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
985df11d
Commit
985df11d
authored
Sep 17, 2023
by
wangfugui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
当网络问题导致无法打开原生先行卡页面时,自动切换为webview页面
parent
08670693
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
32 deletions
+45
-32
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+3
-3
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
.../java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
+23
-22
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+19
-7
No files found.
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
985df11d
...
...
@@ -277,13 +277,13 @@ public class GameUriManager {
}
else
{
YGODAUtil
.
deDeckListener
(
uri
,
(
uri1
,
mainList
,
exList
,
sideList
,
isCompleteDeck
,
exception
)
->
{
if
(!
TextUtils
.
isEmpty
(
exception
))
{
YGOUtil
.
show
(
"卡组解析失败,原因为:"
+
exception
);
YGOUtil
.
show
TextToast
(
"卡组解析失败,原因为:"
+
exception
);
return
;
}
Deck
deckInfo
=
new
Deck
(
uri
,
mainList
,
exList
,
sideList
);
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
if
(!
deckInfo
.
isCompleteDeck
())
{
YGOUtil
.
show
(
activity
.
getString
(
R
.
string
.
tip_deckInfo_isNot_completeDeck
)
);
YGOUtil
.
show
TextToast
(
"当前卡组缺少完整信息,将只显示已有卡片"
);
}
startSetting
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
activity
.
startActivity
(
startSetting
);
...
...
@@ -295,7 +295,7 @@ public class GameUriManager {
if
(
activity
instanceof
MainActivity
)
{
((
HomeActivity
)
activity
).
fragment_home
.
quickjoinRoom
(
host1
,
port
,
password
);
}
else
{
YGOUtil
.
show
(
exception
);
YGOUtil
.
show
TextToast
(
exception
);
}
});
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
View file @
985df11d
...
...
@@ -13,7 +13,6 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -50,6 +49,7 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
...
...
@@ -70,7 +70,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
private
int
FailedCount
;
/**
*
用于标志当前下载状态,用于防止用户多次重复点击“下载按钮”
*
用于标志当前下载状态,用于防止用户多次重复点击“下载按钮”
* Mark the download state, which can prevent user from clicking the download button
* repeatedly.
*/
...
...
@@ -91,7 +91,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
this
.
context
=
getContext
();
initView
(
layoutView
);
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
//
加上判断
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
//
加上判断
EventBus
.
getDefault
().
register
(
this
);
}
return
layoutView
;
...
...
@@ -100,8 +100,8 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
@Override
public
void
onStop
()
{
super
.
onStop
();
Log
.
i
(
TAG
,
"excard fragment on stop"
);
if
(
EventBus
.
getDefault
().
isRegistered
(
this
))
//
加上判断
Log
Util
.
i
(
TAG
,
"excard fragment on stop"
);
if
(
EventBus
.
getDefault
().
isRegistered
(
this
))
//
加上判断
EventBus
.
getDefault
().
unregister
(
this
);
}
...
...
@@ -123,6 +123,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
case
R
.
id
.
btn_download_prerelease
:
LogUtil
.
i
(
TAG
,
"start download"
);
if
(
downloadState
!=
DownloadState
.
DOWNLOAD_ING
)
{
downloadState
=
DownloadState
.
DOWNLOAD_ING
;
downloadfromWeb
(
URL_YGO233_FILE
);
...
...
@@ -133,11 +134,11 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
}
/**
*
根据先行卡包状态改变按钮样式
*
根据先行卡包状态改变按钮样式
*/
public
void
changeDownloadText
()
{
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UPDATED
)
{
//btn_download
展示默认视图
//btn_download
展示默认视图
textDownload
.
setText
(
R
.
string
.
tip_redownload
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
NEED_UPDATE
)
{
textDownload
.
setText
(
R
.
string
.
Download
);
...
...
@@ -164,38 +165,38 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
Toast
.
makeText
(
getActivity
(),
R
.
string
.
Ask_to_Change_Other_Way
,
Toast
.
LENGTH_SHORT
).
show
();
downloadfromWeb
(
URL_YGO233_FILE_ALT
);
}
YGOUtil
.
show
(
"error"
+
msg
.
obj
);
YGOUtil
.
show
TextToast
(
"error"
+
msg
.
obj
);
break
;
case
UnzipUtils
.
ZIP_READY
:
textDownload
.
setText
(
R
.
string
.
title_use_ex
);
break
;
case
UnzipUtils
.
ZIP_UNZIP_OK
:
/*
将先行服务器信息添加到服务器列表中 */
/*
将先行服务器信息添加到服务器列表中
*/
String
servername
=
""
;
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
0
)
servername
=
"23333
先行服务器"
;
servername
=
"23333
先行服务器
"
;
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
1
)
servername
=
"YGOPRO
사전 게시 중국서버"
;
servername
=
"YGOPRO
?? ?? ????
"
;
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
2
)
servername
=
"Mercury23333 OCG/TCG Pre-release"
;
AddServer
(
getActivity
(),
servername
,
"s1.ygo233.com"
,
23333
,
"Knight of Hanoi"
);
//changeDownloadButton();
在下载完成后,通过EventBus通知下载完成(加入用户点击下载后临时切出本fragment,又在下载完成后切回,通过eventbus能保证按钮样式正确更新
//changeDownloadButton();
在下载完成后,通过EventBus通知下载完成(加入用户点击下载后临时切出本fragment,又在下载完成后切回,通过eventbus能保证按钮样式正确更新
/*
注意,要先更新版本号 */
/*
注意,要先更新版本号
*/
SharedPreferenceUtil
.
setExpansionDataVer
(
ServerUtil
.
serverExCardVersion
);
ServerUtil
.
exCardState
=
ServerUtil
.
ExCardState
.
UPDATED
;
EventBus
.
getDefault
().
postSticky
(
new
ExCardEvent
(
ExCardEvent
.
EventType
.
exCardPackageChange
));
//
安装后,通知UI做更新
EventBus
.
getDefault
().
postSticky
(
new
ExCardEvent
(
ExCardEvent
.
EventType
.
exCardPackageChange
));
//
安装后,通知UI做更新
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
context
,
R
.
string
.
ypk_installed
,
Toast
.
LENGTH_LONG
).
show
();
Log
.
i
(
"webCrawler"
,
"Ex-card package is installed"
);
Log
Util
.
i
(
"webCrawler"
,
"Ex-card package is installed"
);
/*
如果未开启先行卡设置,则跳转到设置页面 */
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
//
解压完毕,但此时
Log
.
i
(
"webCrawler"
,
"Ex-card setting is not opened"
);
/*
如果未开启先行卡设置,则跳转到设置页面
*/
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
//
解压完毕,但此时
Log
Util
.
i
(
"webCrawler"
,
"Ex-card setting is not opened"
);
Intent
startSetting
=
new
Intent
(
context
,
MainActivity
.
class
);
startSetting
.
putExtra
(
"flag"
,
4
);
startActivity
(
startSetting
);
...
...
@@ -212,7 +213,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
// String oldVer = SharedPreferenceUtil.getExpansionDataVer();
// if (!TextUtils.isEmpty(WebActivity.exCardVer)) {
// if (!WebActivity.exCardVer.equals(oldVer)) {
// //btn_download
展示默认视图
// //btn_download
展示默认视图
// } else {
// btnDownload.setText(R.string.tip_redownload);
// }
...
...
@@ -233,7 +234,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
}
}
private
void
downloadfromWeb
(
String
fileUrl
)
{
textDownload
.
setText
(
"0%"
);
//
点击下载后,距离onDownloading触发要等几秒,这一延迟会造成软件响应慢的错觉
textDownload
.
setText
(
"0%"
);
//
点击下载后,距离onDownloading触发要等几秒,这一延迟会造成软件响应慢的错觉,因此在下载函数开始就设置文本
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()
+
"-preRlease.zip"
);
if
(
file
.
exists
())
{
FileUtils
.
deleteFile
(
file
);
...
...
@@ -255,7 +256,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
}
catch
(
Exception
e
)
{
message
.
what
=
UnzipUtils
.
ZIP_UNZIP_EXCEPTION
;
}
finally
{
message
.
what
=
UnzipUtils
.
ZIP_UNZIP_OK
;
//TODO
不对吧,finally是一定执行,这样即使有exception也会发unzip_ok啊
message
.
what
=
UnzipUtils
.
ZIP_UNZIP_OK
;
//TODO
不对吧,finally是一定执行,这样即使有exception也会发unzip_ok啊
}
handler
.
sendMessage
(
message
);
}
...
...
@@ -271,7 +272,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
@Override
public
void
onDownloadFailed
(
Exception
e
)
{
//
下载失败后删除下载的文件
//
下载失败后删除下载的文件
FileUtils
.
deleteFile
(
file
);
Message
message
=
new
Message
();
message
.
what
=
TYPE_DOWNLOAD_EXCEPTION
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
985df11d
...
...
@@ -73,6 +73,7 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
import
cn.garymb.ygomobile.ui.widget.Shimmer
;
import
cn.garymb.ygomobile.ui.widget.ShimmerTextView
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.CardManager
;
...
...
@@ -139,7 +140,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
//加上判断
EventBus
.
getDefault
().
register
(
this
);
}
ServerUtil
.
initExCardState
();
//HomeActivity中会调用一次本函数,此处再次调用
是因为有时候
HomeFragment的onCreateView()函数执行较慢,导致initExCardState()中eventbus事件发布完毕后仍未注册,因此在此处再调用一次检查,再次发布
ServerUtil
.
initExCardState
();
//HomeActivity中会调用一次本函数,此处再次调用
的原因:有时
HomeFragment的onCreateView()函数执行较慢,导致initExCardState()中eventbus事件发布完毕后仍未注册,因此在此处再调用一次检查,再次发布
changeColor
();
//showNewbieGuide("homePage");
return
layoutView
;
...
...
@@ -280,7 +281,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
* ServerUtil获取到版本状态后会通过eventmessage通知调用本函数,不需要在主函数显式调用
*/
public
void
changeExCardNewMark
()
{
Log
.
i
(
TAG
,
"check excard new mark, version:"
+
ServerUtil
.
exCardState
);
Log
Util
.
i
(
TAG
,
"check excard new mark, version:"
+
ServerUtil
.
exCardState
);
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UPDATED
)
{
ll_new_notice
.
setVisibility
(
View
.
GONE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
NEED_UPDATE
)
{
...
...
@@ -528,7 +529,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
public
void
saveDeck
(
Uri
uri
,
List
<
Integer
>
mainList
,
List
<
Integer
>
exList
,
List
<
Integer
>
sideList
,
boolean
isCompleteDeck
,
String
exception
)
{
if
(!
TextUtils
.
isEmpty
(
exception
))
{
YGOUtil
.
show
(
"卡组解析失败,原因为:"
+
exception
);
YGOUtil
.
show
TextToast
(
"卡组解析失败,原因为:"
+
exception
);
return
;
}
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
...
...
@@ -553,7 +554,9 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
deckInfo
.
setCompleteDeck
(
isCompleteDeck
);
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
if
(!
deckInfo
.
isCompleteDeck
())
{
YGOUtil
.
show
(
activity
.
getString
(
R
.
string
.
tip_deckInfo_isNot_completeDeck
));
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
tip_deckInfo_isNot_completeDeck
));
}
if
(!
file
.
getAbsolutePath
().
isEmpty
())
{
mBundle
.
putString
(
"setDeck"
,
file
.
getAbsolutePath
());
...
...
@@ -723,13 +726,22 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
getFragmentManager
().
beginTransaction
().
remove
(
activity
.
fragment_deck_cards
).
commit
();
break
;
case
R
.
id
.
action_download_ex
:
/*不检查先行卡设置,无论是否开启先行卡都要求能够打开先行卡页面,因此注释掉下面代码*/
// if (!AppsSettings.get().isReadExpansions()) {//如果未开启扩展卡设置,直接跳过
// Toast.makeText(getActivity(), R.string.ypk_go_setting, Toast.LENGTH_LONG).show();
// break;
// }
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
WebActivity
.
open
(
getContext
(),
getString
(
R
.
string
.
action_download_expansions
),
Constants
.
URL_YGO233_ADVANCE
);
LogUtil
.
i
(
TAG
,
"cannot connect to ex card server, open webactivity"
);
}
else
{
/* using Web crawler to extract the information of pre card */
LogUtil
.
i
(
TAG
,
"connect to ex card http server, open webactivity"
);
Intent
exCardIntent
=
new
Intent
(
getActivity
(),
ExCardActivity
.
class
);
startActivity
(
exCardIntent
);
}
break
;
case
R
.
id
.
action_help
:
{
final
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
...
...
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