Browse Source

1.修改Android Apex Mobile 删除Result。

Pen Li 7 years ago
parent
commit
7d08759a33

+ 0 - 594
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/ApexResultActivity.java

@@ -1,594 +0,0 @@
-package com.usai.apex.apexResult;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Color;
-import android.support.v4.view.MenuItemCompat;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.Gravity;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AbsListView;
-import android.widget.AdapterView;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.usai.apex.ApexTrackingApplication;
-import com.usai.apex.CustomizeFieldsActivity;
-import com.usai.apex.R;
-import com.usai.apex.Result.AMResultActivity;
-import com.usai.apex.actionSheet.ActionSheet;
-import com.usai.apex.mainframe.NewDetailActivity;
-import com.usai.apex.pdf.PDFPreviewActivity;
-import com.usai.util.Network;
-import com.usai.util.commonUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.Iterator;
-
-
-public class ApexResultActivity extends AppCompatActivity implements ApexResultPresenter.ApexResultProtocol {
-
-    // region Build
-
-    private static final String ParametersKey = "Apex_Result_Parameters_Key";
-
-    public static void startResultActivity(Activity activity, Bundle params) {
-
-        if (activity != null) {
-
-            Intent intent = new Intent(activity, ApexResultActivity.class);
-            if (params != null) {
-                intent.putExtra(ParametersKey, params);
-            }
-            activity.startActivity(intent);
-        }
-
-    }
-
-    // endregion
-
-    // region Request Code
-
-    private static class RequestCode {
-
-        static final int Field_Setting = 1010;
-    }
-
-    // endregion
-
-    // region Property
-
-    private Context mCtx = this;
-
-    private ListView mListView;
-    private SwipeRefreshLayout mRefreshLayout;
-    private ProgressBar mProgressBar;
-    private TextView mListFooterView;
-
-    private ScrollListener mScrollListener;
-
-    private ApexResultPresenter mPresenter;
-    private ApexResultAdapter mAdapter;
-    private Bundle mParams;
-
-    // endregion
-
-    // region Override
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_apex_result);
-
-        //
-        if (savedInstanceState != null) {
-            mParams = savedInstanceState.getBundle(ParametersKey);
-        } else {
-            mParams = getIntent().getBundleExtra(ParametersKey);
-        }
-        if (mParams == null) {
-            mParams = new Bundle();
-        }
-
-        setup();
-
-        if (savedInstanceState != null) {
-            mPresenter.onRestoreInstanceState(savedInstanceState);
-        } else {
-            mPresenter.loadData();
-        }
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-
-        if (item.getItemId() == android.R.id.home) {
-            finish();
-            return  true;
-        } else if (item.getItemId() == R.id.apex_result_menu) {
-            menuItemClick();
-            return true;
-        }
-
-        return super.onOptionsItemSelected(item);
-    }
-
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        getMenuInflater().inflate(R.menu.apex_result_menu, menu);
-        return true;
-    }
-
-    @Override
-    protected void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-
-        outState.putBundle(ParametersKey, mParams);
-        mPresenter.onSaveInstanceState(outState);
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
-        if (requestCode == RequestCode.Field_Setting) {
-            mPresenter.dirty = true;
-            loadData();
-        }
-    }
-
-    // endregion
-
-    // region Setting
-
-    private void setup() {
-
-        mPresenter = new ApexResultPresenter(this, mParams);
-        mAdapter = new ApexResultAdapter(mCtx, mPresenter);
-
-        setupActionBar();
-        setupRefreshLayout();
-        setupListView();
-
-        mProgressBar = findViewById(R.id.apex_result_progress_bar);
-    }
-
-    private void setupListView() {
-
-        mListView = findViewById(R.id.apex_result_list_view);
-        mListView.setAdapter(mAdapter);
-
-        setupListFooterView();
-        AbsListView.LayoutParams footerLayoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
-        mListFooterView.setLayoutParams(footerLayoutParams);
-        mListView.addFooterView(mListFooterView);
-
-        mScrollListener = new ScrollListener();
-        mListView.setOnScrollListener(mScrollListener);
-
-        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                clickItemCell(view, position);
-            }
-        });
-    }
-
-    private void setupListFooterView() {
-        mListFooterView = new TextView(mCtx);
-        mListFooterView.setBackgroundColor(Color.WHITE);
-        mListFooterView.setGravity(Gravity.CENTER);
-        mListFooterView.setText("loading more...");
-        mListFooterView.setTextSize(commonUtil.sp2px(mCtx,8));
-        mListFooterView.setVisibility(View.INVISIBLE);
-    }
-
-    private void setupRefreshLayout() {
-
-        mRefreshLayout = findViewById(R.id.apex_result_refresh_layout);
-        mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onRefresh() {
-                refresh();
-            }
-        });
-    }
-
-
-    private void setupActionBar() {
-
-        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
-        if(actionBar != null){
-            actionBar.setHomeButtonEnabled(true);
-            actionBar.setDisplayHomeAsUpEnabled(true);
-        }
-    }
-
-    // endregion
-
-    // region Action
-    private void loadData() {
-        mPresenter.loadData();
-    }
-
-    private void refresh() {
-        mPresenter.refreshData();
-    }
-
-    private void loadMore() {
-        mPresenter.loadMoreData();
-    }
-
-    private void clickItemCell(View cell, int position) {
-
-        handleRowAction(position);
-    }
-
-    // endregion
-
-    // region ProgressBar
-
-    public void showProgressBar() {
-        mProgressBar.setVisibility(View.VISIBLE);
-    }
-
-    public void dismissProgressBar() {
-        mProgressBar.setVisibility(View.GONE);
-    }
-
-    // endregion
-
-    // region Alert
-
-    private void showAlertMessage(String msg) {
-        new AlertDialog.Builder(mCtx)
-                .setTitle("Warning")
-                .setMessage(msg)
-                .setPositiveButton("OK",null)
-                .show();
-    }
-
-    // endregion
-
-    // region Presenter Delegate
-    @Override
-    public void onStartLoading() {
-        isLoading = true;
-        showProgressBar();
-    }
-
-    @Override
-    public void onStopLoading() {
-        if (mRefreshLayout.isRefreshing()) {
-            mRefreshLayout.setRefreshing(false);
-        }
-        mListFooterView.setVisibility(View.INVISIBLE);
-        dismissProgressBar();
-
-        isLoading = false;
-    }
-
-    @Override
-    public void onSuccess(String title) {
-        setTitle(title);
-        mAdapter.notifyDataSetChanged();
-    }
-
-    @Override
-    public void onFailed(String errMsg) {
-        if (errMsg == null) {
-            errMsg = "Sorry, something is wrong.";
-        }
-        showAlertMessage(errMsg);
-    }
-
-    @Override
-    public void onNoMoreData() {
-        showAlertMessage("No More Data");
-    }
-
-    @Override
-    public void onDownloadFile(String path, Bundle params) {
-
-        String email = params.getString("email");
-        String email_subject = params.getString("email_subject");
-        String email_content = params.getString("email_content");
-
-        previewPDF(path, email, email_subject, email_content);
-    }
-    // endregion
-
-    // region Menu Action
-
-    private void menuItemClick() {
-
-        ActionSheet actionSheet = new ActionSheet(mCtx);
-
-        actionSheet.addAction("Setting", ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                showFieldsSetting();
-            }
-        });
-
-        actionSheet.addAction("Save", ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                saveSearchParameters();
-            }
-        });
-
-        actionSheet.addAction("Cancel", ActionSheet.ActionType.ACtionTypeCancel, new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-
-            }
-        });
-
-        actionSheet.show();
-
-    }
-
-    private void saveSearchParameters() {
-
-        final View edit = new EditText(mCtx);
-        new android.app.AlertDialog.Builder(mCtx)
-                .setIconAttribute(android.R.attr.alertDialogIcon)
-                .setTitle(R.string.str_createname)
-                .setView(edit)
-                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int whichButton) {
-
-                                String name = ((EditText) edit).getText().toString();
-                                if(TextUtils.isEmpty(name))
-                                {
-                                    new android.app.AlertDialog.Builder(mCtx)
-                                            .setTitle("Warning")
-                                            .setMessage("Name can not be empty.")
-                                            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
-                                                @Override
-                                                public void onClick(DialogInterface dialog, int which) {
-
-                                                }
-                                            })
-                                            .show();
-                                    return;
-                                }
-
-                                mPresenter.saveSearchParametersWithName(getIntent().toUri(0), name);
-
-                            }
-                        })
-                .setNegativeButton(android.R.string.cancel, null)
-                .create()
-                .show();
-
-    }
-
-    private void showFieldsSetting() {
-
-        Intent intent = new Intent();
-        intent.setClass(this, CustomizeFieldsActivity.class);
-        intent.putExtra("user", ApexTrackingApplication.get_user());
-        intent.putExtra("function_name", mParams.getString("module_name"));
-        intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
-        startActivityForResult(intent,RequestCode.Field_Setting);
-    }
-
-    // endregion
-
-    // region Scroll Listener
-
-    private boolean isLoading = false;
-    private class ScrollListener implements AbsListView.OnScrollListener {
-
-        private int last_index, total_index;
-
-        @Override
-        public void onScrollStateChanged(AbsListView view, int scrollState) {
-            if (last_index == total_index && (scrollState == SCROLL_STATE_IDLE)) {
-                if (!isLoading) {
-
-                    mListFooterView.setVisibility(View.VISIBLE);
-                    loadMore();
-                }
-            }
-        }
-
-        @Override
-        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
-            last_index = firstVisibleItem + visibleItemCount;
-            total_index = totalItemCount;
-        }
-    }
-
-    // endregion
-
-    // region Row Action
-
-    private Bundle paramsForIndex(int position, JSONObject action) {
-
-        JSONArray parameters = mPresenter.rowActionParametersForIndex(position);
-        Bundle params = new Bundle();
-        JSONObject actionParams = action.optJSONObject("params");
-        if (actionParams != null) {
-
-            Iterator<String> keys = actionParams.keys();
-            while (keys.hasNext()) {
-                String key = keys.next();
-                try {
-
-                    int idx = actionParams.getInt(key);
-                    String value = parameters.getString(idx);
-                    params.putString(key, value);
-
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-
-        }
-        return params;
-    }
-
-    private void handleRowAction(int position) {
-
-        JSONArray rowActions = mPresenter.getRowActions();
-        if (rowActions != null) {
-
-            if (rowActions.length() == 1) {
-
-                JSONObject action = rowActions.optJSONObject(0);
-                if (action != null) {
-
-                    Bundle params = paramsForIndex(position, action);
-                    String module = action.optString("module");
-                    if (module != null) {
-                        if (module.equals("quick_look")) {
-
-                            showQuickLookForActionWithParams(action, params);
-
-                        } else if (module.equals("detail")) {
-
-                            showDetailForActionWithParams(action, params);
-                        }
-                    }
-                }
-
-            } else {
-
-                ActionSheet actionSheet = new ActionSheet(mCtx);
-
-                for (int i = 0; i < rowActions.length(); i++) {
-
-                    try {
-
-                        final JSONObject json = rowActions.getJSONObject(i);
-                        final Bundle params = paramsForIndex(position, json);
-
-                        String title = json.getString("title");
-                        final String module = json.getString("module");
-
-                        actionSheet.addAction(title, ActionSheet.ActionType.ActionTypeDefault, new View.OnClickListener() {
-                            @Override
-                            public void onClick(View v) {
-
-                                if (module.equals("quick_look")) {
-
-                                    showQuickLookForActionWithParams(json, params);
-
-                                } else if (module.equals("detail")) {
-
-                                    showDetailForActionWithParams(json, params);
-                                }
-
-                            }
-                        });
-
-                    } catch (JSONException e) {
-                        e.printStackTrace();
-                    }
-
-                } // for
-
-                actionSheet.addAction("Cancel", ActionSheet.ActionType.ACtionTypeCancel, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-
-                    }
-                });
-
-                actionSheet.show();
-
-            }
-        }
-    }
-
-    private void showQuickLookForActionWithParams(JSONObject action, Bundle params) {
-
-        try {
-
-            String url = action.getString("url");
-            mPresenter.downloadFile(url, params);
-
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-    }
-
-    private void showDetailForActionWithParams(JSONObject action, Bundle params) {
-
-        String module_name = mPresenter.getParams().getString("module_name");
-        String detail_id = params.getString("id");
-        JSONArray actions = mPresenter.getActions();
-        if (actions == null) {
-            actions = new JSONArray();
-        }
-
-        Intent intent = new Intent(mCtx, NewDetailActivity.class);
-        intent.putExtra("function_name", module_name);
-        intent.putExtra("actions_count", actions.length());
-        intent.putExtra("_id",detail_id);
-
-        for (int i = 0; i < actions.length(); i++) {
-            try {
-                String name = actions.getString(i);
-                intent.putExtra("action" + i, name);
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-        }
-
-        startActivity(intent);
-    }
-
-    // endregion
-
-    // region PDF
-
-    private void previewPDF(String file,String email,String subject,String content) {
-
-        Intent myIntent = new Intent(mCtx, PDFPreviewActivity.class);
-        myIntent.putExtra("file",file);
-        myIntent.putExtra("iscache",true);
-
-        try {
-            JSONObject json = new JSONObject();
-
-            if (email != null) {
-                json.put("email",email);
-            }
-            if (subject != null) {
-                json.put("subject",subject);
-            }
-            if (content != null) {
-                json.put("content",content);
-            }
-            myIntent.putExtra("email",json.toString());
-
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-
-        startActivity(myIntent);
-    }
-
-    // endregion
-}

+ 0 - 176
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/ApexResultAdapter.java

@@ -1,176 +0,0 @@
-package com.usai.apex.apexResult;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-
-import com.usai.apex.apexResult.cell.ApexResultDocumentCell;
-import com.usai.apex.apexResult.cell.ApexResultShipCell;
-import com.usai.apex.apexResult.model.ApexResultBaseModel;
-import com.usai.apex.apexResult.model.ApexResultDocumentModel;
-import com.usai.apex.apexResult.model.ApexResultShipModel;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-public class ApexResultAdapter extends BaseAdapter {
-
-    // region DataSource
-    public static interface ApexResultAdapterDataSource {
-
-        int numberOfResultItem();
-        ApexResultBaseModel resultModelForIndex(int index);
-    }
-    // endregion
-
-    // region Initial
-    private WeakReference<Context> mWeakContext;
-    private WeakReference<ApexResultAdapterDataSource> mWeakDataSource;
-
-    public ApexResultAdapter(Context context, ApexResultAdapterDataSource dataSource) {
-        if (context == null) {
-            mWeakContext = null;
-        } else {
-            mWeakContext = new WeakReference<>(context);
-        }
-
-        if (dataSource == null) {
-            mWeakDataSource = null;
-        } else {
-            mWeakDataSource = new WeakReference<>(dataSource);
-        }
-    }
-    // endregion
-
-    // region Getter
-
-    private Context getContext() {
-        if (mWeakContext == null) {
-            return null;
-        }
-        return mWeakContext.get();
-    }
-
-    private ApexResultAdapterDataSource getDataSource() {
-        if (mWeakDataSource == null) {
-            return null;
-        }
-        return mWeakDataSource.get();
-    }
-
-    // endregion
-
-    // region Override
-
-    @Override
-    public int getCount() {
-        ApexResultAdapterDataSource dataSource = getDataSource();
-        if (dataSource != null) {
-            return dataSource.numberOfResultItem();
-        }
-        return 0;
-    }
-
-    @Override
-    public Object getItem(int position) {
-        ApexResultAdapterDataSource dataSource = getDataSource();
-        if (dataSource != null) {
-            return dataSource.resultModelForIndex(position);
-        }
-        return null;
-    }
-
-    @Override
-    public boolean hasStableIds() {
-        return true;
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return position;
-    }
-
-    @Override
-    public int getViewTypeCount() {
-        return 2;
-    }
-
-    @Override
-    public int getItemViewType(int position) {
-        ApexResultBaseModel model = (ApexResultBaseModel)getItem(position);
-        return model.type;
-    }
-
-    @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-
-        Context context = getContext();
-        if (context != null) {
-
-            ApexResultBaseModel model = (ApexResultBaseModel)getItem(position);
-            if (model.type == ApexResultBaseModel.ApexResultType.APEX_RESULT_TYPE_SHIP.ordinal()) {
-
-                ApexResultShipModel shipModel = (ApexResultShipModel)model;
-                ApexResultShipCell cell = dequeueShipCell(context, convertView);
-                cell.prepareReuse();
-                cell.setTitle(shipModel.title).setDetail(shipModel.detail).setIcon(shipModel.icon).setPort(shipModel.port).setTime(shipModel.date).setDescription(shipModel.desc);
-                cell.setTransportStage(shipModel.transport_stage);
-
-                ArrayList<ApexResultShipModel.ApexResultAddition> additions = shipModel.getAddition();
-                if (additions != null && additions.size() > 0) {
-                    for (ApexResultShipModel.ApexResultAddition addition : additions) {
-                        cell.addAddition(addition.name, addition.value);
-                    }
-                }
-
-                return cell;
-
-            } else if (model.type == ApexResultBaseModel.ApexResultType.APEX_RESULT_TYPE_DOCUMENT.ordinal()) {
-
-                ApexResultDocumentModel documentModel = (ApexResultDocumentModel)model;
-                ApexResultDocumentCell cell = dequeueDocumentCell(context, convertView);
-                cell.prepareReuse();
-                cell.setFileName(documentModel.fileName).setFileType(documentModel.fileType).setFileDescription(documentModel.fileDesc);
-
-                return cell;
-            }
-
-            return new View(context);
-        }
-        return null;
-    }
-
-    // endregion
-
-    // region Configure Cell
-
-    private ApexResultShipCell dequeueShipCell(Context context, View convertView) {
-
-        ApexResultShipCell cell = null;
-
-        if (convertView == null) {
-            cell = ApexResultShipCell.makeShipCell(context);
-        } else {
-            cell = (ApexResultShipCell)convertView;
-        }
-
-        return cell;
-    }
-
-    private ApexResultDocumentCell dequeueDocumentCell(Context context, View convertView) {
-
-        ApexResultDocumentCell cell = null;
-
-        if (convertView == null) {
-            cell = ApexResultDocumentCell.makeDocumentCell(context);
-        } else {
-            cell = (ApexResultDocumentCell)convertView;
-        }
-
-        return cell;
-    }
-
-    // endregion
-
-}

+ 0 - 497
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/ApexResultPresenter.java

@@ -1,497 +0,0 @@
-package com.usai.apex.apexResult;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-
-import com.usai.apex.ApexTrackingApplication;
-import com.usai.apex.apexResult.model.ApexResultBaseModel;
-import com.usai.apex.apexResult.model.ApexResultDocumentModel;
-import com.usai.apex.apexResult.model.ApexResultShipModel;
-import com.usai.apex.operationQueue.OperationQueue;
-import com.usai.util.Network;
-import com.usai.util.RAUtil;
-
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterDataSource {
-
-    // region Protocol
-    public static interface ApexResultProtocol {
-
-        void onStartLoading();
-        void onStopLoading();
-        void onSuccess(String title);
-        void onFailed(String errMsg);
-        void onNoMoreData();
-        void onDownloadFile(String path, Bundle params);
-
-    }
-    // endregion
-
-    // region Enum
-
-    private enum ApexResultFetchDataType {
-        APEX_RESULT_FETCH_DATA_TYPE_INITIAL,
-        APEX_RESULT_FETCH_DATA_TYPE_REFRESH,
-        APEX_RESULT_FETCH_DATA_TYPE_LOAD_MORE
-    }
-
-    // endregion
-
-    // region Initial
-
-    private WeakReference<ApexResultProtocol> mWeakDelegate;
-    private Bundle mParams;
-    private String mFields;
-    private int offset = 0;
-    private static final int detal = 20;
-    private ArrayList<ApexResultBaseModel> mDataArray;
-    private JSONArray rowActions;
-    private JSONArray actions;
-    public boolean dirty = true;
-
-    public ApexResultPresenter(ApexResultProtocol delegate, Bundle params) {
-        if (delegate == null) {
-            mWeakDelegate = null;
-        } else {
-            mWeakDelegate = new WeakReference<>(delegate);
-        }
-        if (params == null) {
-            mParams = new Bundle();
-        } else {
-            mParams = params;
-        }
-
-        if (mParams.containsKey("columns")) {
-
-            dirty = false;
-        } else {
-            dirty = true;
-        }
-    }
-    // endregion
-
-    // region Save Instance
-
-    private static final String Data_Array_Key = "Data_Array_Key";
-    private static final String Offset_Key = "Offset_Key";
-    private static final String Row_Actions_key = "Row_Actions_Key";
-    private static final String Actions_Key = "Actions_Key";
-    private static final String Dirty_Key = "Dirty_Key";
-    private static final String Display_Fields_Key = "Display_Fields_Key";
-
-    public void onSaveInstanceState(Bundle outState) {
-        if (outState != null) {
-
-            outState.putInt(Offset_Key, offset);
-
-            String dataStr = prepareSaveData();
-            if (dataStr != null) {
-                outState.putString(Data_Array_Key, dataStr);
-            }
-
-            if (rowActions != null) {
-                outState.putString(Row_Actions_key, rowActions.toString());
-            }
-
-            if (actions != null) {
-                outState.putString(Actions_Key, actions.toString());
-            }
-
-            outState.putBoolean(Dirty_Key, dirty);
-            if (mFields != null) {
-                outState.putString(Display_Fields_Key, mFields);
-            }
-        }
-    }
-
-    public void onRestoreInstanceState(Bundle savedInstanceState) {
-        if (savedInstanceState != null) {
-
-            offset = savedInstanceState.getInt(Offset_Key);
-
-            String dataStr = savedInstanceState.getString(Data_Array_Key);
-            prepareRestoreData(dataStr);
-
-            try {
-                String js = savedInstanceState.getString(Row_Actions_key);
-                if (js != null) {
-                    rowActions = new JSONArray(js);
-                }
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-
-            try {
-                String js = savedInstanceState.getString(Actions_Key);
-                if (js != null) {
-                    actions = new JSONArray(js);
-                }
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-
-            mFields = savedInstanceState.getString(Display_Fields_Key);
-            dirty = savedInstanceState.getBoolean(Dirty_Key);
-        }
-    }
-
-    private String prepareSaveData() {
-
-        if (mDataArray != null) {
-
-            JSONArray jsonArray = new JSONArray();
-
-            for (ApexResultBaseModel model : mDataArray) {
-                JSONObject item = model.toJson();
-                jsonArray.put(item);
-            }
-
-            return jsonArray.toString();
-        }
-
-        return null;
-    }
-
-    private void prepareRestoreData(String jsonStr) {
-
-        if (jsonStr != null) {
-
-            try {
-
-                JSONArray jsonArray = new JSONArray(jsonStr);
-
-                ArrayList<ApexResultBaseModel> models = new ArrayList<>();
-                for (int i = 0; i < jsonArray.length(); i++) {
-                    JSONObject item = jsonArray.optJSONObject(i);
-                    if (item != null) {
-                        ApexResultBaseModel model = makeModel(item);
-                        if (model != null) {
-                            models.add(model);
-                        }
-                    }
-                }
-                mDataArray = models;
-
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-
-        }
-    }
-
-    // endregion
-
-    // region Getter
-
-    private ApexResultProtocol getDelegate() {
-        if (mWeakDelegate == null) {
-            return null;
-        }
-        return mWeakDelegate.get();
-    }
-
-    public int dataCount() {
-        if (mDataArray == null) {
-            return 0;
-        }
-        return mDataArray.size();
-    }
-
-    public ApexResultBaseModel modelAtIndex(int index) {
-        if (index >= dataCount()) {
-            return null;
-        }
-        return mDataArray.get(index);
-    }
-
-    public JSONArray rowActionParametersForIndex(int position) {
-        ApexResultBaseModel model = modelAtIndex(position);
-        if (model != null) {
-            return model.rowActionParameters;
-        }
-        return null;
-    }
-
-    public JSONArray getRowActions() {
-        return rowActions;
-    }
-
-    public JSONArray getActions() {
-        return actions;
-    }
-
-    public Bundle getParams() {
-        return mParams;
-    }
-
-    // endregion
-
-    // region DataSource
-
-    @Override
-    public int numberOfResultItem() {
-        return dataCount();
-    }
-
-    @Override
-    public ApexResultBaseModel resultModelForIndex(int index) {
-        return modelAtIndex(index);
-    }
-
-    // endregion
-
-    // region Private
-
-    private ApexResultBaseModel makeModel(JSONObject item) {
-        if (item != null) {
-            int type = item.optInt("type", -1);
-            if (type == ApexResultBaseModel.ApexResultType.APEX_RESULT_TYPE_SHIP.ordinal()) {
-
-                ApexResultShipModel model = new ApexResultShipModel();
-                model.setValuesForKeysWithJSON(item);
-                return model;
-            } else if (type == ApexResultBaseModel.ApexResultType.APEX_RESULT_TYPE_DOCUMENT.ordinal()) {
-
-                ApexResultDocumentModel model = new ApexResultDocumentModel();
-                model.setValuesForKeysWithJSON(item);
-                return model;
-            }
-        }
-        return null;
-    }
-
-    // endregion
-
-    // region Data
-
-    private void loadData(final ApexResultFetchDataType option) {
-
-        if (getDelegate() != null) {
-            getDelegate().onStartLoading();
-        }
-
-        if (mFields == null) {
-            mFields = "";
-        }
-
-
-        OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
-            @Override
-            public Object operationDoInBackground() {
-
-                Bundle params = (Bundle) mParams.clone();
-                params.putInt("offset", offset);
-                params.putInt("limit", detal);
-                params.putString("columns", mFields);
-                JSONObject json = Network.fetchResult(params);
-
-                return json;
-            }
-        }, new OperationQueue.OperationCompletionCallBack() {
-            @Override
-            public void operationCompletion(Object object) {
-
-                JSONObject json = (JSONObject)object;
-                int result = Network.RESULT_FALSE;
-                if (json != null) {
-                    result = json.optInt("result", Network.RESULT_FALSE);
-                }
-
-                if (getDelegate() != null) {
-                    getDelegate().onStopLoading();
-                }
-
-                if (result == Network.RESULT_TRUE) {
-
-                    ArrayList<ApexResultBaseModel> models = new ArrayList<>();
-                    if (option == ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_LOAD_MORE && mDataArray != null && mDataArray.size() > 0) {
-                        models.addAll(mDataArray);
-                    }
-
-                    int loadCount = 0;
-                    JSONArray items = json.optJSONArray("items");
-                    if (items != null) {
-                        loadCount = items.length();
-
-                        for (int i = 0; i < loadCount; i++) {
-                            JSONObject item = items.optJSONObject(i);
-                            if (item != null) {
-
-                                ApexResultBaseModel model = makeModel(item);
-                                if (model != null) {
-                                    models.add(model);
-                                }
-                            }
-                        }
-                    }
-
-                    offset = models.size();
-                    String title = json.optString("title");
-                    rowActions = json.optJSONArray("row_actions");
-                    actions = json.optJSONArray("actions");
-
-                    mDataArray = models;
-                    if (getDelegate() != null) {
-                        getDelegate().onSuccess(title);
-                        if (loadCount < detal) {
-                            getDelegate().onNoMoreData();
-                        }
-                    }
-
-                } else {
-
-                    String msg = "Sorry, something is wrong.";
-                    if (json != null) {
-                        json.optString("err_msg", "Sorry, something is wrong.");
-                    }
-
-                    if (getDelegate() != null) {
-                        getDelegate().onFailed(msg);
-                    }
-                }
-
-            }
-        },null);
-
-    }
-
-    public void loadData() {
-
-        if (dirty) {
-            dirty = false;
-            String module_name = mParams.getString("module_name");
-            String fields = Network.getDisplayFieldsForFunction(module_name);
-            mFields = fields;
-        }
-
-        offset = 0;
-        loadData(ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_INITIAL);
-    }
-
-    public void refreshData() {
-
-        offset = 0;
-        loadData(ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_REFRESH);
-    }
-
-    public void loadMoreData() {
-        loadData(ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_LOAD_MORE);
-    }
-
-    // endregion
-
-    // region Save Search Parameter
-
-    public void saveSearchParametersWithName(final String  intentStr, final String name) {
-
-        if (getDelegate() != null) {
-            getDelegate().onStartLoading();
-        }
-
-        JSONObject json = RAUtil.Bundle2Json(mParams);
-        if (mFields != null) {
-            try {
-                json.put("columns", mFields);
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-        }
-
-
-        final String paramStr = json.toString();
-        final String module_name = mParams.getString("module_name");
-
-        OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
-            @Override
-            public Object operationDoInBackground() {
-                return Network.saveSearchParametersForModuleWithName(intentStr, paramStr, module_name, name);
-            }
-        }, new OperationQueue.OperationCompletionCallBack() {
-            @Override
-            public void operationCompletion(Object object) {
-
-                if (getDelegate() != null) {
-
-                    getDelegate().onStopLoading();
-
-                    JSONObject json = (JSONObject)object;
-
-                    int result = Network.RESULT_FALSE;
-                    String msg = "Sorry, something is wrong.";
-                    if (json != null) {
-
-                        result = json.optInt("result", Network.RESULT_FALSE);
-                        if (result != Network.RESULT_TRUE) {
-                            String err_msg = json.optString("err_msg");
-                            if (!TextUtils.isEmpty(err_msg)) {
-                                msg = err_msg;
-                            }
-                        }
-                    } // json
-
-                    if (result != Network.RESULT_TRUE) {
-                        getDelegate().onFailed(msg);
-                    }
-
-                } // != null
-
-
-
-            }
-        }, null);
-    }
-
-    // endregion
-
-    // region Download
-
-    public void downloadFile(final String url, final Bundle params) {
-
-        if (getDelegate() != null) {
-            getDelegate().onStartLoading();
-        }
-
-        OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
-            @Override
-            public Object operationDoInBackground() {
-
-                String cacheDir = ApexTrackingApplication.getInstance().getExternalCacheDir().getAbsolutePath();
-
-                final File downloadFile = Network.downloadFile(params, url, cacheDir);
-
-                return downloadFile;
-            }
-        }, new OperationQueue.OperationCompletionCallBack() {
-            @Override
-            public void operationCompletion(Object object) {
-
-                if (getDelegate() != null) {
-
-                    getDelegate().onStopLoading();
-
-                    File file = (File)object;
-                    if (file == null) {
-
-                        getDelegate().onFailed("Sorry, something is wrong.");
-
-                    } else {
-                        getDelegate().onDownloadFile(file.getAbsolutePath(), params);
-                    }
-
-                }
-
-            }
-        }, null);
-
-    }
-
-    // endregion
-}

+ 0 - 53
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/cell/ApexResultAdditionView.java

@@ -1,53 +0,0 @@
-package com.usai.apex.apexResult.cell;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.usai.apex.R;
-
-public class ApexResultAdditionView extends RelativeLayout {
-
-    public static ApexResultAdditionView makeAdditionView(Context context) {
-
-        ApexResultAdditionView additionView = (ApexResultAdditionView) LayoutInflater.from(context).inflate(R.layout.apex_result_addition_view, null);
-        additionView.init();
-        return additionView;
-    }
-
-    private TextView titleTv, valueTv;
-
-    public ApexResultAdditionView(Context context) {
-        super(context);
-    }
-
-    public ApexResultAdditionView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public ApexResultAdditionView(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-    }
-
-    private void init() {
-        titleTv = findViewById(R.id.apex_result_addition_title_tv);
-        valueTv = findViewById(R.id.apex_result_addition_value_tv);
-        prepareReuse();
-    }
-
-    private void prepareReuse() {
-        titleTv.setText("");
-        valueTv.setText("");
-    }
-
-    public void setTitle(String title) {
-        titleTv.setText(title);
-    }
-
-    public void setValue(String value) {
-        valueTv.setText(value);
-    }
-
-}

+ 0 - 70
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/cell/ApexResultDocumentCell.java

@@ -1,70 +0,0 @@
-package com.usai.apex.apexResult.cell;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.usai.apex.R;
-
-
-public class ApexResultDocumentCell extends RelativeLayout {
-
-    public static ApexResultDocumentCell makeDocumentCell(Context context) {
-
-        ApexResultDocumentCell cell = (ApexResultDocumentCell) LayoutInflater.from(context).inflate(R.layout.apex_result_document_cell, null);
-        cell.init();
-
-        return cell;
-    }
-
-
-    private ImageView fileIconView;
-    private TextView fileNameTv, fileTypeTv, fileDescTv;
-
-    private void init() {
-
-        fileIconView = findViewById(R.id.apex_result_document_icon_view);
-        fileNameTv = findViewById(R.id.apex_result_document_file_name_tv);
-        fileTypeTv = findViewById(R.id.apex_result_document_file_type_tv);
-        fileDescTv = findViewById(R.id.apex_result_document_file_desc_tv);
-
-        prepareReuse();
-    }
-
-    public ApexResultDocumentCell(Context context) {
-        super(context);
-    }
-
-    public ApexResultDocumentCell(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public ApexResultDocumentCell(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-    }
-
-    public void prepareReuse() {
-        fileNameTv.setText("");
-        fileTypeTv.setText("");
-        fileDescTv.setText("");
-    }
-
-    public ApexResultDocumentCell setFileName(String name) {
-        fileNameTv.setText(name);
-        return this;
-    }
-
-    public ApexResultDocumentCell setFileType(String type) {
-        fileTypeTv.setText(type);
-        return this;
-    }
-
-    public ApexResultDocumentCell setFileDescription(String description) {
-        fileDescTv.setText(description);
-        return this;
-    }
-
-}

+ 0 - 165
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/cell/ApexResultShipCell.java

@@ -1,165 +0,0 @@
-package com.usai.apex.apexResult.cell;
-
-import android.content.Context;
-import android.support.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.usai.apex.ApexTrackingApplication;
-import com.usai.apex.R;
-import com.usai.apex.mainframe.TrackingImageView;
-
-import java.util.ArrayList;
-
-public class ApexResultShipCell extends LinearLayout {
-
-    // region initial
-    public static ApexResultShipCell makeShipCell(Context context) {
-        ApexResultShipCell cell = (ApexResultShipCell) LayoutInflater.from(context).inflate(R.layout.apex_result_ship_cell, null);
-        cell.init();
-
-        return cell;
-    }
-
-    private TextView titleTv, dateTv, descTv, detailTv, portTv;
-    private TrackingImageView statusIv;
-    private View stageView;
-    private LinearLayout additionLayout;
-
-    private ArrayList<ApexResultAdditionView> additionArray = new ArrayList<>();
-    private int additionCount = 0;
-
-    public ApexResultShipCell(Context context) {
-        super(context);
-    }
-
-    public ApexResultShipCell(Context context, @Nullable AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public ApexResultShipCell(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-    }
-
-    private void init() {
-
-        titleTv = findViewById(R.id.tv_title);
-        dateTv = findViewById(R.id.tv_time);
-        descTv = findViewById(R.id.tv_description);
-        detailTv = findViewById(R.id.tv_detail);
-        portTv = findViewById(R.id.tv_port);
-        statusIv = findViewById(R.id.iv_status);
-        stageView = findViewById(R.id.v_transport_stage);
-        additionLayout = findViewById(R.id.apex_result_ship_addition_view);
-
-        prepareReuse();
-    }
-
-    public void prepareReuse() {
-
-        titleTv.setText("");
-        dateTv.setText("");
-        descTv.setText("");
-        detailTv.setText("");
-        portTv.setText("");
-        statusIv.setImageDrawable(null);
-        setTransportStage(0);
-        clearAdditionView();
-    }
-
-    public void setTransportStage(int stage) {
-        switch(stage)
-        {
-            case 0:
-                stageView.setBackground(ApexTrackingApplication.getInstance().getResources().getDrawable(R.drawable.list_corner_transport_stage_bg_0));
-                break;
-            case 1:
-                stageView.setBackground(ApexTrackingApplication.getInstance().getResources().getDrawable(R.drawable.list_corner_transport_stage_bg_1));
-                break;
-            case 2:
-                stageView.setBackground(ApexTrackingApplication.getInstance().getResources().getDrawable(R.drawable.list_corner_transport_stage_bg_2));
-                break;
-            case 3:
-                stageView.setBackground(ApexTrackingApplication.getInstance().getResources().getDrawable(R.drawable.list_corner_transport_stage_bg_3));
-                break;
-            default:
-                stageView.setBackground(ApexTrackingApplication.getInstance().getResources().getDrawable(R.drawable.list_corner_transport_stage_bg_0));
-                break;
-
-        }
-    }
-
-    // endregion
-
-    // region set
-
-    public ApexResultShipCell setTitle(String title) {
-        titleTv.setText(title);
-        return this;
-    }
-
-    public ApexResultShipCell setDetail(String detail) {
-        detailTv.setText(detail);
-        return this;
-    }
-
-    public ApexResultShipCell setIcon(String icon) {
-        if (icon != null) {
-            int resourceId = getContext().getResources().getIdentifier(icon, "drawable", getContext().getPackageName());
-            statusIv.setImageResource(resourceId);
-        } else {
-            statusIv.setImageDrawable(null);
-        }
-        return this;
-    }
-
-    public ApexResultShipCell setPort(String port) {
-        portTv.setText(port);
-        return this;
-    }
-
-    public ApexResultShipCell setTime(String time) {
-        dateTv.setText(time);
-        return this;
-    }
-
-    public ApexResultShipCell setDescription(String description) {
-        descTv.setText(description);
-        return this;
-    }
-
-    public void addAddition(String name, String value) {
-
-        ApexResultAdditionView additionView;
-        if (additionCount >= additionArray.size()) {
-
-            additionView = ApexResultAdditionView.makeAdditionView(getContext());
-            additionArray.add(additionView);
-
-        } else {
-            additionView = additionArray.get(additionCount);
-        }
-        additionCount++;
-
-        additionView.setTitle(name);
-        additionView.setValue(value);
-
-        LinearLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
-        additionLayout.addView(additionView, layoutParams);
-    }
-
-    // endregion
-
-    // region Private
-
-    private void clearAdditionView() {
-        additionLayout.removeAllViews();
-        additionCount = 0;
-    }
-
-    // endregion
-}

+ 0 - 50
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/model/ApexResultBaseModel.java

@@ -1,50 +0,0 @@
-package com.usai.apex.apexResult.model;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import com.usai.apex.base.BaseObject;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class ApexResultBaseModel extends BaseObject {
-
-    protected ApexResultBaseModel(Parcel in) {
-        type = in.readInt();
-        String jsonStr = in.readString();
-        try {
-            rowActionParameters = new JSONArray(jsonStr);
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public ApexResultBaseModel() {
-
-    }
-
-    public JSONObject toJson() {
-        JSONObject json = new JSONObject();
-        try {
-            json.put("type", type);
-            if (rowActionParameters != null) {
-                json.put("rowActionParameters", rowActionParameters);
-            }
-
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-        return json;
-    }
-
-    public static enum ApexResultType {
-        APEX_RESULT_TYPE_SHIP,
-        APEX_RESULT_TYPE_DOCUMENT
-    }
-
-    public int type;
-    public JSONArray rowActionParameters;
-}

+ 0 - 36
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/model/ApexResultDocumentModel.java

@@ -1,36 +0,0 @@
-package com.usai.apex.apexResult.model;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class ApexResultDocumentModel extends ApexResultBaseModel {
-
-    public String fileName;
-    public String fileType;
-    public String fileDesc;
-
-    public ApexResultDocumentModel() {
-
-    }
-
-    @Override
-    public JSONObject toJson() {
-        JSONObject json = super.toJson();
-
-        try {
-            if (fileName != null) {
-                json.put("fileName", fileName);
-            }
-            if (fileType != null) {
-                json.put("fileType", fileType);
-            }
-            if (fileDesc != null) {
-                json.put("fileDesc", fileDesc);
-            }
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-        return json;
-    }
-}

+ 0 - 116
ApexDrivers/apexmobile/src/main/java/com/usai/apex/apexResult/model/ApexResultShipModel.java

@@ -1,116 +0,0 @@
-package com.usai.apex.apexResult.model;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import com.usai.apex.base.BaseObject;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-
-public class ApexResultShipModel extends ApexResultBaseModel {
-
-    // region Addition
-    public static class ApexResultAddition extends BaseObject{
-        public String name;
-        public String value;
-
-        private ApexResultAddition() {
-
-        }
-    }
-    // endregion
-
-    // region Model
-    public String title;
-    public String icon;
-    public String desc;
-    public String detail;
-    public String date;
-    public String port;
-    public int transport_stage;
-
-    public Object addition; // 使用Object对象,便于baseObject赋值
-    private ArrayList<ApexResultAddition> additions;
-
-    public ApexResultShipModel() {
-
-    }
-
-    public void setAddition(Object obj) {
-        this.addition = obj;
-        if (obj != null && obj instanceof JSONArray) {
-
-            JSONArray addition = (JSONArray) obj;
-            if (addition != null && addition.length() > 0) {
-
-                this.additions = new ArrayList<>();
-                for (int i = 0; i < addition.length(); i++) {
-                    JSONObject additionItem = addition.optJSONObject(i);
-                    if (additionItem != null) {
-
-                        ApexResultAddition additionModel = new ApexResultAddition();
-                        additionModel.setValuesForKeysWithJSON(additionItem);
-                        this.additions.add(additionModel);
-                    }
-                }
-
-            } else {
-                this.additions = null;
-            }
-
-        } else {
-            this.additions = null;
-        }
-
-
-
-    }
-
-    public ArrayList<ApexResultAddition> getAddition() {
-        return additions;
-    }
-    // endregion
-
-
-    @Override
-    public JSONObject toJson() {
-        JSONObject json = super.toJson();
-
-        try {
-
-            if (title != null) {
-                json.put("title", title);
-            }
-            if (icon != null) {
-                json.put("icon", icon);
-            }
-            if (desc != null) {
-                json.put("desc", desc);
-            }
-            if (detail != null) {
-                json.put("detail", detail);
-            }
-            if (date != null) {
-                json.put("date", date);
-            }
-            if (port != null) {
-                json.put("port", port);
-            }
-
-            json.put("transport_stage", transport_stage);
-
-            if (addition != null) {
-                json.put("addition", addition);
-            }
-
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-        return json;
-    }
-}