|
@@ -1,581 +0,0 @@
|
|
|
-package com.usai.ratradefiling.home;
|
|
|
|
|
-
|
|
|
|
|
-import android.os.Bundle;
|
|
|
|
|
-import android.text.TextUtils;
|
|
|
|
|
-//
|
|
|
|
|
-//import com.usai.apex.ApexTrackingApplication;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ApexResultAirAwbInfoModel;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ApexResultAirBookingModel;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ApexResultBLInfoModel;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ResultBaseModel;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ApexResultBookingModel;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ApexResultContainerModel;
|
|
|
|
|
-//import com.usai.apex.apexresult.model.ApexResultDocumentModel;
|
|
|
|
|
-import com.usai.ratradefiling.base.ResultBaseModel;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.error.HomeDashACEM1ModelE;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.error.HomeDashACIModelE;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.error.HomeDashISFModelE;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.error.HomeDasheManifestModelE;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.pending.HomeDashACEM1ModelP;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.pending.HomeDashACIModelP;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.pending.HomeDashISFModelP;
|
|
|
|
|
-import com.usai.ratradefiling.home.dashmodel.pending.HomeDasheManifestModelP;
|
|
|
|
|
-import com.usai.redant.rautils.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 HomeDashPresenter implements HomeDashAdapter.HomeDashDataSource {
|
|
|
|
|
-
|
|
|
|
|
- // 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<ResultBaseModel> mDataArray;
|
|
|
|
|
- private JSONArray rowActions;
|
|
|
|
|
- private JSONArray actions;
|
|
|
|
|
- public boolean dirty = true;
|
|
|
|
|
-// private ArrayList<ApexResultMenuItem> mMenuItems;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- public HomeDashPresenter(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 (ResultBaseModel 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<ResultBaseModel> models = new ArrayList<>();
|
|
|
|
|
- for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
|
|
- JSONObject item = jsonArray.optJSONObject(i);
|
|
|
|
|
- if (item != null) {
|
|
|
|
|
- ResultBaseModel 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 ResultBaseModel modelAtIndex(int index) {
|
|
|
|
|
- if (index >= dataCount()) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- return mDataArray.get(index);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public JSONArray rowActionParametersForIndex(int position) {
|
|
|
|
|
- ResultBaseModel 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;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-// public ArrayList<ApexResultMenuItem> getMenuItems() {
|
|
|
|
|
-// return mMenuItems;
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region DataSource
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public int numberOfResultItem() {
|
|
|
|
|
- return dataCount();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public ResultBaseModel resultModelForIndex(int index) {
|
|
|
|
|
- return modelAtIndex(index);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // endregion
|
|
|
|
|
-
|
|
|
|
|
- // region Private
|
|
|
|
|
-
|
|
|
|
|
- private ResultBaseModel makeModel(JSONObject item) {
|
|
|
|
|
- if (item != null) {
|
|
|
|
|
- int type = item.optInt("type", -1);
|
|
|
|
|
-
|
|
|
|
|
- if (type < ResultBaseModel.HomeDashResultType.values().length) {
|
|
|
|
|
- ResultBaseModel.HomeDashResultType resultType = ResultBaseModel.HomeDashResultType.values()[type];
|
|
|
|
|
- switch (resultType) {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- case DashResultTypeEmpty:
|
|
|
|
|
- {
|
|
|
|
|
- ResultBaseModel emptymodel= new ResultBaseModel();
|
|
|
|
|
- emptymodel.type=type;
|
|
|
|
|
- return emptymodel;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeACIPending: {
|
|
|
|
|
- HomeDashACIModelP model = new HomeDashACIModelP();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeeManifestPending: {
|
|
|
|
|
- HomeDasheManifestModelP model = new HomeDasheManifestModelP();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeACEM1Pending: {
|
|
|
|
|
- HomeDashACEM1ModelP model = new HomeDashACEM1ModelP();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeISFPending: {
|
|
|
|
|
- HomeDashISFModelP model = new HomeDashISFModelP();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeACIError: {
|
|
|
|
|
- HomeDashACIModelE model = new HomeDashACIModelE();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeeManifestError: {
|
|
|
|
|
- HomeDasheManifestModelE model = new HomeDasheManifestModelE();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeACEM1Error: {
|
|
|
|
|
- HomeDashACEM1ModelE model = new HomeDashACEM1ModelE();
|
|
|
|
|
- model.setValuesForKeysWithJSON(item);
|
|
|
|
|
- return model;
|
|
|
|
|
- }
|
|
|
|
|
- case DashResultTypeISFError: {
|
|
|
|
|
- HomeDashISFModelE model = new HomeDashISFModelE();
|
|
|
|
|
- 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<ResultBaseModel> 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) {
|
|
|
|
|
-//
|
|
|
|
|
-// ResultBaseModel 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");
|
|
|
|
|
-//
|
|
|
|
|
-// JSONArray menu = json.optJSONArray("menu");
|
|
|
|
|
-// if (menu != null) {
|
|
|
|
|
-//
|
|
|
|
|
-// ArrayList<ApexResultMenuItem> menuItems = new ArrayList<>();
|
|
|
|
|
-// int len = menu.length();
|
|
|
|
|
-// for (int i = 0; i < len; i++) {
|
|
|
|
|
-//
|
|
|
|
|
-// JSONObject item = menu.optJSONObject(i);
|
|
|
|
|
-// if (item != null) {
|
|
|
|
|
-//
|
|
|
|
|
-// ApexResultMenuItem menuItem = new ApexResultMenuItem();
|
|
|
|
|
-// menuItem.setValuesForKeysWithJSON(item);
|
|
|
|
|
-// menuItems.add(menuItem);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// mMenuItems = menuItems;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// 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
|
|
|
|
|
-}
|
|
|