|
@@ -9,6 +9,7 @@ import com.usai.apex.apexResult.model.ApexResultDocumentModel;
|
|
|
import com.usai.apex.apexResult.model.ApexResultShipModel;
|
|
import com.usai.apex.apexResult.model.ApexResultShipModel;
|
|
|
import com.usai.apex.operationQueue.OperationQueue;
|
|
import com.usai.apex.operationQueue.OperationQueue;
|
|
|
import com.usai.util.Network;
|
|
import com.usai.util.Network;
|
|
|
|
|
+import com.usai.util.RAUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
import org.json.JSONArray;
|
|
@@ -48,11 +49,13 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
|
|
|
|
|
private WeakReference<ApexResultProtocol> mWeakDelegate;
|
|
private WeakReference<ApexResultProtocol> mWeakDelegate;
|
|
|
private Bundle mParams;
|
|
private Bundle mParams;
|
|
|
|
|
+ private String mFields;
|
|
|
private int offset = 0;
|
|
private int offset = 0;
|
|
|
private static final int detal = 20;
|
|
private static final int detal = 20;
|
|
|
private ArrayList<ApexResultBaseModel> mDataArray;
|
|
private ArrayList<ApexResultBaseModel> mDataArray;
|
|
|
private JSONArray rowActions;
|
|
private JSONArray rowActions;
|
|
|
private JSONArray actions;
|
|
private JSONArray actions;
|
|
|
|
|
+ public boolean dirty = true;
|
|
|
|
|
|
|
|
public ApexResultPresenter(ApexResultProtocol delegate, Bundle params) {
|
|
public ApexResultPresenter(ApexResultProtocol delegate, Bundle params) {
|
|
|
if (delegate == null) {
|
|
if (delegate == null) {
|
|
@@ -65,6 +68,13 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
} else {
|
|
} else {
|
|
|
mParams = params;
|
|
mParams = params;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (mParams.containsKey("columns")) {
|
|
|
|
|
+
|
|
|
|
|
+ dirty = false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dirty = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// endregion
|
|
// endregion
|
|
|
|
|
|
|
@@ -74,6 +84,8 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
private static final String Offset_Key = "Offset_Key";
|
|
private static final String Offset_Key = "Offset_Key";
|
|
|
private static final String Row_Actions_key = "Row_Actions_Key";
|
|
private static final String Row_Actions_key = "Row_Actions_Key";
|
|
|
private static final String Actions_Key = "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) {
|
|
public void onSaveInstanceState(Bundle outState) {
|
|
|
if (outState != null) {
|
|
if (outState != null) {
|
|
@@ -92,6 +104,11 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
if (actions != null) {
|
|
if (actions != null) {
|
|
|
outState.putString(Actions_Key, actions.toString());
|
|
outState.putString(Actions_Key, actions.toString());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ outState.putBoolean(Dirty_Key, dirty);
|
|
|
|
|
+ if (mFields != null) {
|
|
|
|
|
+ outState.putString(Display_Fields_Key, mFields);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -120,6 +137,9 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ mFields = savedInstanceState.getString(Display_Fields_Key);
|
|
|
|
|
+ dirty = savedInstanceState.getBoolean(Dirty_Key);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -258,6 +278,11 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
getDelegate().onStartLoading();
|
|
getDelegate().onStartLoading();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (mFields == null) {
|
|
|
|
|
+ mFields = "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
|
|
OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
|
|
|
@Override
|
|
@Override
|
|
|
public Object operationDoInBackground() {
|
|
public Object operationDoInBackground() {
|
|
@@ -265,6 +290,7 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
Bundle params = (Bundle) mParams.clone();
|
|
Bundle params = (Bundle) mParams.clone();
|
|
|
params.putInt("offset", offset);
|
|
params.putInt("offset", offset);
|
|
|
params.putInt("limit", detal);
|
|
params.putInt("limit", detal);
|
|
|
|
|
+ params.putString("columns", mFields);
|
|
|
JSONObject json = Network.fetchResult(params);
|
|
JSONObject json = Network.fetchResult(params);
|
|
|
|
|
|
|
|
return json;
|
|
return json;
|
|
@@ -338,10 +364,21 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void loadData() {
|
|
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);
|
|
loadData(ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_INITIAL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void refreshData() {
|
|
public void refreshData() {
|
|
|
|
|
+
|
|
|
|
|
+ offset = 0;
|
|
|
loadData(ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_REFRESH);
|
|
loadData(ApexResultFetchDataType.APEX_RESULT_FETCH_DATA_TYPE_REFRESH);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -353,19 +390,29 @@ public class ApexResultPresenter implements ApexResultAdapter.ApexResultAdapterD
|
|
|
|
|
|
|
|
// region Save Search Parameter
|
|
// region Save Search Parameter
|
|
|
|
|
|
|
|
- public void saveSearchParametersWithName(final String name) {
|
|
|
|
|
|
|
+ public void saveSearchParametersWithName(final String intentStr, final String name) {
|
|
|
|
|
|
|
|
if (getDelegate() != null) {
|
|
if (getDelegate() != null) {
|
|
|
getDelegate().onStartLoading();
|
|
getDelegate().onStartLoading();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- final String paramStr = mParams.toString();
|
|
|
|
|
|
|
+ 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");
|
|
final String module_name = mParams.getString("module_name");
|
|
|
|
|
|
|
|
OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
|
|
OperationQueue.sharedQueue().addOperationTask(new OperationQueue.OperationBackgroundCallBack() {
|
|
|
@Override
|
|
@Override
|
|
|
public Object operationDoInBackground() {
|
|
public Object operationDoInBackground() {
|
|
|
- return Network.saveSearchParametersForModuleWithName(paramStr, module_name, name);
|
|
|
|
|
|
|
+ return Network.saveSearchParametersForModuleWithName(intentStr, paramStr, module_name, name);
|
|
|
}
|
|
}
|
|
|
}, new OperationQueue.OperationCompletionCallBack() {
|
|
}, new OperationQueue.OperationCompletionCallBack() {
|
|
|
@Override
|
|
@Override
|