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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
44 deletions
+65
-44
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+45
-27
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
+20
-17
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 {
...
@@ -90,26 +90,35 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
* @param loginId
* @param loginId
*/
*/
protected
void
showMainActivity
(
String
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
@Override
public
void
run
()
{
public
void
onEmpty
()
{
onAgreed
();
}
@Override
public
void
onAgreed
()
{
// 規約同意画面が開かれなかったら、次に進む
doShowMainActivity
();
}
@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
);
LogoutHelper
.
logout
(
ABVNoAuthenticatedActivity
.
this
);
}
}
});
});
switch
(
confirmResult
)
{
case
DISABLE:
case
EMPTY:
case
AGREED:
// 規約同意画面が開かれなかったら、改めて初期化
doShowMainActivity
();
break
;
case
FAILED:
break
;
case
CONFIRM:
// onActivityResultを待つ
break
;
}
}
};
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
listener
);
}
}
protected
void
doShowMainActivity
()
{
protected
void
doShowMainActivity
()
{
...
@@ -408,22 +417,31 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
...
@@ -408,22 +417,31 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
}
// 必要に応じて、規約同意画面を表示
// 必要に応じて、規約同意画面を表示
AgreementToTermsActivity
.
clearVersion
(
this
);
// for debug!
AgreementToTermsActivity
.
clearVersion
(
this
);
// for debug!
AgreementToTermsActivity
.
Result
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
null
);
AgreementToTermsActivity
.
PreAgreementListener
listener
=
new
AgreementToTermsActivity
.
PreAgreementListener
()
{
switch
(
confirmResult
)
{
@Override
case
DISABLE:
public
void
onDisabled
()
{
case
EMPTY:
onAgreed
();
case
AGREED:
}
// 規約同意画面が開かれなかったら、改めて初期化
@Override
public
void
onEmpty
()
{
onAgreed
();
}
@Override
public
void
onAgreed
()
{
// 規約同意画面が開かれなかったら、次に進む
doMoveToHome
();
doMoveToHome
();
break
;
}
case
FAILED:
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
@Override
public
void
onFailed
(
Exception
e
)
{
// 読み込みに失敗しても、次に進む
Logger
.
e
(
TAG
,
e
);
doMoveToHome
();
doMoveToHome
();
break
;
case
CONFIRM:
// onActivityResultを待つ
break
;
}
}
};
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
listener
);
}
}
@Override
@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 {
...
@@ -29,12 +29,11 @@ public class AgreementToTermsActivity extends ABVUIActivity {
private
static
final
String
TAG
=
"AgreementToTermsActivity"
;
private
static
final
String
TAG
=
"AgreementToTermsActivity"
;
private
String
currentVersion
=
""
;
private
String
currentVersion
=
""
;
public
enum
Result
{
public
interface
PreAgreementListener
{
DISABLE
,
// 規約同意オプションが無効だった
void
onDisabled
();
EMPTY
,
// 規約情報が空だった
void
onEmpty
();
AGREED
,
// 同意済みだった
void
onAgreed
();
FAILED
,
// 規約情報の読み込みに失敗した
void
onFailed
(
Exception
e
);
CONFIRM
// 規約同意画面を表示した
}
}
@Override
@Override
...
@@ -148,42 +147,46 @@ public class AgreementToTermsActivity extends ABVUIActivity {
...
@@ -148,42 +147,46 @@ public class AgreementToTermsActivity extends ABVUIActivity {
* @param context 呼び出し元アクティビティ
* @param context 呼び出し元アクティビティ
* @param requestCode startActivityForResultで使用するリクエスト・コード
* @param requestCode startActivityForResultで使用するリクエスト・コード
* @param isNormalSize 端末サイズ指定(スマホならtrue)
* @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
())
{
if
(!
ABVDataCache
.
getInstance
().
serviceOption
.
isUsableAgreementToTerms
())
{
// 規約同意オプションが無効な場合、何もしない
// 規約同意オプションが無効な場合、何もしない
return
Result
.
DISABLE
;
listener
.
onDisabled
();
return
;
}
}
try
{
context
.
showProgressPopup
();
context
.
showProgressPopup
();
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
AgreementToTermsJSON
json
=
logic
.
getTerms
();
AgreementToTermsJSON
json
=
logic
.
getTerms
();
if
(
json
.
getTerms
().
isEmpty
()
||
json
.
getTermsVersion
().
isEmpty
())
{
if
(
json
.
getTerms
().
isEmpty
()
||
json
.
getTermsVersion
().
isEmpty
())
{
// 規約内容やバージョンが空の場合は何もしない
// 規約内容やバージョンが空の場合は何もしない
return
Result
.
EMPTY
;
listener
.
onEmpty
();
return
;
}
}
if
(
getLatestVersion
(
context
).
equals
(
json
.
getTermsVersion
()))
{
if
(
getLatestVersion
(
context
).
equals
(
json
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは何もしない
// 規約のバージョンが、すでに同意しているものと同じときは何もしない
return
Result
.
AGREED
;
listener
.
onAgreed
();
return
;
}
}
// ダイアログ表示
// ダイアログ表示
Intent
intent
=
new
Intent
(
context
,
isNormalSize
?
AgreementToTermsActivity
.
class
:
AgreementToTermsActivityDialog
.
class
);
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_VERSION
,
json
.
getTermsVersion
());
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS
,
json
.
getTerms
());
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS
,
json
.
getTerms
());
context
.
startActivityForResult
(
intent
,
requestCode
);
context
.
startActivityForResult
(
intent
,
requestCode
);
return
Result
.
CONFIRM
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
Logger
.
e
(
TAG
,
e
);
if
(
onFailed
!=
null
)
{
listener
.
onFailed
(
e
);
failed
(
context
,
onFailed
);
}
return
Result
.
FAILED
;
}
finally
{
}
finally
{
context
.
closeProgressPopup
();
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