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
d336a4a7
Commit
d336a4a7
authored
Sep 21, 2023
by
wangfugui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加注释,调整工程文件编码,统一为utf-8
parent
a291d0ac
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
121 additions
and
53 deletions
+121
-53
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+12
-1
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+9
-3
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
...ain/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
+5
-1
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
.../java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
+5
-14
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExPackageTabAdapter.java
...java/cn/garymb/ygomobile/ex_card/ExPackageTabAdapter.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
.../src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
+1
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardFavorites.java
...main/java/cn/garymb/ygomobile/ui/cards/CardFavorites.java
+12
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+1
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+5
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
+3
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+22
-8
mobile/src/main/java/cn/garymb/ygomobile/utils/BitmapUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/BitmapUtil.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
+11
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
+10
-5
mobile/src/main/java/ocgcore/CardManager.java
mobile/src/main/java/ocgcore/CardManager.java
+5
-1
mobile/src/main/java/ocgcore/DataManager.java
mobile/src/main/java/ocgcore/DataManager.java
+8
-5
mobile/src/main/java/ocgcore/LimitManager.java
mobile/src/main/java/ocgcore/LimitManager.java
+8
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
d336a4a7
...
...
@@ -23,12 +23,15 @@ import android.widget.Toast;
import
com.ourygo.lib.duelassistant.util.YGODAUtil
;
import
org.greenrobot.eventbus.EventBus
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.util.Locale
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.bean.Deck
;
import
cn.garymb.ygomobile.bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.home.HomeActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
...
...
@@ -51,6 +54,12 @@ public class GameUriManager {
stringManager
=
new
StringManager
();
}
/**
* 根据intent的getData()和getXXXExtra()执行逻辑,
*
* @param intent
* @return false当传入的intent.getAction()不符合可处理的action时,不做处理,返回false
*/
public
boolean
doIntent
(
Intent
intent
)
{
Log
.
i
(
Constants
.
TAG
,
"doIntent"
);
if
(
ACTION_OPEN_DECK
.
equals
(
intent
.
getAction
()))
{
...
...
@@ -225,12 +234,14 @@ public class GameUriManager {
}
else
if
(
isYpk
)
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
startSetting
.
putExtra
(
"flag"
,
4
);
activity
.
startActivity
(
startSetting
);
activity
.
startActivity
(
startSetting
);
//todo ??再次打开MainActivity?
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_installed
,
Toast
.
LENGTH_LONG
).
show
();
loadServerInfoFromZipOrYpk
(
getActivity
(),
file
);
//ypk不与excard机制相干涉
}
}
else
if
(
isYrp
)
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
()))
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
d336a4a7
...
...
@@ -107,6 +107,12 @@ public class YGOStarter {
quitFullScreen
(
activity
,
activityShowInfo
);
}
/**
* 对添加用于展示的相关信息
*
* @param activity
* @return
*/
public
static
ActivityShowInfo
onCreated
(
Activity
activity
)
{
ActivityShowInfo
activityShowInfo
=
Infos
.
get
(
activity
);
if
(
activityShowInfo
==
null
)
{
...
...
@@ -157,11 +163,10 @@ public class YGOStarter {
private
static
long
lasttime
=
0
;
/**
*
* @param activity
* @param options
* @param args 例如(播放完退出游戏):-r 1111.yrp
* 或者(播放完不退出游戏):-k -r 1111.yrp
* @param args
例如(播放完退出游戏):-r 1111.yrp
*
或者(播放完不退出游戏):-k -r 1111.yrp
*/
public
static
void
startGame
(
Activity
activity
,
YGOGameOptions
options
,
String
...
args
)
{
//如果距离上次加入游戏的时间大于1秒才处理
...
...
@@ -184,6 +189,7 @@ public class YGOStarter {
Log
.
e
(
TAG
,
"跳转后"
+
System
.
currentTimeMillis
());
}
/* 维护activity的用于展示的相关信息 */
private
static
final
HashMap
<
Activity
,
ActivityShowInfo
>
Infos
=
new
HashMap
<>();
private
static
class
ActivityShowInfo
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
View file @
d336a4a7
package
cn.garymb.ygomobile.bean.events
;
/**
* 用于EventBus发布的时间类型。
*/
public
class
ExCardEvent
{
public
enum
EventType
{
exCardPackageChange
,
exCardPrefChange
exCardPackageChange
,
//扩展卡包变化
exCardPrefChange
//扩展卡设置变化
}
private
EventType
eventType
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
View file @
d336a4a7
package
cn.garymb.ygomobile.ex_card
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSET_SERVER_LIST
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_ADVANCE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE_ALT
;
...
...
@@ -30,31 +29,18 @@ import org.greenrobot.eventbus.Subscribe;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.ServerInfo
;
import
cn.garymb.ygomobile.bean.ServerList
;
import
cn.garymb.ygomobile.bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.ServerListManager
;
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
;
import
cn.garymb.ygomobile.utils.UnzipUtils
;
import
cn.garymb.ygomobile.utils.XmlUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.DataManager
;
...
...
@@ -145,6 +131,10 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_iii
,
Toast
.
LENGTH_LONG
).
show
();
WebActivity
.
open
(
getActivity
(),
getString
(
R
.
string
.
ex_card_list_title
),
URL_YGO233_ADVANCE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
)
{
//do nothing
//状态UNCHECKED仅在app启动后调用哦你Create()之前短暂存在,所以该情况进行处理
//the UNCHECKED state only exists temporarily before the check action, so we need not handle it.
}
}
//TODO eventbus receive event
...
...
@@ -233,6 +223,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
changeDownloadText
();
}
}
private
void
downloadfromWeb
(
String
fileUrl
)
{
textDownload
.
setText
(
"0%"
);
//点击下载后,距离onDownloading触发要等几秒,这一延迟会造成软件响应慢的错觉,因此在下载函数开始就设置文本
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()
+
"-preRlease.zip"
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExPackageTabAdapter.java
View file @
d336a4a7
...
...
@@ -11,11 +11,11 @@ import com.google.android.material.tabs.TabLayout;
import
cn.garymb.ygomobile.lite.R
;
/**
*
先行卡相关Fragment的Tab的适配器,用来实现页面切换
*
先行卡相关Fragment的Tab的适配器,用来实现页面切换
*/
public
class
ExPackageTabAdapter
extends
FragmentStatePagerAdapter
{
TabLayout
tabLayout
;
/*
仅用于获取strings.xml中的字符串。I
t's used just for getting strings from strings.xml */
/*
仅用于获取strings.xml中的字符串。It's
used just for getting strings from strings.xml */
Context
context
;
public
ExPackageTabAdapter
(
FragmentManager
fm
,
TabLayout
_tabLayout
,
Context
context
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
View file @
d336a4a7
...
...
@@ -28,8 +28,7 @@ import ocgcore.enums.LimitType;
/**
* 包括LimitManager、CardManager、LimitList
* LimitList负责判断禁止卡等
*
*
* field包括LimitManager、CardManager
*/
public
class
CardLoader
implements
ICardSearcher
{
private
final
LimitManager
mLimitManager
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardFavorites.java
View file @
d336a4a7
...
...
@@ -14,6 +14,9 @@ import cn.garymb.ygomobile.loader.ICardSearcher;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
ocgcore.data.Card
;
/**
* 静态类,
*/
public
class
CardFavorites
{
private
final
List
<
Integer
>
mList
=
new
ArrayList
<>();
private
static
final
String
TAG
=
"CardFavorites"
;
...
...
@@ -55,6 +58,12 @@ public class CardFavorites {
return
mList
;
}
/**
* 从cardLoader查询收藏的卡片
*
* @param cardLoader
* @return 排序后的列表
*/
public
List
<
Card
>
getCards
(
ICardSearcher
cardLoader
)
{
SparseArray
<
Card
>
id
=
cardLoader
.
readCards
(
mList
,
false
);
List
<
Card
>
list
=
new
ArrayList
<>();
...
...
@@ -89,6 +98,9 @@ public class CardFavorites {
Log
.
d
(
TAG
,
"load favorites success:"
+
mList
.
size
());
}
/**
* 将卡片收藏保存到sharedStorage中
*/
public
void
save
()
{
List
<
String
>
ret
=
new
ArrayList
<>();
if
(!
mList
.
isEmpty
())
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
d336a4a7
...
...
@@ -26,13 +26,8 @@ import com.tencent.smtt.export.external.TbsCoreSettings;
import
com.tencent.smtt.sdk.QbSdk
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.StringReader
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -141,7 +136,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
//showNewbieGuide("homePage");
initBottomNavigationBar
();
onNewIntent
(
getIntent
());
ServerUtil
.
initExCardState
();
//检查扩展卡版本
ServerUtil
.
initExCardState
();
//检查扩展卡版本
todo 移动到LogoActivity中
}
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
d336a4a7
...
...
@@ -289,6 +289,10 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_iii
,
Toast
.
LENGTH_SHORT
).
show
();
ll_new_notice
.
setVisibility
(
View
.
GONE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
)
{
//do nothing
//由于UNCHECKED状态仅在app刚启动时短暂存在,因此不需要对其进行处理
//the UNCHECKED state only exists temporarily before the check action, so we need not handle it.
}
}
...
...
@@ -776,7 +780,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
break
;
case
R
.
id
.
add_server
:
mServerListManager
.
addServer
();
break
;
break
;
case
R
.
id
.
tv_banner_loading
:
if
(
isMcNewsLoadException
)
findMcNews
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
View file @
d336a4a7
...
...
@@ -69,6 +69,9 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
}
/**
* 资源复制
*/
private
void
checkRes
()
{
checkResourceDownload
((
error
,
isNew
)
->
{
//加载收藏夹
...
...
@@ -210,7 +213,6 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
Constants
.
REQUEST_SETTINGS_CODE
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
d336a4a7
...
...
@@ -30,11 +30,13 @@ import java.io.IOException;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings.languageEnum
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
libwindbot.windbot.WindBot
;
import
ocgcore.CardManager
;
...
...
@@ -151,12 +153,15 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
mContext
.
unregisterReceiver
(
mReceiver
);
}
/**
* 查询sharedPreference中的版本号和package的版本号,比较后得出是否需要更新,将结果存入isNewVersion。
*/
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
dialog
=
DialogPlus
.
show
(
mContext
,
null
,
mContext
.
getString
(
R
.
string
.
check_res
));
int
vercode
=
SystemUtils
.
getVersion
(
mContext
);
if
(
mSettings
.
getAppVersion
()
<
vercode
)
{
if
(
mSettings
.
getAppVersion
()
<
vercode
)
{
//刚安装app时,mSettings.getAppVersion()返回值为0
mSettings
.
setAppVersion
(
vercode
);
isNewVersion
=
true
;
}
else
{
...
...
@@ -186,6 +191,13 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
});
}
/**
* 清除下载缓存
* 如果是新安装ygomobile,则将资源文件从assets拷贝到游戏目录中。游戏目录为app-specific external storage
*
* @param params The parameters of the task.
* @return
*/
@Override
protected
Integer
doInBackground
(
Void
...
params
)
{
Log
.
d
(
TAG
,
"check start"
);
...
...
@@ -214,12 +226,13 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
checkDirs
();
if
(
mSettings
.
isUseExtraCards
())
{
//自定义数据库无效,则用默认的
if
(!
CardManager
.
checkDataBase
(
mSettings
.
getData
B
aseFile
()))
{
if
(!
CardManager
.
checkDataBase
(
mSettings
.
getData
b
aseFile
()))
{
mSettings
.
setUseExtraCards
(
false
);
}
}
//如果是新版本
if
(
needsUpdate
)
{
LogUtil
.
i
(
TAG
,
"needsUpdate"
);
//复制卡组
File
deckFiles
=
new
File
(
mSettings
.
getDeckDir
());
if
(
deckFiles
.
list
().
length
==
0
)
{
...
...
@@ -277,24 +290,25 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
String
language
=
mContext
.
getResources
().
getConfiguration
().
locale
.
getLanguage
();
if
(!
language
.
isEmpty
())
{
if
(
mSettings
.
getDataLanguage
()
==
-
1
)
{
if
(
language
.
equals
(
"zh"
))
{
if
(
language
.
equals
(
languageEnum
.
Chinese
.
name
))
{
copyCnData
(
true
);
}
else
if
(
language
.
equals
(
"ko"
))
{
}
else
if
(
language
.
equals
(
languageEnum
.
Korean
.
name
))
{
copyKorData
(
true
);
}
else
{
copyEnData
(
true
);
}
}
else
{
if
(
mSettings
.
getDataLanguage
()
==
0
)
copyCnData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
1
)
copyKorData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
2
)
copyEnData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
languageEnum
.
Chinese
.
code
)
copyCnData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
languageEnum
.
Korean
.
code
)
copyKorData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
languageEnum
.
English
.
code
)
copyEnData
(
true
);
}
}
han
.
sendEmptyMessage
(
0
);
loadData
();
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"ERROR COPY"
,
e
);
Log
.
e
(
TAG
,
"ERROR COPY"
,
e
);
return
ERROR_COPY
;
}
return
ERROR_NONE
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/BitmapUtil.java
View file @
d336a4a7
...
...
@@ -226,8 +226,8 @@ public class BitmapUtil {
return
bitmap
;
}
public
static
Paint
getPaint
(
int
saturation
){
Paint
mPaint
=
new
Paint
();
public
static
Paint
getPaint
(
int
saturation
)
{
Paint
mPaint
=
new
Paint
();
ColorMatrix
cm
=
new
ColorMatrix
();
cm
.
setSaturation
(
saturation
);
mPaint
.
setColorFilter
(
new
ColorMatrixColorFilter
(
cm
));
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
View file @
d336a4a7
...
...
@@ -103,6 +103,9 @@ public class IOUtils {
return
new
File
(
path
).
getName
();
}
/**
* 将文件从工程的assets文件夹拷贝到目录中
*/
public
static
int
copyFilesFromAssets
(
Context
context
,
String
assets
,
String
toPath
,
boolean
update
)
throws
IOException
{
AssetManager
am
=
context
.
getAssets
();
String
[]
files
=
am
.
list
(
assets
);
...
...
@@ -162,8 +165,15 @@ public class IOUtils {
createFolder
(
file
.
getParentFile
());
}
/**
* 根据file创建目录,如果file指向的目录已存在,则直接返回true。
* 创建失败时返回false。
* 创建成功时返回true
* @param file
* @return
*/
public
static
boolean
createFolder
(
@Nullable
File
file
)
{
if
(
file
==
null
)
{
if
(
file
==
null
)
{
return
false
;
}
if
(!
file
.
exists
())
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
View file @
d336a4a7
...
...
@@ -37,8 +37,14 @@ import okhttp3.Response;
public
class
ServerUtil
{
private
static
final
String
TAG
=
ServerUtil
.
class
.
getSimpleName
();
public
enum
ExCardState
{
/* 已安装最新版扩展卡,扩展卡不是最新版本,无法查询到服务器版本 */
UNCHECKED
,
UPDATED
,
NEED_UPDATE
,
ERROR
}
/* 存储了当前先行卡是否需要更新的状态,UI逻辑直接读取该变量就能获知是否已安装先行卡 */
public
volatile
static
ExCardState
exCardState
=
ExCardState
.
ERROR
;
//TODO 可能有并发问题
public
volatile
static
ExCardState
exCardState
=
ExCardState
.
UNCHECKED
;
//TODO 可能有并发问题
public
volatile
static
String
serverExCardVersion
=
""
;
private
volatile
static
int
failCounter
=
0
;
...
...
@@ -122,9 +128,12 @@ public class ServerUtil {
}
if
(
serverName
!=
null
&&
(
isHost
(
serverHost
)
||
isValidIP
(
serverHost
))
&&
isNumeric
(
serverPort
))
{
AddServer
(
context
,
serverName
,
serverHost
,
Integer
.
valueOf
(
serverPort
),
"Knight of Hanoi"
);
}
else
{
YGOUtil
.
showTextToast
(
"can't parse ex-server properly"
);
}
LogUtil
.
w
(
"看看"
,
serverName
+
isHost
(
serverHost
)
+
serverHost
+
isNumeric
(
serverPort
)
+
serverPort
);
zipFile
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -202,8 +211,4 @@ public class ServerUtil {
}
public
enum
ExCardState
{
/* 已安装最新版扩展卡,扩展卡不是最新版本,无法查询到服务器版本 */
UPDATED
,
NEED_UPDATE
,
ERROR
}
}
mobile/src/main/java/ocgcore/CardManager.java
View file @
d336a4a7
...
...
@@ -134,10 +134,14 @@ public class CardManager {
return
cardDataHashMap
;
}
/**
* 清空cardDataHashMap,之后从cdb文件读取卡牌,到cardDataHashMap
* 如果开启了先行卡,
*/
@WorkerThread
public
void
loadCards
()
{
cardDataHashMap
.
clear
();
int
count
=
readAllCards
(
AppsSettings
.
get
().
getData
B
aseFile
(),
cardDataHashMap
);
int
count
=
readAllCards
(
AppsSettings
.
get
().
getData
b
aseFile
(),
cardDataHashMap
);
Log
.
i
(
TAG
,
"load defualt cdb:"
+
count
);
if
(!
TextUtils
.
isEmpty
(
exDbPath
))
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
...
...
mobile/src/main/java/ocgcore/DataManager.java
View file @
d336a4a7
package
ocgcore
;
import
org.greenrobot.eventbus.EventBus
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.
ex_card.ExCardListAdapter
;
import
cn.garymb.ygomobile.
bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.loader.CardLoader
;
/**
* 单例模式,使用get()方式自动获取单例
* 单例模式,使用get()方式自动获取单例
* 其field包括StringManager、LimitManager、CardManager
*/
public
class
DataManager
{
private
static
DataManager
sLoader
=
null
;
private
static
final
String
TAG
=
String
.
valueOf
(
DataManager
.
class
);
public
static
DataManager
get
()
{
if
(
sLoader
!=
null
)
{
return
sLoader
;
...
...
@@ -50,8 +54,7 @@ public class DataManager {
private
boolean
mInit
;
public
void
load
(
boolean
force
)
{
//Log.i("webCrawler", "DataManager load data");
//LogUtil.i("webCrawler", "DataManager load data");
boolean
needLoad
=
false
;
synchronized
(
this
)
{
if
(!
mInit
||
force
)
{
...
...
@@ -59,7 +62,7 @@ public class DataManager {
}
mInit
=
true
;
}
if
(
needLoad
)
{
if
(
needLoad
)
{
mStringManager
.
load
();
mLimitManager
.
load
();
mCardManager
.
loadCards
();
...
...
mobile/src/main/java/ocgcore/LimitManager.java
View file @
d336a4a7
...
...
@@ -22,7 +22,9 @@ import cn.garymb.ygomobile.utils.IOUtils;
import
ocgcore.data.LimitList
;
public
class
LimitManager
implements
Closeable
{
/* key为时间,如“2023.7” ,value为禁止卡、限制卡、准限制卡的列表 */
private
final
Map
<
String
,
LimitList
>
mLimitLists
=
new
HashMap
<>();
/* 只存储key的列表,其元素形如“2023.7” */
private
final
List
<
String
>
mLimitNames
=
new
ArrayList
<>();
private
int
mCount
;
...
...
@@ -74,6 +76,12 @@ public class LimitManager implements Closeable {
return
rs1
&&
rs2
;
}
/**
* 解析限制卡配置文件lflist.conf的内容
*
* @param file
* @return
*/
public
boolean
loadFile
(
File
file
)
{
if
(
file
.
isDirectory
()
||
!
file
.
exists
())
{
return
false
;
...
...
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