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
5c640418
Commit
5c640418
authored
May 18, 2023
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
非同期通信を実装
parent
7371d7a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
66 deletions
+87
-66
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+48
-30
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
+39
-36
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
View file @
5c640418
...
...
@@ -90,26 +90,35 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
* @param loginId
*/
protected
void
showMainActivity
(
String
loginId
)
{
AgreementToTermsActivity
.
PreAgreementListener
listener
=
new
AgreementToTermsActivity
.
PreAgreementListener
()
{
@Override
public
void
onDisabled
()
{
onAgreed
();
}
AgreementToTermsActivity
.
Result
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
new
Runnable
()
{
@Override
public
void
run
()
{
LogoutHelper
.
logout
(
ABVNoAuthenticatedActivity
.
this
);
public
void
onEmpty
()
{
onAgreed
(
);
}
});
switch
(
confirmResult
)
{
case
DISABLE:
case
EMPTY:
case
AGREED:
// 規約同意画面が開かれなかったら、改めて初期化
@Override
public
void
onAgreed
()
{
// 規約同意画面が開かれなかったら、次に進む
doShowMainActivity
();
break
;
case
FAILED:
break
;
case
CONFIRM:
// onActivityResultを待つ
break
;
}
}
@Override
public
void
onFailed
(
Exception
e
)
{
// 読み込みに失敗したらログアウト
AlertDialogUtil
.
showAlertDialog
(
ABVNoAuthenticatedActivity
.
this
,
R
.
string
.
app_name
,
R
.
string
.
failed_to_get_terms_of_service
,
true
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
LogoutHelper
.
logout
(
ABVNoAuthenticatedActivity
.
this
);
}
});
}
};
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
listener
);
}
protected
void
doShowMainActivity
()
{
...
...
@@ -408,22 +417,31 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
// 必要に応じて、規約同意画面を表示
AgreementToTermsActivity
.
clearVersion
(
this
);
// for debug!
AgreementToTermsActivity
.
Result
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
null
);
switch
(
confirmResult
)
{
case
DISABLE:
case
EMPTY:
case
AGREED:
// 規約同意画面が開かれなかったら、改めて初期化
AgreementToTermsActivity
.
PreAgreementListener
listener
=
new
AgreementToTermsActivity
.
PreAgreementListener
()
{
@Override
public
void
onDisabled
()
{
onAgreed
();
}
@Override
public
void
onEmpty
()
{
onAgreed
();
}
@Override
public
void
onAgreed
()
{
// 規約同意画面が開かれなかったら、次に進む
doMoveToHome
();
break
;
case
FAILED:
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
}
@Override
public
void
onFailed
(
Exception
e
)
{
// 読み込みに失敗しても、次に進む
Logger
.
e
(
TAG
,
e
);
doMoveToHome
();
break
;
case
CONFIRM:
// onActivityResultを待つ
break
;
}
}
};
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
listener
);
}
@Override
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
View file @
5c640418
...
...
@@ -29,12 +29,11 @@ public class AgreementToTermsActivity extends ABVUIActivity {
private
static
final
String
TAG
=
"AgreementToTermsActivity"
;
private
String
currentVersion
=
""
;
public
enum
Result
{
DISABLE
,
// 規約同意オプションが無効だった
EMPTY
,
// 規約情報が空だった
AGREED
,
// 同意済みだった
FAILED
,
// 規約情報の読み込みに失敗した
CONFIRM
// 規約同意画面を表示した
public
interface
PreAgreementListener
{
void
onDisabled
();
void
onEmpty
();
void
onAgreed
();
void
onFailed
(
Exception
e
);
}
@Override
...
...
@@ -148,41 +147,45 @@ public class AgreementToTermsActivity extends ABVUIActivity {
* @param context 呼び出し元アクティビティ
* @param requestCode startActivityForResultで使用するリクエスト・コード
* @param isNormalSize 端末サイズ指定(スマホならtrue)
* @param
onFailed 規約情報の取得に失敗したときの処理
* @param
listener 規約同意画面を表示する前に結果が出た時の動作を指定するリスナー
*/
public
static
Result
confirmAgreement
(
final
ABVActivity
context
,
int
requestCode
,
boolean
isNormalSize
,
@Nullable
final
Runnable
onFailed
)
{
public
static
void
confirmAgreement
(
final
ABVActivity
context
,
final
int
requestCode
,
final
boolean
isNormalSize
,
final
PreAgreementListener
listener
)
{
if
(!
ABVDataCache
.
getInstance
().
serviceOption
.
isUsableAgreementToTerms
())
{
// 規約同意オプションが無効な場合、何もしない
return
Result
.
DISABLE
;
listener
.
onDisabled
();
return
;
}
try
{
context
.
showProgressPopup
();
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
AgreementToTermsJSON
json
=
logic
.
getTerms
();
if
(
json
.
getTerms
().
isEmpty
()
||
json
.
getTermsVersion
().
isEmpty
())
{
// 規約内容やバージョンが空の場合は何もしない
return
Result
.
EMPTY
;
}
if
(
getLatestVersion
(
context
).
equals
(
json
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは何もしない
return
Result
.
AGREED
;
}
// ダイアログ表示
Intent
intent
=
new
Intent
(
context
,
isNormalSize
?
AgreementToTermsActivity
.
class
:
AgreementToTermsActivityDialog
.
class
);
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
json
.
getTermsVersion
());
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS
,
json
.
getTerms
());
context
.
startActivityForResult
(
intent
,
requestCode
);
return
Result
.
CONFIRM
;
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
if
(
onFailed
!=
null
)
{
failed
(
context
,
onFailed
);
context
.
showProgressPopup
();
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
AgreementToTermsJSON
json
=
logic
.
getTerms
();
if
(
json
.
getTerms
().
isEmpty
()
||
json
.
getTermsVersion
().
isEmpty
())
{
// 規約内容やバージョンが空の場合は何もしない
listener
.
onEmpty
();
return
;
}
if
(
getLatestVersion
(
context
).
equals
(
json
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは何もしない
listener
.
onAgreed
();
return
;
}
// ダイアログ表示
Intent
intent
=
new
Intent
(
context
,
isNormalSize
?
AgreementToTermsActivity
.
class
:
AgreementToTermsActivityDialog
.
class
);
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
json
.
getTermsVersion
());
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS
,
json
.
getTerms
());
context
.
startActivityForResult
(
intent
,
requestCode
);
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
listener
.
onFailed
(
e
);
}
finally
{
context
.
closeProgressPopup
();
}
}
return
Result
.
FAILED
;
}
finally
{
context
.
closeProgressPopup
();
}
});
}
/**
...
...
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