Commit 78c5c903 by NGUYEN HOANG SON

implement auto sync for push message

parent 3ec8094a
...@@ -55,14 +55,18 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity { ...@@ -55,14 +55,18 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity {
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(), ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_no_operation, R.string.msg_routineTask_report_disable_no_operation,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else if (operationDto.needSyncFlg) { } else {
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null && operationListActivity.needAutoSync()) {
operationListActivity.autoSyncOperationId(operationId);
return;
}
if (operationDto.needSyncFlg) {
// リソースパターンの適用 // リソースパターンの適用
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(), ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_not_updated, R.string.msg_routineTask_report_disable_not_updated,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else { } else {
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null) { if (operationListActivity != null) {
operationListActivity.startTaskDirectionOrReportView(operationDto); operationListActivity.startTaskDirectionOrReportView(operationDto);
} else { } else {
...@@ -73,6 +77,7 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity { ...@@ -73,6 +77,7 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity {
} }
} }
} }
}
dialog.dismiss(); dialog.dismiss();
} }
}); });
......
...@@ -498,7 +498,6 @@ public class OperationListActivity extends OperationActivity { ...@@ -498,7 +498,6 @@ public class OperationListActivity extends OperationActivity {
} }
} }
} }
needSyncOperationList.addAll(mOperationDao.getAllOperation());
if (needSyncOperationList.size() > 0) { if (needSyncOperationList.size() > 0) {
categoryBatchSync(needSyncOperationList); categoryBatchSync(needSyncOperationList);
} else { } else {
...@@ -1444,8 +1443,7 @@ public class OperationListActivity extends OperationActivity { ...@@ -1444,8 +1443,7 @@ public class OperationListActivity extends OperationActivity {
return; return;
} }
if (needAutoSync()) { if (needAutoSync()) {
autoSyncOpenOperationId = operationId; autoSyncOperationId(operationId);
autoSyncOperation();
return; return;
} }
if (operationDto.needSyncFlg) { if (operationDto.needSyncFlg) {
...@@ -2450,6 +2448,9 @@ public class OperationListActivity extends OperationActivity { ...@@ -2450,6 +2448,9 @@ public class OperationListActivity extends OperationActivity {
return (isAutoSync() && ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()); return (isAutoSync() && ABVEnvironment.getInstance().networkAdapter.isNetworkConnected());
} }
/**
* Run refresh data and batch sync if need
*/
public void autoSyncOperation() { public void autoSyncOperation() {
if (isAutoSyncing) { if (isAutoSyncing) {
return; return;
...@@ -2469,6 +2470,19 @@ public class OperationListActivity extends OperationActivity { ...@@ -2469,6 +2470,19 @@ public class OperationListActivity extends OperationActivity {
}); });
} }
/**
* Auto sync and open operation if success
* @param operationId
*/
public void autoSyncOperationId(Long operationId) {
autoSyncOpenOperationId = operationId;
autoSyncOperation();
}
/**
* Auto sync done
* @param isSuccess
*/
public void autoSyncOperationDone(boolean isSuccess) { public void autoSyncOperationDone(boolean isSuccess) {
isAutoSyncing = false; isAutoSyncing = false;
closeProgressPopup(); closeProgressPopup();
......
...@@ -265,8 +265,7 @@ public abstract class OperationListHelper { ...@@ -265,8 +265,7 @@ public abstract class OperationListHelper {
public void onClickReport(OperationDto operationDto) { public void onClickReport(OperationDto operationDto) {
if (mAppActivity.needAutoSync()) { if (mAppActivity.needAutoSync()) {
mAppActivity.autoSyncOpenOperationId = operationDto.operationId; mAppActivity.autoSyncOperationId(operationDto.operationId);
mAppActivity.autoSyncOperation();
return; return;
} }
if (operationDto.contentId != null && operationDto.contentId != 0) { if (operationDto.contentId != null && operationDto.contentId != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment