Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
3329f676
Commit
3329f676
authored
Aug 29, 2019
by
Lee Jaebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一括同期処理(レビュー後修正)
parent
3e2de8d8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
188 additions
and
171 deletions
+188
-171
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/OperationDao.java
+10
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVActivity.java
+1
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVAuthenticatedActivity.java
+1
-20
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/view/ABVBatchSyncView.java
+87
-18
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/OperationListActivity.java
+87
-132
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/helper/OperationGroupMasterListHelper.java
+2
-0
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/data/dao/OperationDao.java
View file @
3329f676
...
@@ -401,6 +401,16 @@ public class OperationDao extends AbstractDao {
...
@@ -401,6 +401,16 @@ public class OperationDao extends AbstractDao {
}
}
/**
/**
* 作業グループに紐づく同期可能な作業リストが存在するかチェック
* @param operationGroupMasterId
* @return
*/
public
boolean
hasNeedSyncOperationByGroupMasterId
(
Integer
operationGroupMasterId
)
{
List
<
OperationDto
>
operationDtoList
=
getNeedSyncOperationByGroupMasterId
(
operationGroupMasterId
);
return
operationDtoList
!=
null
&&
operationDtoList
.
size
()
>
0
;
}
/**
* 定期点検で同期が必要な作業を取得
* 定期点検で同期が必要な作業を取得
* @return
* @return
*/
*/
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVActivity.java
View file @
3329f676
...
@@ -800,7 +800,7 @@ public abstract class ABVActivity extends Activity {
...
@@ -800,7 +800,7 @@ public abstract class ABVActivity extends Activity {
showSimpleAlertDialog
(
getString
(
titleResId
),
getString
(
bodyResId
));
showSimpleAlertDialog
(
getString
(
titleResId
),
getString
(
bodyResId
));
}
}
p
rotected
void
showSimpleAlertDialog
(
final
String
title
,
final
String
body
)
{
p
ublic
void
showSimpleAlertDialog
(
final
String
title
,
final
String
body
)
{
handler
.
postDelayed
(
new
Runnable
()
{
handler
.
postDelayed
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVAuthenticatedActivity.java
View file @
3329f676
...
@@ -659,26 +659,7 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
...
@@ -659,26 +659,7 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
return
result
;
return
result
;
}
}
/**
* 作業用コンテンツダウンロード時、ダウンロードかダウンロード再開か判定して行う。
* @param contentDto
* @return
*/
public
boolean
operationContentDownload
(
final
ContentDto
contentDto
)
{
if
(
contentDto
.
isDownloadPaused
())
{
// ダウンロード途中で通信が切れた場合、一時停止のステータスに変更になるため、再開させる
try
{
contentDownloader
.
resume
(
contentDto
.
contentId
);
contentDownloader
.
addContentDownloadListener
(
this
);
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
"downloadContent failed. contentId="
+
contentDto
.
contentId
,
e
);
return
false
;
}
}
else
{
return
contentDownload
(
contentDto
.
contentId
,
false
,
false
);
}
return
true
;
}
// Wifi非接続時のアラート表示
// Wifi非接続時のアラート表示
public
void
showWifiDisconnectAlert
(
final
int
messageId
,
final
DialogInterface
.
OnClickListener
positive
,
final
DialogInterface
.
OnClickListener
negative
)
throws
NetworkDisconnectedException
{
public
void
showWifiDisconnectAlert
(
final
int
messageId
,
final
DialogInterface
.
OnClickListener
positive
,
final
DialogInterface
.
OnClickListener
negative
)
throws
NetworkDisconnectedException
{
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/view/ABVBatchSyncView.java
View file @
3329f676
...
@@ -6,25 +6,42 @@ import android.graphics.PixelFormat;
...
@@ -6,25 +6,42 @@ import android.graphics.PixelFormat;
import
java.util.Stack
;
import
java.util.Stack
;
import
jp.agentec.abook.abv.bl.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.Callback
;
import
jp.agentec.abook.abv.bl.common.CommonExecutor
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.data.dao.AbstractDao
;
import
jp.agentec.abook.abv.bl.data.dao.ContentDao
;
import
jp.agentec.abook.abv.bl.dto.ContentDto
;
import
jp.agentec.abook.abv.bl.dto.OperationDto
;
import
jp.agentec.abook.abv.bl.dto.OperationDto
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.home.activity.OperationListActivity
;
/**
/**
* Created by leej on 2019/08/26.
* Created by leej on 2019/08/26.
*/
*/
public
class
ABVBatchSyncView
extends
ProgressDialog
{
public
class
ABVBatchSyncView
extends
ProgressDialog
{
private
static
final
String
TAG
=
"ABVBatchSyncView"
;
private
Stack
<
OperationDto
>
mBatchSyncOperationStack
=
new
Stack
<>();
private
Stack
<
OperationDto
>
mBatchSyncOperationStack
=
new
Stack
<>();
private
ContentDao
contentDao
=
AbstractDao
.
getDao
(
ContentDao
.
class
);
private
OperationListActivity
mOperationListActivity
;
// Activityが破棄された場合、処理を中止するフラグ
private
boolean
isDestroy
=
false
;
public
ABVBatchSyncView
(
Context
context
)
{
public
ABVBatchSyncView
(
Context
context
)
{
super
(
context
);
super
(
context
);
mOperationListActivity
=
(
OperationListActivity
)
context
;
init
();
init
();
isDestroy
=
false
;
}
}
// 初期化
// 初期化
private
void
init
()
{
private
void
init
()
{
if
(
getWindow
()
!=
null
)
{
if
(
getWindow
()
!=
null
)
{
setIndeterminate
(
false
);
setIndeterminate
(
false
);
// キャンセルできないように設定・ナビゲーションバーのバックボタンも無効してくれる
setCancelable
(
false
);
setCancelable
(
false
);
setProgressStyle
(
ProgressDialog
.
STYLE_HORIZONTAL
);
//プログレスバー表示
setProgressStyle
(
ProgressDialog
.
STYLE_HORIZONTAL
);
//プログレスバー表示
getWindow
().
setFormat
(
PixelFormat
.
TRANSPARENT
);
getWindow
().
setFormat
(
PixelFormat
.
TRANSPARENT
);
...
@@ -42,39 +59,91 @@ public class ABVBatchSyncView extends ProgressDialog {
...
@@ -42,39 +59,91 @@ public class ABVBatchSyncView extends ProgressDialog {
}
}
/**
/**
* 参照のみ、stackには保存状態
* 閉じる処理
* @return
*/
*/
public
OperationDto
getOperationStackPeek
()
{
public
void
closeProgressDialog
()
{
return
mBatchSyncOperationStack
.
peek
();
// プログレス値を0に初期化
setProgress
(
0
);
dismiss
();
}
}
/**
/**
*
stackからOperationDtoを取り出す
*
スタック中の空チェック
* @return
* @return
*/
*/
public
OperationDto
getOperationStackPop
()
{
public
boolean
isStackEmpty
()
{
return
mBatchSyncOperationStack
.
pop
();
return
mBatchSyncOperationStack
.
empty
();
}
}
public
boolean
checkMaxProgress
()
{
/**
return
getMax
()
==
getProgress
()
+
1
;
* 一括同期処理(stackの中を全て同期する)
* ベース資料ダウンロードチェックして、未ダウンロードであればダウンロードして同期
*/
public
void
batchOperationSyncForCheckDonwload
()
{
if
(
isDestroy
||
isStackEmpty
())
{
// Activity破棄フラグがtrue、またはスタックが存在しなければ、全て完了と見做す
closeProgressDialog
();
Logger
.
d
(
TAG
,
"---batchSync is end"
);
return
;
}
// ベース資料のダウンロードチェック
OperationDto
peekOperationDto
=
mBatchSyncOperationStack
.
peek
();
ContentDto
contentDto
=
contentDao
.
getContent
(
peekOperationDto
.
contentId
);
if
(
contentDto
==
null
)
{
Logger
.
e
(
TAG
,
"contentDto is null !"
);
closeProgressDialog
();
return
;
}
if
(!
contentDto
.
downloadedFlg
||
contentDto
.
updatedFlg
)
{
if
(!
mOperationListActivity
.
operationContentDownload
(
contentDto
))
{
// error
showBatchSyncErrorAlert
(
peekOperationDto
,
mOperationListActivity
.
getString
(
R
.
string
.
msg_batch_sync_content_download_fail
));
}
return
;
}
// 同期処理
batchOperationSync
();
}
}
/**
/**
*
閉じる処理
*
一括同期処理(ベース資料はダウンロード済み)
*/
*/
public
void
closeProgressDialog
()
{
public
void
batchOperationSync
()
{
// プログレス値を0に初期化
final
OperationDto
operationDto
=
mBatchSyncOperationStack
.
pop
();
setProgress
(
0
);
String
errorMessage
=
mOperationListActivity
.
syncOperation
(
operationDto
.
operationId
,
operationDto
.
reportType
,
false
);
dismiss
();
if
(
errorMessage
!=
null
)
{
showBatchSyncErrorAlert
(
operationDto
,
errorMessage
);
}
else
{
// 正常
// 次のスタックがなければ、カウントしない
if
(!
isStackEmpty
())
{
setProgress
(
getProgress
()
+
1
);
}
// 次の作業を同期処理
batchOperationSyncForCheckDonwload
();
}
}
// Activityが破棄された場合呼ばれる
public
void
setActivityDestroy
()
{
isDestroy
=
true
;
}
}
/**
/**
* スタック中の空チェック
* 一括同期処理時、エラーアラート表示
* @return
* 一括同期中のプログレスバーは非表示にする
* @param operationDto
* @param errorMessage
*/
*/
public
boolean
isStackEmpty
()
{
public
void
showBatchSyncErrorAlert
(
OperationDto
operationDto
,
String
errorMessage
)
{
return
mBatchSyncOperationStack
.
empty
();
// 異常
closeProgressDialog
();
if
(
ABVEnvironment
.
getInstance
().
networkAdapter
.
isNetworkConnected
())
{
String
convertErrorMsg
=
String
.
format
(
mOperationListActivity
.
getString
(
R
.
string
.
msg_batch_sync_error
),
operationDto
.
operationName
)
+
errorMessage
;
mOperationListActivity
.
showSimpleAlertDialog
(
mOperationListActivity
.
getString
(
R
.
string
.
app_name
),
convertErrorMsg
);
}
else
{
// ネットワーク通信エラー
mOperationListActivity
.
showSimpleAlertDialog
(
mOperationListActivity
.
getString
(
R
.
string
.
app_name
),
mOperationListActivity
.
getString
(
R
.
string
.
msg_batch_sync_disconnect_network
));
}
}
}
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/OperationListActivity.java
View file @
3329f676
...
@@ -387,8 +387,7 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -387,8 +387,7 @@ public class OperationListActivity extends ABVUIActivity {
alertDialog
.
show
();
alertDialog
.
show
();
}
}
}
}
// 一括同期を設定
batchSyncView
=
new
ABVBatchSyncView
(
this
);
mAllOperationReportTypes
=
getOperationReportTypeList
(
true
);
mAllOperationReportTypes
=
getOperationReportTypeList
(
true
);
// リスト更新
// リスト更新
setOperationListView
();
setOperationListView
();
...
@@ -442,15 +441,17 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -442,15 +441,17 @@ public class OperationListActivity extends ABVUIActivity {
// フィルターボタンを無効にする
// フィルターボタンを無効にする
mFilterButton
.
setImageDrawable
(
getRDrawable
(
R
.
drawable
.
ic_filter
));
mFilterButton
.
setImageDrawable
(
getRDrawable
(
R
.
drawable
.
ic_filter
));
setEnabledImageButton
(
mFilterButton
);
setEnabledImageButton
(
mFilterButton
,
false
);
// 検索ボタンを無効にする
// 検索ボタンを無効にする
mSearchButton
.
setImageDrawable
(
getRDrawable
(
R
.
drawable
.
ic_operation_search
));
mSearchButton
.
setImageDrawable
(
getRDrawable
(
R
.
drawable
.
ic_operation_search
));
setEnabledImageButton
(
mSearchButton
);
setEnabledImageButton
(
mSearchButton
,
false
);
// 一括同期ボタン表示
// 一括同期ボタン表示
mOperationBatchSyncButton
.
setVisibility
(
View
.
VISIBLE
);
mOperationBatchSyncButton
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
// 全て
// 全て
cancelToolbarEnabledIcon
();
// ボタンを活性化
setEnabledImageButton
(
mFilterButton
,
true
);
setEnabledImageButton
(
mSearchButton
,
true
);
// 一括同期ボタン非表示
// 一括同期ボタン非表示
mOperationBatchSyncButton
.
setVisibility
(
View
.
GONE
);
mOperationBatchSyncButton
.
setVisibility
(
View
.
GONE
);
}
}
...
@@ -459,7 +460,11 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -459,7 +460,11 @@ public class OperationListActivity extends ABVUIActivity {
}
else
{
}
else
{
// アイコン非表示
// アイコン非表示
mLocationTypeRadioGroup
.
setVisibility
(
View
.
GONE
);
mLocationTypeRadioGroup
.
setVisibility
(
View
.
GONE
);
cancelToolbarEnabledIcon
();
// 一括同期ボタンを非表示
mOperationBatchSyncButton
.
setVisibility
(
View
.
GONE
);
// ボタンを活性化
setEnabledImageButton
(
mFilterButton
,
true
);
setEnabledImageButton
(
mSearchButton
,
true
);
}
}
// ツールバーの検索結果レイアウトの表示・非表示
// ツールバーの検索結果レイアウトの表示・非表示
...
@@ -473,19 +478,17 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -473,19 +478,17 @@ public class OperationListActivity extends ABVUIActivity {
mEndDateStr
=
null
;
mEndDateStr
=
null
;
clearData
();
clearData
();
}
}
// イメージボタンを無効にする
// イメージボタンを無効/有効にする
private
void
setEnabledImageButton
(
ImageButton
button
)
{
private
void
setEnabledImageButton
(
ImageButton
button
,
boolean
enabled
)
{
if
(
enabled
)
{
// 活性化
button
.
setEnabled
(
true
);
button
.
setColorFilter
(
null
);
}
else
{
// 非活性化
button
.
setEnabled
(
false
);
button
.
setEnabled
(
false
);
button
.
setColorFilter
(
0xaa808080
);
button
.
setColorFilter
(
0xaa808080
);
}
}
/**
* ツールバーのアイコンを有効にする
*/
private
void
cancelToolbarEnabledIcon
()
{
mFilterButton
.
setEnabled
(
true
);
mFilterButton
.
setColorFilter
(
null
);
mSearchButton
.
setEnabled
(
true
);
mSearchButton
.
setColorFilter
(
null
);
}
}
/**
/**
...
@@ -568,7 +571,7 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -568,7 +571,7 @@ public class OperationListActivity extends ABVUIActivity {
Logger
.
d
(
TAG
,
"onResume Sync operationId : "
+
operationId
);
Logger
.
d
(
TAG
,
"onResume Sync operationId : "
+
operationId
);
if
(
operationDto
!=
null
&&
operationDto
.
needSyncFlg
)
{
if
(
operationDto
!=
null
&&
operationDto
.
needSyncFlg
)
{
// 同期処理後、直列処理で新着更新を行う。
// 同期処理後、直列処理で新着更新を行う。
syncOperation
(
operationId
,
operationDto
.
reportType
);
s
ingleS
yncOperation
(
operationId
,
operationDto
.
reportType
);
}
else
{
}
else
{
closeProgressPopup
();
closeProgressPopup
();
}
}
...
@@ -821,16 +824,17 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -821,16 +824,17 @@ public class OperationListActivity extends ABVUIActivity {
if
(
isShowingBatchSync
())
{
if
(
isShowingBatchSync
())
{
// 一括同期からの同期処理
// 一括同期からの同期処理
Logger
.
d
(
TAG
,
"[onDownloadingContentZip] batchOperationSync start"
);
Logger
.
d
(
TAG
,
"[onDownloadingContentZip] batchOperationSync start"
);
batch
OperationSync
(
true
);
batch
SyncView
.
batchOperationSync
(
);
}
else
{
}
else
{
OperationDto
operationDto
=
mOperationLogic
.
getOperation
(
operationContentDto
.
operationId
);
OperationDto
operationDto
=
mOperationLogic
.
getOperation
(
operationContentDto
.
operationId
);
syncOperation
(
operationContentDto
.
operationId
,
operationDto
.
reportType
,
true
);
s
ingleS
yncOperation
(
operationContentDto
.
operationId
,
operationDto
.
reportType
,
true
);
}
}
}
else
if
(
notification
.
downloadStatus
==
DownloadStatusType
.
Failed
||
notification
.
downloadStatus
==
DownloadStatusType
.
Canceled
||
notification
.
downloadStatus
==
DownloadStatusType
.
Paused
)
{
}
else
if
(
notification
.
downloadStatus
==
DownloadStatusType
.
Failed
||
notification
.
downloadStatus
==
DownloadStatusType
.
Canceled
||
notification
.
downloadStatus
==
DownloadStatusType
.
Paused
)
{
Logger
.
d
(
TAG
,
"syncOperation update is failed downloadStatus : "
+
notification
.
downloadStatus
);
Logger
.
d
(
TAG
,
"syncOperation update is failed downloadStatus : "
+
notification
.
downloadStatus
);
if
(
isShowingBatchSync
())
{
if
(
isShowingBatchSync
())
{
// 一括同期からのダウンロード失敗時、エラーメッセージ表示
// 一括同期からのダウンロード失敗時、エラーメッセージ表示
showBatchSyncErrorAlert
(
getString
(
R
.
string
.
msg_batch_sync_content_download_fail
));
OperationDto
operationDto
=
mOperationLogic
.
getOperation
(
operationContentDto
.
operationId
);
batchSyncView
.
showBatchSyncErrorAlert
(
operationDto
,
getString
(
R
.
string
.
msg_batch_sync_content_download_fail
));
}
}
closeProgressPopup
();
closeProgressPopup
();
}
}
...
@@ -838,34 +842,22 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -838,34 +842,22 @@ public class OperationListActivity extends ABVUIActivity {
}
}
// 作業の自動同期処理(onresumeで呼ばれる同期処理)
// 作業の自動同期処理(onresumeで呼ばれる同期処理)
public
void
syncOperation
(
final
long
operationId
,
int
operationReportType
)
{
public
void
s
ingleS
yncOperation
(
final
long
operationId
,
int
operationReportType
)
{
syncOperation
(
operationId
,
operationReportType
,
false
);
s
ingleS
yncOperation
(
operationId
,
operationReportType
,
false
);
}
}
/**
/**
* 作業同期処理
* 作業同期処理
(単一)
* @param operationId
* @param operationId
* @param operationReportType
* @param operationReportType
*/
*/
public
void
syncOperation
(
final
long
operationId
,
int
operationReportType
,
boolean
buttonEventFlg
)
{
public
void
singleSyncOperation
(
final
long
operationId
,
int
operationReportType
,
boolean
buttonEventFlg
)
{
// TODO callback or return errorMsg どっちを使用すればいいか検討
String
errorMessage
=
syncOperation
(
operationId
,
operationReportType
,
buttonEventFlg
);
syncOperation
(
operationId
,
operationReportType
,
buttonEventFlg
,
new
Callback
()
{
@Override
public
Object
callback
(
Object
ret
)
{
final
String
errorMessage
=
(
String
)
ret
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
errorMessage
!=
null
)
{
if
(
errorMessage
!=
null
)
{
closeProgressPopup
();
// エラーメッセージ表示
// エラーメッセージ表示
showSimpleAlertDialog
(
getString
(
R
.
string
.
app_name
),
errorMessage
);
showSimpleAlertDialog
(
getString
(
R
.
string
.
app_name
),
errorMessage
);
closeProgressPopup
();
}
}
});
return
null
;
}
}
});
}
}
/**
/**
...
@@ -873,9 +865,9 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -873,9 +865,9 @@ public class OperationListActivity extends ABVUIActivity {
* @param operationId
* @param operationId
* @param reportType
* @param reportType
* @param buttonEventFlag
* @param buttonEventFlag
* @return result
true 正常 false 異常
* @return result
errorMessage
*/
*/
public
void
syncOperation
(
final
long
operationId
,
int
reportType
,
boolean
buttonEventFlag
,
final
Callback
errorCallback
)
{
public
String
syncOperation
(
final
long
operationId
,
int
reportType
,
boolean
buttonEventFlag
)
{
final
StringBuilder
errorMsg
=
new
StringBuilder
();
final
StringBuilder
errorMsg
=
new
StringBuilder
();
Logger
.
i
(
TAG
,
"---sync start"
);
Logger
.
i
(
TAG
,
"---sync start"
);
...
@@ -961,12 +953,11 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -961,12 +953,11 @@ public class OperationListActivity extends ABVUIActivity {
mOperationLastEditDate
=
null
;
mOperationLastEditDate
=
null
;
refreshOperationList
();
refreshOperationList
();
closeProgressPopup
();
closeProgressPopup
();
// コールバック
errorCallback
.
callback
(
errorMsg
.
length
()
>
0
?
errorMsg
.
toString
()
:
null
);
}
}
});
});
Logger
.
i
(
TAG
,
"---sync end"
);
Logger
.
i
(
TAG
,
"---sync end"
);
}
}
return
errorMsg
.
length
()
>
0
?
errorMsg
.
toString
()
:
null
;
}
}
// 設定画面へ遷移
// 設定画面へ遷移
...
@@ -1881,7 +1872,7 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -1881,7 +1872,7 @@ public class OperationListActivity extends ABVUIActivity {
closeProgressPopup
();
closeProgressPopup
();
}
}
}
else
{
}
else
{
syncOperation
(
operationDto
.
operationId
,
operationDto
.
reportType
,
true
);
s
ingleS
yncOperation
(
operationDto
.
operationId
,
operationDto
.
reportType
,
true
);
}
}
}
}
});
});
...
@@ -2279,9 +2270,9 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -2279,9 +2270,9 @@ public class OperationListActivity extends ABVUIActivity {
dialog
.
setPositiveButton
(
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
dialog
.
setPositiveButton
(
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
// 一括同期開始
// 一括同期開始
categoryBatchSync
();
categoryBatchSync
();
dialog
.
dismiss
();
}
}
});
});
dialog
.
setNegativeButton
(
R
.
string
.
cancel
,
new
DialogInterface
.
OnClickListener
()
{
dialog
.
setNegativeButton
(
R
.
string
.
cancel
,
new
DialogInterface
.
OnClickListener
()
{
...
@@ -2302,106 +2293,28 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -2302,106 +2293,28 @@ public class OperationListActivity extends ABVUIActivity {
*/
*/
public
void
categoryBatchSync
()
{
public
void
categoryBatchSync
()
{
Logger
.
i
(
TAG
,
"---batch sync start"
);
Logger
.
i
(
TAG
,
"---batch sync start"
);
// ネットワーク通信チェック
if
(!
ABVEnvironment
.
getInstance
().
networkAdapter
.
isNetworkConnected
())
{
showSimpleAlertDialog
(
getString
(
R
.
string
.
app_name
),
getString
(
R
.
string
.
request_network_connection
));
return
;
}
// 作業種別に関連する作業リストを取得
// 作業種別に関連する作業リストを取得
List
<
OperationDto
>
operationList
=
mOperationDao
.
getNeedSyncOperationByGroupMasterId
(
getABVUIDataCache
().
getOperationGroupMasterId
());
List
<
OperationDto
>
operationList
=
mOperationDao
.
getNeedSyncOperationByGroupMasterId
(
getABVUIDataCache
().
getOperationGroupMasterId
());
// 一覧に作業が存在しない場合
if
(
operationList
==
null
||
operationList
.
isEmpty
())
{
Logger
.
w
(
TAG
,
"categoryBatchSync operation is null or Empty"
);
return
;
}
// 作業リストをスタックにセット
// 作業リストをスタックにセット
Stack
<
OperationDto
>
operationDtoStack
=
new
Stack
<
OperationDto
>();
Stack
<
OperationDto
>
operationDtoStack
=
new
Stack
<
OperationDto
>();
for
(
OperationDto
operationDto
:
operationList
)
{
operationDtoStack
.
addAll
(
operationList
);
operationDtoStack
.
push
(
operationDto
);
}
// 一括同期を設定
batchSyncView
=
new
ABVBatchSyncView
(
this
);
// batchSyncViewにスタックをセットして表示
// batchSyncViewにスタックをセットして表示
batchSyncView
.
setStack
(
operationDtoStack
);
batchSyncView
.
setStack
(
operationDtoStack
);
batchSyncView
.
show
();
batchSyncView
.
show
();
// 一括同期処理
// 一括同期処理
batchOperationSync
(
false
);
batchSyncView
.
batchOperationSyncForCheckDonwload
();
}
/**
* 一括同期処理(stackの中を全て同期する)
* @param downloadedFlg
*/
private
void
batchOperationSync
(
final
boolean
downloadedFlg
)
{
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
batchSyncView
.
isStackEmpty
())
{
batchSyncView
.
closeProgressDialog
();
return
;
}
if
(!
downloadedFlg
)
{
Logger
.
d
(
TAG
,
"batchOperation sync -- base file not downloaded"
);
// ベースファイルのダウンロードチェック
OperationDto
peekOperationDto
=
batchSyncView
.
getOperationStackPeek
();
ContentDto
contentDto
=
contentDao
.
getContent
(
peekOperationDto
.
contentId
);
if
(
contentDto
==
null
)
{
Logger
.
e
(
TAG
,
"contentDto is null !"
);
return
;
}
if
(!
contentDto
.
downloadedFlg
||
contentDto
.
updatedFlg
)
{
if
(!
operationContentDownload
(
contentDto
))
{
// error
showBatchSyncErrorAlert
(
getString
(
R
.
string
.
msg_batch_sync_content_download_fail
));
}
return
;
}
}
final
OperationDto
operationDto
=
batchSyncView
.
getOperationStackPop
();
// TODO callback or return errorMsg どっちを使用すればいいか検討
syncOperation
(
operationDto
.
operationId
,
operationDto
.
reportType
,
false
,
new
Callback
()
{
@Override
public
Object
callback
(
Object
ret
)
{
final
String
errorMessage
=
(
String
)
ret
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
errorMessage
!=
null
)
{
// error
if
(
ABVEnvironment
.
getInstance
().
networkAdapter
.
isNetworkConnected
())
{
showBatchSyncErrorAlert
(
String
.
format
(
getString
(
R
.
string
.
msg_batch_sync_error
),
operationDto
.
operationName
)
+
errorMessage
);
}
else
{
// ネットワーク通信エラー
showBatchSyncErrorAlert
(
getString
(
R
.
string
.
msg_batch_sync_disconnect_network
));
}
}
else
{
if
(
batchSyncView
.
checkMaxProgress
())
{
// 最後の処理が完了したと見做す
batchSyncView
.
closeProgressDialog
();
Logger
.
d
(
TAG
,
"---batchSync is end"
);
}
else
{
// プログレスバーに作業1つ完了をセット
batchSyncView
.
setProgress
(
batchSyncView
.
getProgress
()
+
1
);
// 次の作業を同期処理
batchOperationSync
(
false
);
}
}
}
});
return
null
;
}
});
}
});
}
/**
* 一括同期処理時、エラーアラート表示
* 一括同期中のプログレスバーは非表示にする
* @param msg
*/
private
void
showBatchSyncErrorAlert
(
String
msg
)
{
showSimpleAlertDialog
(
getString
(
R
.
string
.
app_name
),
msg
);
batchSyncView
.
closeProgressDialog
();
}
}
/**
/**
...
@@ -2422,4 +2335,46 @@ public class OperationListActivity extends ABVUIActivity {
...
@@ -2422,4 +2335,46 @@ public class OperationListActivity extends ABVUIActivity {
}
}
}
}
}
}
/**
* 作業用コンテンツダウンロード時、ダウンロードかダウンロード再開か判定して行う。
* @param contentDto
* @return
*/
public
boolean
operationContentDownload
(
final
ContentDto
contentDto
)
{
if
(
contentDto
.
isDownloadPaused
())
{
// ダウンロード途中で通信が切れた場合、一時停止のステータスに変更になるため、再開させる
try
{
contentDownloader
.
resume
(
contentDto
.
contentId
);
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
"downloadContent failed. contentId="
+
contentDto
.
contentId
,
e
);
return
false
;
}
}
else
{
// ダウンロード
return
contentDownload
(
contentDto
.
contentId
,
false
,
false
);
}
return
true
;
}
/**
* 一括同期の活性化・非活性化チェック
*/
public
void
checkBatchNeedSyncButton
(
Integer
operationGroupMasterId
)
{
if
(
mOperationDao
.
hasNeedSyncOperationByGroupMasterId
(
operationGroupMasterId
))
{
// 選択したカテゴリ一覧でneedSyncFlgがtrueの作業が存在すれば、活性化する
setEnabledImageButton
(
mOperationBatchSyncButton
,
true
);
}
else
{
// 一括同期ボタンを非活性化する
setEnabledImageButton
(
mOperationBatchSyncButton
,
false
);
}
}
@Override
public
void
onDestroy
()
{
Logger
.
d
(
TAG
,
"onDestroy"
);
contentDownloader
.
removeContentDownloadListener
(
this
);
batchSyncView
.
setActivityDestroy
();
super
.
onDestroy
();
}
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/helper/OperationGroupMasterListHelper.java
View file @
3329f676
...
@@ -74,6 +74,8 @@ public class OperationGroupMasterListHelper extends HierarchyOperationListHelper
...
@@ -74,6 +74,8 @@ public class OperationGroupMasterListHelper extends HierarchyOperationListHelper
mAppActivity
.
closeOperationGroupMasterDialog
();
mAppActivity
.
closeOperationGroupMasterDialog
();
}
}
OperationGroupMasterDto
peekOperationGroupMasterDto
=
stack
.
peek
();
OperationGroupMasterDto
peekOperationGroupMasterDto
=
stack
.
peek
();
mAppActivity
.
checkBatchNeedSyncButton
(
peekOperationGroupMasterDto
.
operationGroupMasterId
);
// 作業種別IDで紐づく作業リストを取得
// 作業種別IDで紐づく作業リストを取得
return
mOperationGroupMasterLogic
.
getOperationByOperationGroupMasterId
(
peekOperationGroupMasterDto
.
operationGroupMasterId
);
return
mOperationGroupMasterLogic
.
getOperationByOperationGroupMasterId
(
peekOperationGroupMasterDto
.
operationGroupMasterId
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment