Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
868dee72
Commit
868dee72
authored
Nov 02, 2018
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并检查更新的方法,优化检查更新失败时的提示
parent
9495cd4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
60 deletions
+64
-60
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+47
-5
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/DialogPlus.java
...src/main/java/cn/garymb/ygomobile/ui/plus/DialogPlus.java
+15
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+2
-55
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
868dee72
package
cn.garymb.ygomobile.ui.home
;
package
cn.garymb.ygomobile.ui.home
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.net.Uri
;
import
android.net.Uri
;
...
@@ -111,7 +112,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -111,7 +112,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//trpay
//trpay
TrPay
.
getInstance
(
HomeActivity
.
this
).
initPaySdk
(
"e1014da420ea4405898c01273d6731b6"
,
"YGOMobile"
);
TrPay
.
getInstance
(
HomeActivity
.
this
).
initPaySdk
(
"e1014da420ea4405898c01273d6731b6"
,
"YGOMobile"
);
//autoupadte checking
//autoupadte checking
checkPgyerUpdateSilent
(
getContext
(),
false
);
checkPgyerUpdateSilent
(
getContext
(),
false
,
false
,
false
);
//ServiceDuelAssistant
//ServiceDuelAssistant
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
this
.
startForegroundService
(
new
Intent
(
this
,
ServiceDuelAssistant
.
class
));
this
.
startForegroundService
(
new
Intent
(
this
,
ServiceDuelAssistant
.
class
));
...
@@ -399,8 +400,19 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -399,8 +400,19 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
mMenuIds
.
put
(
mMenuIds
.
size
(),
menuId
);
mMenuIds
.
put
(
mMenuIds
.
size
(),
menuId
);
}
}
public
static
void
checkPgyerUpdateSilent
(
Context
context
,
boolean
isToastNoUpdata
)
{
/*
final
DialogPlus
builder
=
new
DialogPlus
(
context
);;
*isToastCheckUpdateing 是否提示正在检查更新
*isToastNoUpdata 没有更新是否提示
* isErrorIntent 检查更新失败是否跳转下载地址
*/
public
static
void
checkPgyerUpdateSilent
(
Context
context
,
boolean
isToastCheckUpdateing
,
boolean
isToastNoUpdata
,
boolean
isErrorIntent
)
{
final
DialogPlus
builder
=
new
DialogPlus
(
context
);
if
(
isToastCheckUpdateing
)
{
builder
.
showProgressBar
();
builder
.
hideTitleBar
();
builder
.
setMessage
(
"检查更新中,请稍等"
);
builder
.
show
();
}
//蒲公英自动检查更新
//蒲公英自动检查更新
new
PgyUpdateManager
.
Builder
()
new
PgyUpdateManager
.
Builder
()
.
setForced
(
true
)
.
setForced
(
true
)
...
@@ -408,7 +420,11 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -408,7 +420,11 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
.
setDeleteHistroyApk
(
false
)
.
setDeleteHistroyApk
(
false
)
.
setUpdateManagerListener
(
new
UpdateManagerListener
()
{
.
setUpdateManagerListener
(
new
UpdateManagerListener
()
{
@Override
@Override
public
void
onNoUpdateAvailable
()
{
}
public
void
onNoUpdateAvailable
()
{
if
(
isToastNoUpdata
){
Toast
.
makeText
(
context
,
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
@Override
@Override
public
void
onUpdateAvailable
(
AppBean
appBean
)
{
public
void
onUpdateAvailable
(
AppBean
appBean
)
{
final
String
versionName
,
updateMessage
;
final
String
versionName
,
updateMessage
;
...
@@ -428,7 +444,33 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -428,7 +444,33 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
}
}
@Override
@Override
public
void
checkUpdateFailed
(
Exception
e
)
{
}
public
void
checkUpdateFailed
(
Exception
e
)
{
if
(
isErrorIntent
)
{
builder
.
hideProgressBar
();
builder
.
showTitleBar
();
builder
.
setTitleText
(
"检查更新失败"
);
builder
.
setMessage
(
"检查更新失败,原因为:“"
+
e
.
getMessage
()+
"”\n是否跳转到官方下载地址下载?"
);
builder
.
setLeftButtonText
(
"去吧"
);
builder
.
setRightButtonText
(
"取消"
);
builder
.
setRightButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
}
});
builder
.
setLeftButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
Intent
intent
=
new
Intent
();
intent
.
setAction
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
Uri
.
parse
(
"https://www.taptap.com/app/37972"
));
context
.
startActivity
(
intent
);
dialog
.
dismiss
();
}
});
builder
.
show
();
}
}
})
})
.
setDownloadFileListener
(
new
DownloadFileListener
()
{
.
setDownloadFileListener
(
new
DownloadFileListener
()
{
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/DialogPlus.java
View file @
868dee72
...
@@ -88,6 +88,14 @@ public class DialogPlus extends Dialog {
...
@@ -88,6 +88,14 @@ public class DialogPlus extends Dialog {
return
this
;
return
this
;
}
}
//显示标题栏
public
DialogPlus
showTitleBar
()
{
if
(
mTitleLayout
!=
null
)
{
mTitleLayout
.
setVisibility
(
View
.
VISIBLE
);
}
return
this
;
}
public
DialogPlus
hideTitleBar
()
{
public
DialogPlus
hideTitleBar
()
{
if
(
mTitleLayout
!=
null
)
{
if
(
mTitleLayout
!=
null
)
{
mTitleLayout
.
setVisibility
(
View
.
GONE
);
mTitleLayout
.
setVisibility
(
View
.
GONE
);
...
@@ -184,6 +192,13 @@ public class DialogPlus extends Dialog {
...
@@ -184,6 +192,13 @@ public class DialogPlus extends Dialog {
return
this
;
return
this
;
}
}
public
DialogPlus
hideProgressBar
()
{
if
(
mProgressBar
!=
null
)
{
mProgressBar
.
setVisibility
(
View
.
GONE
);
}
return
this
;
}
public
DialogPlus
showProgressBar2
()
{
public
DialogPlus
showProgressBar2
()
{
if
(
mProgressBar2
!=
null
)
{
if
(
mProgressBar2
!=
null
)
{
mProgressBar2
.
setVisibility
(
View
.
VISIBLE
);
mProgressBar2
.
setVisibility
(
View
.
VISIBLE
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
868dee72
...
@@ -185,61 +185,8 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -185,61 +185,8 @@ public class SettingFragment extends PreferenceFragmentPlus {
.
loadUrl
(
"file:///android_asset/changelog.html"
,
Color
.
TRANSPARENT
)
.
loadUrl
(
"file:///android_asset/changelog.html"
,
Color
.
TRANSPARENT
)
.
show
();
.
show
();
}
}
if
(
PREF_CHECK_UPDATE
.
equals
(
preference
.
getKey
()))
{
if
(
PREF_CHECK_UPDATE
.
equals
(
key
))
{
final
DialogPlus
builder
=
new
DialogPlus
(
getContext
());;
HomeActivity
.
checkPgyerUpdateSilent
(
getActivity
(),
true
,
true
,
true
);
//蒲公英自动检查更新
new
PgyUpdateManager
.
Builder
()
.
setForced
(
true
)
.
setUserCanRetry
(
false
)
.
setDeleteHistroyApk
(
false
)
.
setUpdateManagerListener
(
new
UpdateManagerListener
()
{
@Override
public
void
onNoUpdateAvailable
()
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onUpdateAvailable
(
AppBean
appBean
)
{
final
String
versionName
,
updateMessage
;
versionName
=
appBean
.
getVersionName
();
updateMessage
=
appBean
.
getReleaseNote
();
builder
.
setTitle
(
getContext
().
getResources
().
getString
(
R
.
string
.
Update_Found
)
+
versionName
);
builder
.
setMessage
(
updateMessage
);
builder
.
setRightButtonText
(
R
.
string
.
Download
);
builder
.
setRightButtonListener
((
dlg
,
i
)
->
{
builder
.
showProgressBar2
();
builder
.
hideButton
();
builder
.
setTitle
(
R
.
string
.
Downloading
);
PgyUpdateManager
.
downLoadApk
(
appBean
.
getDownloadURL
());
});
builder
.
show
();
}
@Override
public
void
checkUpdateFailed
(
Exception
e
)
{
Intent
intent
=
new
Intent
();
intent
.
setAction
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
Uri
.
parse
(
"https://www.taptap.com/app/37972"
));
getContext
().
startActivity
(
intent
);
}
})
.
setDownloadFileListener
(
new
DownloadFileListener
()
{
@Override
public
void
downloadFailed
()
{
builder
.
dismiss
();
}
@Override
public
void
downloadSuccessful
(
Uri
uri
)
{
builder
.
dismiss
();
PgyUpdateManager
.
installApk
(
uri
);
}
@Override
public
void
onProgressUpdate
(
Integer
...
integers
)
{
builder
.
getProgressBar2
().
setProgress
(
integers
[
0
]);
}})
.
register
();
}
}
if
(
PREF_PENDULUM_SCALE
.
equals
(
key
))
{
if
(
PREF_PENDULUM_SCALE
.
equals
(
key
))
{
CheckBoxPreference
checkBoxPreference
=
(
CheckBoxPreference
)
preference
;
CheckBoxPreference
checkBoxPreference
=
(
CheckBoxPreference
)
preference
;
...
...
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