Commit 82568d82 by Kim Jinsung

Merge branch 'contract/sato/1.0.500_son' into 'contract/sato/1.0.500'

implement operation auto sync

See merge request !320
parents e46de6fd 0c39bacd
......@@ -606,4 +606,8 @@ public class OperationDao extends AbstractDao {
Logger.e(TAG, e);
}
}
public List<OperationDto> getNeedSyncAllOperation() {
return rawQueryGetDtoList("select tp.*, rpc.content_id from t_operation AS tp left outer join r_operation_content AS rpc on tp.operation_id = rpc.operation_id where tp.need_sync_flg = 1", null, OperationDto.class);
}
}
......@@ -1468,4 +1468,9 @@
<string name="msg_qrcode_not_operation_format">作業QRコードではありません。</string>
<string name="msg_qrcode_operation_not_found">作業が存在しません。</string>
<string name="msg_qrcode_disconnect_content_download">インターネットに接続されてないので同期できません。インターネットに接続してください。</string>
<string name="auto_sync">自動同期</string>
<string name="auto_sync_setting_title">自動同期する</string>
<string name="auto_sync_setting_subtitle">作業一覧で作業の自動同期を可能にします。</string>
</resources>
......@@ -1482,4 +1482,8 @@
<string name="msg_qrcode_operation_not_found">Working does not exist.</string>
<string name="msg_qrcode_disconnect_content_download">Synchronization process was failed because there are not connected to the internet. Please connect the internet.</string>
<string name="auto_sync">Auto Sync</string>
<string name="auto_sync_setting_title">Automatically sync</string>
<string name="auto_sync_setting_subtitle">Enables automatic synchronization of operations in the operation list.</string>
</resources>
\ No newline at end of file
......@@ -68,4 +68,11 @@
android:title="@string/spp_machine" >
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/auto_sync" android:key="auto_sync">
<CheckBoxPreference
android:defaultValue="false"
android:key="operationAutoSync"
android:title="@string/auto_sync_setting_title"
android:summary="@string/auto_sync_setting_subtitle"/>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
......@@ -55,21 +55,26 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity {
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_no_operation,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else if (operationDto.needSyncFlg) {
// リソースパターンの適用
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_not_updated,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else {
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null) {
operationListActivity.startTaskDirectionOrReportView(operationDto);
} else {
if (operationListActivity != null && operationListActivity.needAutoSync()) {
operationListActivity.autoSyncOperationId(operationId);
return;
}
if (operationDto.needSyncFlg) {
// リソースパターンの適用
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_not_list,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
R.string.msg_routineTask_report_disable_not_updated,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else {
if (operationListActivity != null) {
operationListActivity.startTaskDirectionOrReportView(operationDto);
} else {
// リソースパターンの適用
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_not_list,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
}
}
}
}
......
......@@ -76,6 +76,7 @@ public interface AppDefType {
String OPERATION_GROUP_MASERT_MODE = "operation_group_master"; // 通常・作業種別モード(画面)
String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID
String OPERATION_SORT_CONDITION = "operation_sort_condition"; // 作業のソート
String OPERATION_AUTO_SYNC = "operationAutoSync";
}
/**
......
......@@ -82,6 +82,9 @@ public class ABVBatchSyncView extends ProgressDialog {
// Activity破棄フラグがtrue、またはスタックが存在しなければ、全て完了と見做す
closeProgressDialog();
Logger.d(TAG, "---batchSync is end");
if (mOperationListActivity != null && mOperationListActivity.mAutoSyncingFlg) {
mOperationListActivity.autoSyncOperationDone(true);
}
return;
}
// ベース資料のダウンロードチェック
......@@ -97,6 +100,9 @@ public class ABVBatchSyncView extends ProgressDialog {
// error
showBatchSyncErrorAlert(peekOperationDto, mOperationListActivity.getString(R.string.msg_batch_sync_content_download_fail));
}
if (mOperationListActivity != null && mOperationListActivity.mAutoSyncingFlg) {
mOperationListActivity.autoSyncOperationDone(false);
}
return;
}
// 同期処理
......
......@@ -206,6 +206,9 @@ public class OperationListActivity extends OperationActivity {
// 作業種別のサービスオプション値を保持用フラグ
private boolean mOperationGroupMasterServiceOperationFlg;
public boolean mAutoSyncingFlg;
public Long mAutoSyncOpenOperationId = null;
public Long mQrCodeOperationId = null;
// ビューの作成
private class ReloadHandler implements Runnable {
......@@ -478,6 +481,32 @@ public class OperationListActivity extends OperationActivity {
// ビューを作り直す
setOperationListView();
}
if (isAutoSync()) {
if (mAutoSyncingFlg) {
if (result) {
// content update success
List<OperationDto> needSyncOperationList = new ArrayList<>();
if (mAutoSyncOpenOperationId != null) {
OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId);
if (operationDto.needSyncFlg) {
needSyncOperationList.add(operationDto);
}
} else {
needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation());
}
if (needSyncOperationList.size() > 0) {
categoryBatchSync(needSyncOperationList);
} else {
// donot need sync
autoSyncOperationDone(true);
}
} else {
// content update fail
autoSyncOperationDone(false);
}
}
return;
}
//「I/O 帳票使用」がYESのみ、新着更新処理完了後、一括同期処理を開始する。
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
if (mAutoBatchSyncFlg) {
......@@ -509,68 +538,78 @@ public class OperationListActivity extends OperationActivity {
refreshOperationList();
// 作業指示・報告からプロジェクト一覧へ戻った時の同期処理
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
if (operationId != -1) {
final OperationDto operationDto = mOperationLogic.getOperation(operationId);
// リソースパターンの適用
showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
R.string.synchronizing,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() {
if (isAutoSync()) {
// delay for showProgressView
handler.postDelayed(new Runnable() {
@Override
public void run() {
Logger.d(TAG, "onResume Sync operationId : " + operationId);
if (operationDto != null && operationDto.needSyncFlg) {
// 同期処理後、直列処理で新着更新を行う。
singleSyncOperation(operationId, operationDto.reportType);
//「I/O 帳票使用」がYESのみ、カテゴリ一括動機実施
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
//同期中のインジケーター表示中には新着更新中のインジケーター表示できないので、チェックする。
while (progressDialogHorizontalShowing()) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
Logger.e(TAG, "sleep error = " + ie.getLocalizedMessage());
}
}
//新着更新後、一括同期処理を行うため、インジケーター表示
handler.post(new Runnable() {
@Override
public void run() {
showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(),
R.string.updating,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
autoSyncOperation();
}
}, 100);
} else {
final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
if (operationId != -1) {
final OperationDto operationDto = mOperationLogic.getOperation(operationId);
// リソースパターンの適用
showProgressView(PatternStringUtil.patternToString(getApplicationContext(),
R.string.synchronizing,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
Logger.d(TAG, "onResume Sync operationId : " + operationId);
if (operationDto != null && operationDto.needSyncFlg) {
// 同期処理後、直列処理で新着更新を行う。
singleSyncOperation(operationId, operationDto.reportType);
//「I/O 帳票使用」がYESのみ、カテゴリ一括動機実施
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
//同期中のインジケーター表示中には新着更新中のインジケーター表示できないので、チェックする。
while (progressDialogHorizontalShowing()) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
Logger.e(TAG, "sleep error = " + ie.getLocalizedMessage());
}
}
});
mAutoBatchSyncFlg = true;
//表示作業数が10個以上の場合、2秒待機してから新着更新を行う。10個未満は1秒待機
List<OperationDto> operationList = mListHelper.getOperationList();
int delaySeconds = 1000;
if (operationList.size() >= DELAY_2SECONDS_OPERATION_MAX_COUNT) {
delaySeconds = 2000;
}
handler.postDelayed(new Runnable() {
@Override
public void run() {
dataRefresh(true);
//新着更新後、一括同期処理を行うため、インジケーター表示
handler.post(new Runnable() {
@Override
public void run() {
showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(),
R.string.updating,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
}
});
mAutoBatchSyncFlg = true;
//表示作業数が10個以上の場合、2秒待機してから新着更新を行う。10個未満は1秒待機
List<OperationDto> operationList = mListHelper.getOperationList();
int delaySeconds = 1000;
if (operationList.size() >= DELAY_2SECONDS_OPERATION_MAX_COUNT) {
delaySeconds = 2000;
}
}, delaySeconds);
handler.postDelayed(new Runnable() {
@Override
public void run() {
dataRefresh(true);
}
}, delaySeconds);
}
} else {
closeProgressPopup();
dataRefresh(true);
}
} else {
closeProgressPopup();
dataRefresh(true);
}
}
});
}
if (!activityResultFlg && operationId == -1) {
dataRefresh(true);
}
});
}
if (!activityResultFlg && operationId == -1) {
dataRefresh(true);
}
}
}
putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
activityResultFlg = false;
......@@ -1406,6 +1445,10 @@ public class OperationListActivity extends OperationActivity {
showErrorDialog(R.string.msg_qrcode_operation_not_found);
return;
}
if (needAutoSync()) {
autoSyncOperationId(operationId);
return;
}
if (operationDto.needSyncFlg) {
//インターネット非接続時にはアラート表示
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
......@@ -1855,6 +1898,10 @@ public class OperationListActivity extends OperationActivity {
refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(lastUpdateTimeLabel);
}
}
if (needAutoSync()) {
autoSyncOperation();
return;
}
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
......@@ -1892,7 +1939,10 @@ public class OperationListActivity extends OperationActivity {
refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(lastUpdateTimeLabel);
}
}
if (needAutoSync()) {
autoSyncOperation();
return;
}
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
......@@ -2393,4 +2443,58 @@ public class OperationListActivity extends OperationActivity {
Logger.w(TAG,"Camera Permission false");
}
}
private boolean isAutoSync() {
return PreferenceUtil.get(getApplicationContext(), AppDefType.UserPrefKey.OPERATION_AUTO_SYNC, false);
}
public boolean needAutoSync() {
return (isAutoSync() && ABVEnvironment.getInstance().networkAdapter.isNetworkConnected());
}
/**
* Run refresh data and batch sync if need
*/
public void autoSyncOperation() {
if (mAutoSyncingFlg) {
return;
}
mAutoSyncingFlg = true;
showProgressPopup(getResources().getString(R.string.synchronizing));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
dataRefresh(true);
if (!contentRefresher.isRefreshing()) {
autoSyncOperationDone(false);
}
}
});
}
/**
* Auto sync and open operation if success
* @param operationId
*/
public void autoSyncOperationId(Long operationId) {
mAutoSyncOpenOperationId = operationId;
autoSyncOperation();
}
/**
* Auto sync done
* @param isSuccess
*/
public void autoSyncOperationDone(boolean isSuccess) {
mAutoSyncingFlg = false;
closeProgressPopup();
if (isSuccess) {
if (mAutoSyncOpenOperationId != null) {
OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId);
if (!operationDto.needSyncFlg) {
openReportView(operationDto);
}
}
}
mAutoSyncOpenOperationId = null;
}
}
......@@ -148,18 +148,7 @@ public abstract class OperationListHelper {
adapter.setAdapterListener(new AbstractOperationAdapter.AbstractOperationListAdapterListener() {
@Override
public void openReport(OperationDto operationDto) {
if (operationDto.contentId != null && operationDto.contentId != 0) {
// 作業画面
mAppActivity.openReportView(operationDto);
} else {
if (operationDto.operationType == PANO) {
// パノラマ登録画面
mAppActivity.showPanoEntryDialog(operationDto);
} else {
// 何もしない
Logger.e("not open target");
}
}
onClickReport(operationDto);
}
@Override
......@@ -211,18 +200,7 @@ public abstract class OperationListHelper {
adapter.setAdapterListener(new AbstractOperationAdapter.AbstractOperationListAdapterListener() {
@Override
public void openReport(OperationDto operationDto) {
if (operationDto.contentId != null && operationDto.contentId != 0) {
// 作業画面
mAppActivity.openReportView(operationDto);
} else {
if (operationDto.operationType == PANO) {
// パノラマ登録画面
mAppActivity.showPanoEntryDialog(operationDto);
} else {
// 何もしない
Logger.e("not open target");
}
}
onClickReport(operationDto);
}
@Override
......@@ -285,4 +263,23 @@ public abstract class OperationListHelper {
*/
abstract protected List<OperationDto> findOperationList() throws Exception;
public void onClickReport(OperationDto operationDto) {
if (mAppActivity.needAutoSync()) {
mAppActivity.autoSyncOperationId(operationDto.operationId);
return;
}
if (operationDto.contentId != null && operationDto.contentId != 0) {
// 作業画面
mAppActivity.openReportView(operationDto);
} else {
if (operationDto.operationType == PANO) {
// パノラマ登録画面
mAppActivity.showPanoEntryDialog(operationDto);
} else {
// 何もしない
Logger.e("not open target");
}
}
}
}
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