|
@@ -1,783 +0,0 @@
|
|
|
-package com.usai.ratradefiling.detail;
|
|
|
|
|
-
|
|
|
|
|
-import android.app.ProgressDialog;
|
|
|
|
|
-import android.content.Context;
|
|
|
|
|
-import android.content.Intent;
|
|
|
|
|
-import android.os.Bundle;
|
|
|
|
|
-import android.os.Handler;
|
|
|
|
|
-import android.os.Message;
|
|
|
|
|
-import android.view.LayoutInflater;
|
|
|
|
|
-import android.view.MenuItem;
|
|
|
|
|
-import android.view.View;
|
|
|
|
|
-import android.view.ViewGroup;
|
|
|
|
|
-import android.widget.ArrayAdapter;
|
|
|
|
|
-import android.widget.ExpandableListView;
|
|
|
|
|
-import android.widget.ListView;
|
|
|
|
|
-import android.widget.PopupWindow;
|
|
|
|
|
-import android.widget.TextView;
|
|
|
|
|
-
|
|
|
|
|
-import androidx.annotation.NonNull;
|
|
|
|
|
-import androidx.annotation.Nullable;
|
|
|
|
|
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
|
|
|
-
|
|
|
|
|
-import com.usai.ratradefiling.R;
|
|
|
|
|
-import com.usai.ratradefiling.base.BasicActivity;
|
|
|
|
|
-import com.usai.ratradefiling.detail.model.DetailActionSelectionModel;
|
|
|
|
|
-import com.usai.ratradefiling.detail.model.DetailSubActionModel;
|
|
|
|
|
-//import com.usai.ratradefiling.network.Network;
|
|
|
|
|
-//import com.usai.ratradefiling.update.UpdateActivity;
|
|
|
|
|
-
|
|
|
|
|
-import org.json.JSONArray;
|
|
|
|
|
-import org.json.JSONException;
|
|
|
|
|
-import org.json.JSONObject;
|
|
|
|
|
-
|
|
|
|
|
-import java.lang.ref.WeakReference;
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-
|
|
|
|
|
-import static com.usai.ratradefiling.detail.model.DetailSubActionModel.DetailActionSubType.DetailActionSubTypeAccept;
|
|
|
|
|
-import static com.usai.ratradefiling.detail.model.DetailSubActionModel.DetailActionSubType.DetailActionSubTypeEnum;
|
|
|
|
|
-import static com.usai.ratradefiling.detail.model.DetailSubActionModel.DetailActionSubType.DetailActionSubTypeUpdate;
|
|
|
|
|
-
|
|
|
|
|
-public class DetailActivity extends BasicActivity {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private final static String IntentOrderIDKey = "orderID";
|
|
|
|
|
- private final static String IntentOrderStatusKey = "orderStatus";
|
|
|
|
|
- private final static String IntentOrderType2Key = "orderType2";
|
|
|
|
|
- private final static String IntentStatusNoKey = "statusNo";
|
|
|
|
|
-
|
|
|
|
|
- private final static String SaveDataKey = "DetailSaveJSON";
|
|
|
|
|
- private final static String SaveOrderIDKey = "DetailSaveOrderID";
|
|
|
|
|
- private final static String SaveOrderStatusKey = "DetailSaveOrderStatus";
|
|
|
|
|
- private final static String SaveOrderType2Key = "DetailSaveOrderType2";
|
|
|
|
|
- private final static String SaveStatusNo2Key = "DetailSaveStatusNo";
|
|
|
|
|
- private final static String SavedLoadKey = "DetailSaveLoad";
|
|
|
|
|
- private final static String SavedFirstVisible = "SavedFirstVisible";
|
|
|
|
|
-
|
|
|
|
|
- public final static String CheckDetailNotification = "com.usai.redant.apexdriver.CheckDetailNotification";
|
|
|
|
|
-
|
|
|
|
|
- public static Intent build(Context context, String orderID,int status,String type2,String statusNo) {
|
|
|
|
|
-
|
|
|
|
|
- if (context == null) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Intent intent = new Intent(context,DetailActivity.class);
|
|
|
|
|
- if (orderID != null) {
|
|
|
|
|
- intent.putExtra(IntentOrderIDKey,orderID);
|
|
|
|
|
- }
|
|
|
|
|
- if (type2 != null) {
|
|
|
|
|
- intent.putExtra(IntentOrderType2Key,type2);
|
|
|
|
|
- }
|
|
|
|
|
- if (statusNo != null) {
|
|
|
|
|
- intent.putExtra(IntentStatusNoKey,statusNo);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- intent.putExtra(IntentOrderStatusKey,status);
|
|
|
|
|
- return intent;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private String mOrderID;
|
|
|
|
|
- private String mOrderType2;
|
|
|
|
|
- private String mStatusNo;
|
|
|
|
|
- private int mOrderStatus;
|
|
|
|
|
-
|
|
|
|
|
- private Context mCtx = this;
|
|
|
|
|
- private DetailActivity self = this;
|
|
|
|
|
- private ExpandableListView mListView;
|
|
|
|
|
- private SwipeRefreshLayout mRefresh;
|
|
|
|
|
- private DetailAdapter mAdapter;
|
|
|
|
|
- private ArrayList<DetailSectionModel> mSectionArray = new ArrayList<>();
|
|
|
|
|
- private JSONObject mJson;
|
|
|
|
|
-
|
|
|
|
|
- private DetailHandler mHandler;
|
|
|
|
|
- private TextView mEmptyView;
|
|
|
|
|
- private boolean mLoad = false;
|
|
|
|
|
- private int mFirstVisible = 0;
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
|
|
-// setContentView(R.layout.activity_detail);
|
|
|
|
|
-//
|
|
|
|
|
-// androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
-// if(actionBar != null){
|
|
|
|
|
-// actionBar.setHomeButtonEnabled(true);
|
|
|
|
|
-// actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// setTitle(getString(R.string.detail_title));
|
|
|
|
|
-//
|
|
|
|
|
-// if (getIntent() != null) {
|
|
|
|
|
-// mOrderID = getIntent().getStringExtra(IntentOrderIDKey);
|
|
|
|
|
-// mOrderType2 = getIntent().getStringExtra(IntentOrderType2Key);
|
|
|
|
|
-// mOrderStatus = getIntent().getIntExtra(IntentOrderStatusKey,0);
|
|
|
|
|
-// mStatusNo = getIntent().getStringExtra(IntentStatusNoKey);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// mHandler = new DetailHandler(this);
|
|
|
|
|
-//
|
|
|
|
|
-// mListView = findViewById(R.id.detail_list_view);
|
|
|
|
|
-// mAdapter = new DetailAdapter(mCtx,self,mSectionArray);
|
|
|
|
|
-//
|
|
|
|
|
-// mListView.setAdapter(mAdapter);
|
|
|
|
|
-// mListView.setGroupIndicator(null);
|
|
|
|
|
-// mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
|
|
|
|
|
-// return true; // 不允许GroupView点击
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-//
|
|
|
|
|
-// mRefresh = findViewById(R.id.detail_refresh);
|
|
|
|
|
-// mRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onRefresh() {
|
|
|
|
|
-// loadData();
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-//
|
|
|
|
|
-// mEmptyView = findViewById(R.id.detail_empty_btn);
|
|
|
|
|
-// mEmptyView.setText(getString(R.string.empty_msg));
|
|
|
|
|
-// mEmptyView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onClick(View v) {
|
|
|
|
|
-// loadData();
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-// mListView.setEmptyView(findViewById(R.id.detail_empty_view));
|
|
|
|
|
-//
|
|
|
|
|
-// mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
|
|
|
-//
|
|
|
|
|
-// mFirstVisible = firstVisibleItem;
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-//
|
|
|
|
|
-// if (savedInstanceState != null) {
|
|
|
|
|
-//
|
|
|
|
|
-// String jsonStr = savedInstanceState.getString(SaveDataKey);
|
|
|
|
|
-// if (jsonStr != null) {
|
|
|
|
|
-//
|
|
|
|
|
-// try {
|
|
|
|
|
-//
|
|
|
|
|
-// JSONObject json = new JSONObject(jsonStr);
|
|
|
|
|
-//
|
|
|
|
|
-// handleJson(json);
|
|
|
|
|
-// changeData();
|
|
|
|
|
-//
|
|
|
|
|
-// } catch (JSONException e) {
|
|
|
|
|
-// e.printStackTrace();
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// mOrderID = savedInstanceState.getString(SaveOrderIDKey);
|
|
|
|
|
-// mOrderType2 = savedInstanceState.getString(SaveOrderType2Key);
|
|
|
|
|
-// mOrderStatus = savedInstanceState.getInt(SaveOrderStatusKey);
|
|
|
|
|
-// mStatusNo = savedInstanceState.getString(SaveStatusNo2Key);
|
|
|
|
|
-// mLoad = savedInstanceState.getBoolean(SavedLoadKey);
|
|
|
|
|
-//
|
|
|
|
|
-// final int tmpVisible = savedInstanceState.getInt(SavedFirstVisible);
|
|
|
|
|
-// mListView.post(new Runnable() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void run() {
|
|
|
|
|
-// mListView.setSelection(tmpVisible);
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-//
|
|
|
|
|
-// } else {
|
|
|
|
|
-// loadData();
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
- switch (item.getItemId()) {
|
|
|
|
|
- case android.R.id.home:
|
|
|
|
|
- this.finish(); // back button
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onSaveInstanceState(Bundle outState) {
|
|
|
|
|
- super.onSaveInstanceState(outState);
|
|
|
|
|
-
|
|
|
|
|
- if (mJson != null) {
|
|
|
|
|
- outState.putString(SaveDataKey,mJson.toString());
|
|
|
|
|
- }
|
|
|
|
|
- if (mOrderID != null) {
|
|
|
|
|
- outState.putString(SaveOrderIDKey,mOrderID);
|
|
|
|
|
- }
|
|
|
|
|
- if (mOrderType2 != null) {
|
|
|
|
|
- outState.putString(SaveOrderType2Key,mOrderType2);
|
|
|
|
|
- }
|
|
|
|
|
- outState.putInt(SaveOrderStatusKey,mOrderStatus);
|
|
|
|
|
-
|
|
|
|
|
- if (mStatusNo != null) {
|
|
|
|
|
- outState.putString(SaveStatusNo2Key,mStatusNo);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- outState.putBoolean(SavedLoadKey,mLoad);
|
|
|
|
|
- outState.putInt(SavedFirstVisible,mFirstVisible);
|
|
|
|
|
-
|
|
|
|
|
- sendLifeCircleBroadCast(0);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onResume() {
|
|
|
|
|
- super.onResume();
|
|
|
|
|
- sendLifeCircleBroadCast(1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onStart() {
|
|
|
|
|
- super.onStart();
|
|
|
|
|
- sendLifeCircleBroadCast(2);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onStop() {
|
|
|
|
|
- super.onStop();
|
|
|
|
|
- sendLifeCircleBroadCast(3);
|
|
|
|
|
- }
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onPause() {
|
|
|
|
|
- sendLifeCircleBroadCast(4);
|
|
|
|
|
- super.onPause();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onLowMemory() {
|
|
|
|
|
- super.onLowMemory();
|
|
|
|
|
- sendLifeCircleBroadCast(5);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onDestroy() {
|
|
|
|
|
-
|
|
|
|
|
- dismissProgressDialog();
|
|
|
|
|
-
|
|
|
|
|
- sendLifeCircleBroadCast(6);
|
|
|
|
|
-
|
|
|
|
|
- super.onDestroy();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void sendLifeCircleBroadCast(int life) {
|
|
|
|
|
-
|
|
|
|
|
-// Intent intent = new Intent(MapLifCircleAction);
|
|
|
|
|
-// intent.putExtra("Life",life);
|
|
|
|
|
-//
|
|
|
|
|
-// LocalBroadcastManager.getInstance(mCtx).sendBroadcast(intent);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void goHome() {
|
|
|
|
|
-// Intent intent = new Intent(self, ApexDriverApplication.sharedApplication().getMainActivityClass());
|
|
|
|
|
-// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
-// self.startActivity(intent);
|
|
|
|
|
-// Intent bintent=new Intent(HomeFragment.HomeReloadBroadcastAction);
|
|
|
|
|
-// bintent.setPackage(getPackageName());
|
|
|
|
|
-// sendBroadcast(bintent);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Data
|
|
|
|
|
- * */
|
|
|
|
|
-
|
|
|
|
|
- private ProgressDialog mProgressDialog;
|
|
|
|
|
- private void showProgressDialog() {
|
|
|
|
|
-// if (mProgressDialog == null) {
|
|
|
|
|
-// mProgressDialog = new ProgressDialog(this);
|
|
|
|
|
-// mProgressDialog.setMessage(getString(R.string.loading));
|
|
|
|
|
-// mProgressDialog.setCancelable(false);
|
|
|
|
|
-// mProgressDialog.show();
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void dismissProgressDialog() {
|
|
|
|
|
- if (mProgressDialog != null && mProgressDialog.isShowing()) {
|
|
|
|
|
- mProgressDialog.dismiss();
|
|
|
|
|
- }
|
|
|
|
|
- mProgressDialog = null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void showWarningMsg(String msg) {
|
|
|
|
|
- if (msg == null || msg.length() == 0) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-// new AlertDialog.Builder(mCtx).setTitle(getString(R.string.warning))
|
|
|
|
|
-// .setMessage(msg)
|
|
|
|
|
-// .setPositiveButton(getString(R.string.btn_ok),null)
|
|
|
|
|
-// .show();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void handleJson(JSONObject json) {
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- JSONArray sectionArr = json.optJSONArray("sections");
|
|
|
|
|
- if (sectionArr != null) {
|
|
|
|
|
-
|
|
|
|
|
- mJson = json;
|
|
|
|
|
- mSectionArray.clear();
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < sectionArr.length(); i++) {
|
|
|
|
|
-
|
|
|
|
|
- JSONObject section = sectionArr.getJSONObject(i);
|
|
|
|
|
- DetailSectionModel model = new DetailSectionModel(mCtx);
|
|
|
|
|
-
|
|
|
|
|
- model.title = section.optString("title");
|
|
|
|
|
- model.setValues(section.optJSONArray("values"));
|
|
|
|
|
-
|
|
|
|
|
- mSectionArray.add(model);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void changeData() {
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 手动调用打开/关闭 Group,否则默认关闭
|
|
|
|
|
- * */
|
|
|
|
|
- if (mSectionArray.size() > 0) {
|
|
|
|
|
- for (int i = 0; i < mSectionArray.size(); i++) {
|
|
|
|
|
- mListView.expandGroup(i);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- mAdapter.notifyDataSetChanged();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void reload() {
|
|
|
|
|
- loadData();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void loadData() {
|
|
|
|
|
- findViewById(R.id.label_cache).setVisibility(View.INVISIBLE);
|
|
|
|
|
- showProgressDialog();
|
|
|
|
|
-
|
|
|
|
|
- if (mSectionArray != null) {
|
|
|
|
|
- mSectionArray.clear();
|
|
|
|
|
- }
|
|
|
|
|
- if (mAdapter != null) {
|
|
|
|
|
- mAdapter.notifyDataSetChanged();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- new Thread(new Runnable() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void run() {
|
|
|
|
|
-
|
|
|
|
|
-// JSONObject json = com.usai.ratradefiling.network.Network.requestOrderDetail(mCtx,mOrderID,mOrderStatus,mOrderType2,mStatusNo);
|
|
|
|
|
-// if(json.optBoolean("iscache"))
|
|
|
|
|
-// {
|
|
|
|
|
-// runOnUiThread(new Runnable() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void run() {
|
|
|
|
|
-// findViewById(R.id.label_cache).setVisibility(View.VISIBLE);
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// Message msg = new Message();
|
|
|
|
|
-// msg.what = DetailHandler.DetailActionReloadData;
|
|
|
|
|
-// msg.obj = json;
|
|
|
|
|
-// mHandler.sendMessage(msg);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }).start();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void handleRemoteAction(final DetailSubActionModel model) {
|
|
|
|
|
-
|
|
|
|
|
- showProgressDialog();
|
|
|
|
|
- new Thread(new Runnable() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void run() {
|
|
|
|
|
-
|
|
|
|
|
-// JSONObject json = Network.report(mOrderID,mOrderStatus,model.actionSubType,model.index,model.actionTitle,model.url,model.params);
|
|
|
|
|
-//
|
|
|
|
|
-// Message msg = new Message();
|
|
|
|
|
-// msg.what = DetailHandler.DetailActionRemote;
|
|
|
|
|
-// msg.obj = json;
|
|
|
|
|
-// msg.arg1 = model.remoteActionType;
|
|
|
|
|
-// mHandler.sendMessage(msg);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }).start();
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void handleEnumAction(View view,DetailSubActionModel actionModel) {
|
|
|
|
|
-
|
|
|
|
|
-// showWindow(view,actionModel.enums);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void showUpdate(DetailSubActionModel model) {
|
|
|
|
|
-
|
|
|
|
|
-// Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2, model.index);
|
|
|
|
|
-// mCtx.startActivity(intent);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Detail Action
|
|
|
|
|
- * */
|
|
|
|
|
-
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void performAction(final View view, final DetailSubActionModel actionModel) {
|
|
|
|
|
-//
|
|
|
|
|
-// if (actionModel == null) {
|
|
|
|
|
-// return;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// if (actionModel.alert) {
|
|
|
|
|
-//
|
|
|
|
|
-//// new AlertDialog.Builder(mCtx)
|
|
|
|
|
-//// .setTitle(actionModel.alertTitle)
|
|
|
|
|
-//// .setMessage(actionModel.alertMsg)
|
|
|
|
|
-//// .setNegativeButton(getString(R.string.btn_cancel),null)
|
|
|
|
|
-//// .setPositiveButton(getString(R.string.btn_ok), new DialogInterface.OnClickListener() {
|
|
|
|
|
-//// @Override
|
|
|
|
|
-//// public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
-//// handleAction(view,actionModel);
|
|
|
|
|
-//// }
|
|
|
|
|
-//// })
|
|
|
|
|
-//// .show();
|
|
|
|
|
-//
|
|
|
|
|
-// } else {
|
|
|
|
|
-// handleAction(view,actionModel);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void navigationTo(DetailLocationModel locationModel) {
|
|
|
|
|
-//
|
|
|
|
|
-// if (locationModel != null && !TextUtils.isEmpty(locationModel.street)) {
|
|
|
|
|
-//
|
|
|
|
|
-// Uri gmmIntentUri = Uri.parse("google.navigation:q=" + locationModel.street + "&mode=d");
|
|
|
|
|
-// Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
|
|
|
|
-// mapIntent.setPackage("com.google.android.apps.maps");
|
|
|
|
|
-// if (mapIntent.resolveActivity(getPackageManager()) != null) {
|
|
|
|
|
-// startActivity(mapIntent);
|
|
|
|
|
-// } else {
|
|
|
|
|
-// Toast.makeText(mCtx,getString(R.string.alert_no_google_map),Toast.LENGTH_LONG).show();
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void showMap(DetailMapModel model) {
|
|
|
|
|
-// if (model != null && !TextUtils.isEmpty(model.getLat()) && !TextUtils.isEmpty(model.getLon())) {
|
|
|
|
|
-//
|
|
|
|
|
-// Uri gmmIntentUri = Uri.parse("geo:" + model.getLat() + "," + model.getLon() + "?mode=d");
|
|
|
|
|
-// Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
|
|
|
|
-// mapIntent.setPackage("com.google.android.apps.maps");
|
|
|
|
|
-// if (mapIntent.resolveActivity(getPackageManager()) != null) {
|
|
|
|
|
-// startActivity(mapIntent);
|
|
|
|
|
-// } else {
|
|
|
|
|
-// Toast.makeText(mCtx,getString(R.string.alert_no_google_map),Toast.LENGTH_LONG).show();
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
- private void handleAction(View view, DetailSubActionModel actionModel) {
|
|
|
|
|
-
|
|
|
|
|
- switch (actionModel.actionType) {
|
|
|
|
|
- case DetailSubActionModel.DetailActionType.DetailActionTypeLocal: {
|
|
|
|
|
-
|
|
|
|
|
- if (actionModel.actionSubType == DetailActionSubTypeEnum) {
|
|
|
|
|
- handleEnumAction(view,actionModel);
|
|
|
|
|
- } else if (actionModel.actionSubType == DetailActionSubTypeUpdate) {
|
|
|
|
|
- showUpdate(actionModel);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- case DetailSubActionModel.DetailActionType.DetailActionTypeRemote: {
|
|
|
|
|
-
|
|
|
|
|
- if (actionModel.actionSubType == DetailActionSubTypeAccept) {
|
|
|
|
|
-// ApexDriverApplication.sharedApplication().setRequiredBackgroundLocation(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- handleRemoteAction(actionModel);
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Handler
|
|
|
|
|
- * */
|
|
|
|
|
-
|
|
|
|
|
- private static final class DetailHandler extends Handler {
|
|
|
|
|
-
|
|
|
|
|
- static final int DetailActionReloadData = 0;
|
|
|
|
|
- static final int DetailActionRemote = 1;
|
|
|
|
|
-
|
|
|
|
|
- WeakReference<DetailActivity> mWeakDetail;
|
|
|
|
|
-
|
|
|
|
|
- public DetailHandler(DetailActivity activity) {
|
|
|
|
|
- mWeakDetail = new WeakReference<>(activity);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void handleMessage(Message msg) {
|
|
|
|
|
- super.handleMessage(msg);
|
|
|
|
|
-
|
|
|
|
|
-// DetailActivity activity = mWeakDetail.get();
|
|
|
|
|
-// activity.dismissProgressDialog();
|
|
|
|
|
-// switch (msg.what) {
|
|
|
|
|
-// case DetailActionReloadData: {
|
|
|
|
|
-//// if(activity.mListView.getEmptyView()==null)
|
|
|
|
|
-//// {
|
|
|
|
|
-//// activity.mListView.setEmptyView(activity.findViewById(R.id.detail_empty_view));
|
|
|
|
|
-//// }
|
|
|
|
|
-//
|
|
|
|
|
-// if (activity.mRefresh.isRefreshing()) {
|
|
|
|
|
-// activity.mRefresh.setRefreshing(false);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// JSONObject json = (JSONObject) msg.obj;
|
|
|
|
|
-//
|
|
|
|
|
-// if (json != null) {
|
|
|
|
|
-//
|
|
|
|
|
-// try {
|
|
|
|
|
-// int restul = json.getInt("result");
|
|
|
|
|
-// if (restul == RESULT_TRUE) {
|
|
|
|
|
-// activity.mEmptyView.setVisibility(View.GONE);
|
|
|
|
|
-// if (!activity.mLoad) {
|
|
|
|
|
-// activity.mLoad = true;
|
|
|
|
|
-//
|
|
|
|
|
-// Intent intent = new Intent(CheckDetailNotification);
|
|
|
|
|
-// intent.putExtra("order_id",activity.mOrderID);
|
|
|
|
|
-// intent.setPackage( activity.getPackageName());
|
|
|
|
|
-// activity.sendBroadcast(intent);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// activity.handleJson(json);
|
|
|
|
|
-//
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // error
|
|
|
|
|
-// activity.mEmptyView.setVisibility(View.VISIBLE);
|
|
|
|
|
-// String errMsg = json.optString("err_msg");
|
|
|
|
|
-// if (errMsg == null || errMsg.length() == 0) {
|
|
|
|
|
-// errMsg = activity.getString(R.string.sorry);
|
|
|
|
|
-// }
|
|
|
|
|
-// activity.showWarningMsg(errMsg);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// } catch (JSONException e) {
|
|
|
|
|
-// activity.mEmptyView.setVisibility(View.VISIBLE);
|
|
|
|
|
-// e.printStackTrace();
|
|
|
|
|
-// // error
|
|
|
|
|
-// String errMsg = activity.getString(R.string.sorry);
|
|
|
|
|
-// activity.showWarningMsg(errMsg);
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // error
|
|
|
|
|
-// String errMsg = activity.getString(R.string.connect_wrong);
|
|
|
|
|
-// activity.showWarningMsg(errMsg);
|
|
|
|
|
-// }
|
|
|
|
|
-// activity.changeData();
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// case DetailActionRemote: {
|
|
|
|
|
-//
|
|
|
|
|
-// JSONObject json = (JSONObject)msg.obj;
|
|
|
|
|
-// if (json != null) {
|
|
|
|
|
-// int result = json.optInt("result");
|
|
|
|
|
-// if (result == RESULT_TRUE) {
|
|
|
|
|
-//
|
|
|
|
|
-// switch (msg.arg1) {
|
|
|
|
|
-// case DetailRemoteActionTypeGoHome: {
|
|
|
|
|
-// activity.goHome();
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// case DetailRemoteActionTypeReload: {
|
|
|
|
|
-// activity.reload();
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // error;
|
|
|
|
|
-// String errMsg = json.optString("err_msg");
|
|
|
|
|
-// if (errMsg == null || errMsg.length() == 0) {
|
|
|
|
|
-// errMsg = activity.getString(R.string.sorry);
|
|
|
|
|
-// }
|
|
|
|
|
-// activity.showWarningMsg(errMsg);
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // error
|
|
|
|
|
-// String errMsg = activity.getString(R.string.sorry);
|
|
|
|
|
-// activity.showWarningMsg(errMsg);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// default:{
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// break;
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Pop
|
|
|
|
|
- * */
|
|
|
|
|
- private PopupWindow popupWindow;
|
|
|
|
|
- private ListView popListView;
|
|
|
|
|
- private PopAdapter popAdapter;
|
|
|
|
|
- private View popView;
|
|
|
|
|
- private void showWindow(View parent, final ArrayList<DetailActionSelectionModel> models) {
|
|
|
|
|
-//
|
|
|
|
|
-// LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
-//
|
|
|
|
|
-// popView = layoutInflater.inflate(R.layout.pop_list_view, null);
|
|
|
|
|
-//
|
|
|
|
|
-// popListView = (ListView) popView.findViewById(R.id.pop_list);
|
|
|
|
|
-//
|
|
|
|
|
-// popAdapter = new PopAdapter(this, R.layout.pop_cell,models);
|
|
|
|
|
-// popListView.setAdapter(popAdapter);
|
|
|
|
|
-//
|
|
|
|
|
-// // 创建一个PopuWidow对象
|
|
|
|
|
-// popupWindow = new PopupWindow(popView, RAUtil.dp2px(mCtx,250), RAUtil.dp2px(mCtx,300));
|
|
|
|
|
-//
|
|
|
|
|
-// // 使其聚集
|
|
|
|
|
-// popupWindow.setFocusable(true);
|
|
|
|
|
-// // 设置允许在外点击消失
|
|
|
|
|
-// popupWindow.setOutsideTouchable(true);
|
|
|
|
|
-//
|
|
|
|
|
-// popupWindow.update();
|
|
|
|
|
-//
|
|
|
|
|
-// // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
|
|
|
|
|
-// popupWindow.setBackgroundDrawable(new ColorDrawable(Color.RED));
|
|
|
|
|
-// WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
|
|
|
|
-// // 显示的位置
|
|
|
|
|
-// int xPos = windowManager.getDefaultDisplay().getWidth() / 2 - popupWindow.getWidth() / 2;
|
|
|
|
|
-//
|
|
|
|
|
-// popupWindow.showAsDropDown(parent, xPos, 0);
|
|
|
|
|
-//// popupWindow.showAsDropDown(parent);
|
|
|
|
|
-//
|
|
|
|
|
-// popListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
-//
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
|
|
|
|
-//
|
|
|
|
|
-// final DetailActionSelectionModel model = models.get(position);
|
|
|
|
|
-//
|
|
|
|
|
-// if (position != 0) {
|
|
|
|
|
-//
|
|
|
|
|
-// DetailActionSelectionModel currentModel = models.get(0);
|
|
|
|
|
-//
|
|
|
|
|
-// new AlertDialog.Builder(mCtx)
|
|
|
|
|
-// .setTitle(getString(R.string.warning))
|
|
|
|
|
-// .setMessage(String.format(getString(R.string.not_done),currentModel.actionTitle,model.actionTitle))
|
|
|
|
|
-// .setNegativeButton(getString(R.string.btn_cancel),null)
|
|
|
|
|
-// .setPositiveButton(getString(R.string.btn_ok), new DialogInterface.OnClickListener() {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
-// if (popupWindow != null) {
|
|
|
|
|
-// popupWindow.dismiss();
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2,model.actionIndex);
|
|
|
|
|
-// mCtx.startActivity(intent);
|
|
|
|
|
-// }
|
|
|
|
|
-// })
|
|
|
|
|
-// .show();
|
|
|
|
|
-//
|
|
|
|
|
-// } else {
|
|
|
|
|
-//
|
|
|
|
|
-// if (popupWindow != null) {
|
|
|
|
|
-// popupWindow.dismiss();
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// Intent intent = UpdateActivity.build(mCtx,mOrderID,model.actionID,model.actionTitle,mOrderType2, model.actionIndex);
|
|
|
|
|
-// mCtx.startActivity(intent);
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private class PopAdapter extends ArrayAdapter<DetailActionSelectionModel> {
|
|
|
|
|
-
|
|
|
|
|
- private Context ctx;
|
|
|
|
|
- private int resId;
|
|
|
|
|
- private ArrayList<DetailActionSelectionModel> selectionModels;
|
|
|
|
|
-
|
|
|
|
|
- public PopAdapter(@NonNull Context context, int resource,ArrayList<DetailActionSelectionModel> selectionModels) {
|
|
|
|
|
- super(context, resource);
|
|
|
|
|
- ctx = context;
|
|
|
|
|
- resId = resource;
|
|
|
|
|
- this.selectionModels = selectionModels;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public int getCount() {
|
|
|
|
|
-
|
|
|
|
|
- return selectionModels.size();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @NonNull
|
|
|
|
|
- @Override
|
|
|
|
|
- public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
|
|
|
|
-
|
|
|
|
|
- PopHolder holder;
|
|
|
|
|
- if (convertView == null) {
|
|
|
|
|
-
|
|
|
|
|
- convertView = LayoutInflater.from(ctx).inflate(resId,null);
|
|
|
|
|
- holder = new PopHolder(convertView);
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
-
|
|
|
|
|
- holder = (PopHolder)convertView.getTag();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- DetailActionSelectionModel model = selectionModels.get(position);
|
|
|
|
|
- holder.bindPopModel(model);
|
|
|
|
|
-
|
|
|
|
|
- return convertView;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private class PopHolder {
|
|
|
|
|
-
|
|
|
|
|
- TextView titleTv;
|
|
|
|
|
-
|
|
|
|
|
- PopHolder(View view) {
|
|
|
|
|
-
|
|
|
|
|
-// titleTv = view.findViewById(R.id.pop_title_tv);
|
|
|
|
|
-//
|
|
|
|
|
-// view.setTag(this);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void bindPopModel(DetailActionSelectionModel model) {
|
|
|
|
|
- titleTv.setText(model.actionTitle);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|