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
236060f9
Commit
236060f9
authored
Oct 18, 2022
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
home启动时检查更新
parent
9d8086b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
28 deletions
+72
-28
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+49
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
...java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
+23
-27
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
236060f9
...
...
@@ -2,6 +2,7 @@ package cn.garymb.ygomobile.ui.home;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSET_SERVER_LIST
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_DATAVER
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_DOWNLOAD_LINK
;
import
android.annotation.SuppressLint
;
import
android.content.Intent
;
...
...
@@ -39,6 +40,7 @@ import com.ourygo.assistant.util.Util;
import
com.stx.xhb.androidx.XBanner
;
import
com.tubb.smrv.SwipeMenuRecyclerView
;
import
org.apache.commons.lang3.StringUtils
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
...
...
@@ -95,6 +97,9 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
private
static
final
int
TYPE_BANNER_QUERY_EXCEPTION
=
1
;
private
static
final
int
TYPE_RES_LOADING_OK
=
2
;
private
static
final
int
TYPE_GET_DATA_VER_OK
=
3
;
private
static
final
int
TYPE_GET_VERSION_OK
=
4
;
private
static
final
int
TYPE_GET_VERSION_FAILED
=
5
;
public
static
String
Version
;
private
static
final
String
ARG_MC_NEWS_LIST
=
"mcNewsList"
;
private
boolean
isMcNewsLoadException
=
false
;
...
...
@@ -146,6 +151,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
//加上判断
EventBus
.
getDefault
().
register
(
this
);
}
checkUpgrade
();
showExNew
();
//showNewbieGuide("homePage");
return
layoutView
;
...
...
@@ -273,7 +279,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
WebActivity
.
dataVer
=
msg
.
obj
.
toString
();
String
oldVer
=
SharedPreferenceUtil
.
getExpansionDataVer
();
if
(!
TextUtils
.
isEmpty
(
WebActivity
.
dataVer
))
{
if
(!
WebActivity
.
dataVer
.
equals
(
oldVer
))
{
if
(!
WebActivity
.
dataVer
.
equals
(
oldVer
))
{
ll_new_notice
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
ll_new_notice
.
setVisibility
(
View
.
GONE
);
...
...
@@ -282,6 +288,26 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
showExNew
();
ll_new_notice
.
setVisibility
(
View
.
GONE
);
}
case
TYPE_GET_VERSION_OK:
Version
=
msg
.
obj
.
toString
();
Log
.
i
(
BuildConfig
.
VERSION_NAME
,
Version
);
if
(!
Version
.
equals
(
BuildConfig
.
VERSION_NAME
))
{
DialogPlus
dialog
=
new
DialogPlus
(
getActivity
());
dialog
.
setMessage
(
R
.
string
.
Found_Update
);
dialog
.
setLeftButtonText
(
R
.
string
.
download_home
);
dialog
.
setLeftButtonListener
((
dlg
,
s
)
->
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
Uri
.
parse
(
"https://netdisk.link/YGOMobile_"
+
Version
+
".apk/links"
));
startActivity
(
intent
);
dialog
.
dismiss
();
});
dialog
.
show
();
}
break
;
case
TYPE_GET_VERSION_FAILED:
String
error
=
msg
.
obj
.
toString
();
Log
.
e
(
BuildConfig
.
VERSION_NAME
,
error
);
break
;
}
}
...
...
@@ -307,6 +333,28 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
}
}
public
void
checkUpgrade
()
{
OkhttpUtil
.
get
(
URL_YGO233_DOWNLOAD_LINK
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_GET_VERSION_FAILED
;
message
.
obj
=
e
;
handler
.
sendMessage
(
message
);
Log
.
i
(
BuildConfig
.
VERSION_NAME
,
"error"
+
e
);
}
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
String
json
=
response
.
body
().
string
();
Message
message
=
new
Message
();
message
.
what
=
TYPE_GET_VERSION_OK
;
message
.
obj
=
StringUtils
.
substringBetween
(
json
,
"https://netdisk.link/YGOMobile_"
,
".apk/links"
);
handler
.
sendMessage
(
message
);
}
});
}
private
void
findMcNews
()
{
isMcNewsLoadException
=
false
;
tv_banner_loading
.
setVisibility
(
View
.
VISIBLE
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
View file @
236060f9
...
...
@@ -90,8 +90,8 @@ import okhttp3.Callback;
import
okhttp3.Response
;
public
class
SettingFragment
extends
PreferenceFragmentPlus
{
private
static
final
int
TYPE_GET_VERSION_OK
=
0
;
private
static
final
int
TYPE_GET_VERSION_FAILED
=
1
;
private
static
final
int
TYPE_
SETTING_
GET_VERSION_OK
=
0
;
private
static
final
int
TYPE_
SETTING_
GET_VERSION_FAILED
=
1
;
private
AppsSettings
mSettings
;
public
static
String
Version
;
private
boolean
isInit
=
true
;
...
...
@@ -106,7 +106,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_GET_VERSION_OK:
case
TYPE_
SETTING_
GET_VERSION_OK:
Version
=
msg
.
obj
.
toString
();
Log
.
i
(
BuildConfig
.
VERSION_NAME
,
Version
);
if
(!
Version
.
equals
(
BuildConfig
.
VERSION_NAME
))
{
...
...
@@ -124,7 +124,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
case
TYPE_GET_VERSION_FAILED:
case
TYPE_
SETTING_
GET_VERSION_FAILED:
String
error
=
msg
.
obj
.
toString
();
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
error
,
Toast
.
LENGTH_SHORT
).
show
();
break
;
...
...
@@ -253,7 +253,25 @@ public class SettingFragment extends PreferenceFragmentPlus {
joinQQGroup
(
groupkey
);
}
if
(
PREF_CHECK_UPDATE
.
equals
(
key
))
{
checkUpgrade
();
OkhttpUtil
.
get
(
URL_YGO233_DOWNLOAD_LINK
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_SETTING_GET_VERSION_FAILED
;
message
.
obj
=
e
;
handler
.
sendMessage
(
message
);
Log
.
i
(
BuildConfig
.
VERSION_NAME
,
"error"
+
e
);
}
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
String
json
=
response
.
body
().
string
();
Message
message
=
new
Message
();
message
.
what
=
TYPE_SETTING_GET_VERSION_OK
;
message
.
obj
=
StringUtils
.
substringBetween
(
json
,
"https://netdisk.link/YGOMobile_"
,
".apk/links"
);
handler
.
sendMessage
(
message
);
}
});
}
if
(
PREF_DEL_EX
.
equals
(
key
))
{
File
[]
ypks
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
().
getAbsolutePath
()).
listFiles
();
...
...
@@ -588,28 +606,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
});
}
public
void
checkUpgrade
(){
OkhttpUtil
.
get
(
URL_YGO233_DOWNLOAD_LINK
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_GET_VERSION_FAILED
;
message
.
obj
=
e
;
handler
.
sendMessage
(
message
);
Log
.
i
(
BuildConfig
.
VERSION_NAME
,
"error"
+
e
);
}
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
String
json
=
response
.
body
().
string
();
Message
message
=
new
Message
();
message
.
what
=
TYPE_GET_VERSION_OK
;
message
.
obj
=
StringUtils
.
substringBetween
(
json
,
"https://netdisk.link/YGOMobile_"
,
".apk/links"
);
handler
.
sendMessage
(
message
);
}
});
}
public
boolean
joinQQGroup
(
String
key
)
{
Intent
intent
=
new
Intent
();
intent
.
setData
(
Uri
.
parse
(
"mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D"
+
key
));
...
...
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