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
14d6c183
Commit
14d6c183
authored
Sep 26, 2023
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加识别字符进行substring
parent
f79bd774
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
72 deletions
+75
-72
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+5
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+23
-22
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
...java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
+47
-48
No files found.
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
14d6c183
...
@@ -156,8 +156,11 @@ public interface Constants {
...
@@ -156,8 +156,11 @@ public interface Constants {
String
URL_DONATE
=
"https://afdian.net/@ygomobile"
;
String
URL_DONATE
=
"https://afdian.net/@ygomobile"
;
String
URL_MASTER_RULE_CN
=
"https://ocg-rule.readthedocs.io/"
;
String
URL_MASTER_RULE_CN
=
"https://ocg-rule.readthedocs.io/"
;
String
WIKI_SEARCH_URL
=
"https://ygocdb.com/card/"
;
String
WIKI_SEARCH_URL
=
"https://ygocdb.com/card/"
;
String
URL_HOME_VERSION
=
"https://ygomobile.top/version.txt"
;
String
URL_HOME_VERSION
=
"https://ygomobile.top/ver_code.txt"
;
String
URL_HOME_VERSION_ALT
=
"https://ygom.top/version.txt"
;
String
URL_HOME_VERSION_ALT
=
"https://ygom.top/ver_code.txt"
;
String
ID1
=
"[versionname]"
;
String
ID2
=
"[download_link]"
;
String
ID3
=
"#pre_release_code"
;
String
URL_YGO233_DOWNLOAD_LINK
=
"https://ygo233.com/download/ygomobile"
;
String
URL_YGO233_DOWNLOAD_LINK
=
"https://ygo233.com/download/ygomobile"
;
String
URL_YGO233_ADVANCE
=
"https://ygo233.com/pre"
;
String
URL_YGO233_ADVANCE
=
"https://ygo233.com/pre"
;
String
URL_YGO233_DATAVER
=
"https://ygo233.com/pre/dataver"
;
String
URL_YGO233_DATAVER
=
"https://ygo233.com/pre/dataver"
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
14d6c183
package
cn.garymb.ygomobile.ui.home
;
package
cn.garymb.ygomobile.ui.home
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ID1
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ID2
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ID3
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION_ALT
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION_ALT
;
...
@@ -160,17 +163,30 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
...
@@ -160,17 +163,30 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
mFragment
=
fragment_home
;
mFragment
=
fragment_home
;
getSupportFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
fragment_content
,
fragment_home
).
commit
();
getSupportFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
fragment_content
,
fragment_home
).
commit
();
getSupportActionBar
().
hide
();
getSupportActionBar
().
hide
();
}
@SuppressLint
(
"HandlerLeak"
)
}
private
void
showNewsCounts
()
{
mTextBadgeItem
=
new
TextBadgeItem
()
.
setBorderWidth
(
4
)
//文本大小
.
setGravity
(
Gravity
.
LEFT
)
//位置 默认右上
.
setBackgroundColorResource
(
R
.
color
.
holo_orange_bright
)
//背景颜色
.
setAnimationDuration
(
200
)
//动画时间
.
setText
(
"3"
)
.
setHideOnSelect
(
false
)
//true当选中状态时消失,非选中状态再次显示
.
show
();
}
@SuppressLint
(
"HandlerLeak"
)
Handler
handlerHome
=
new
Handler
()
{
Handler
handlerHome
=
new
Handler
()
{
@Override
@Override
public
void
handleMessage
(
Message
msg
)
{
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
switch
(
msg
.
what
)
{
case
TYPE_GET_VERSION_OK:
case
TYPE_GET_VERSION_OK:
if
(
msg
.
obj
.
toString
().
contains
(
"|"
)
&&
msg
.
obj
.
toString
().
contains
(
"\n"
))
{
if
(
msg
.
obj
.
toString
().
contains
(
ID1
)
&&
msg
.
obj
.
toString
().
contains
(
ID2
)
&&
msg
.
obj
.
toString
().
contains
(
ID3
))
{
Version
=
msg
.
obj
.
toString
().
substring
(
0
,
msg
.
obj
.
toString
().
indexOf
(
"|
"
));
//截取版本号
Version
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
ID1
)
+
ID1
.
length
(),
msg
.
obj
.
toString
().
indexOf
(
";
"
));
//截取版本号
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"|"
)
+
1
,
msg
.
obj
.
toString
().
indexOf
(
"\n
"
));
//截取下载地址
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
ID2
)
+
ID2
.
length
(),
msg
.
obj
.
toString
().
indexOf
(
"$
"
));
//截取下载地址
Cache_pre_release_code
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"\n"
)
+
1
);
//截取先行-正式对照文本
Cache_pre_release_code
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
ID3
)
+
ID3
.
length
(
)
+
1
);
//截取先行-正式对照文本
if
(!
TextUtils
.
isEmpty
(
Cache_pre_release_code
))
{
if
(!
TextUtils
.
isEmpty
(
Cache_pre_release_code
))
{
arrangeCodeList
(
Cache_pre_release_code
);
//转换成两个数组
arrangeCodeList
(
Cache_pre_release_code
);
//转换成两个数组
}
}
...
@@ -186,16 +202,12 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
...
@@ -186,16 +202,12 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
});
});
dialog
.
show
();
dialog
.
show
();
}
}
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
}
}
break
;
break
;
case
TYPE_GET_VERSION_FAILED:
case
TYPE_GET_VERSION_FAILED:
++
FailedCount
;
++
FailedCount
;
if
(
FailedCount
<=
2
)
{
if
(
FailedCount
<=
2
)
{
checkUpgrade
(
URL_HOME_VERSION_ALT
);
checkUpgrade
(
URL_HOME_VERSION_ALT
);
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
}
}
break
;
break
;
}
}
...
@@ -203,17 +215,6 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
...
@@ -203,17 +215,6 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
}
}
};
};
private
void
showNewsCounts
()
{
mTextBadgeItem
=
new
TextBadgeItem
()
.
setBorderWidth
(
4
)
//文本大小
.
setGravity
(
Gravity
.
LEFT
)
//位置 默认右上
.
setBackgroundColorResource
(
R
.
color
.
holo_orange_bright
)
//背景颜色
.
setAnimationDuration
(
200
)
//动画时间
.
setText
(
"3"
)
.
setHideOnSelect
(
false
)
//true当选中状态时消失,非选中状态再次显示
.
show
();
}
@Override
@Override
public
void
onTabSelected
(
int
position
)
{
public
void
onTabSelected
(
int
position
)
{
switch
(
position
)
{
switch
(
position
)
{
...
@@ -412,6 +413,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
...
@@ -412,6 +413,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
@Override
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
String
json
=
response
.
body
().
string
();
String
json
=
response
.
body
().
string
();
Log
.
e
(
"seesee"
,
json
);
Message
message
=
new
Message
();
Message
message
=
new
Message
();
message
.
what
=
TYPE_GET_VERSION_OK
;
message
.
what
=
TYPE_GET_VERSION_OK
;
message
.
obj
=
json
;
message
.
obj
=
json
;
...
@@ -425,7 +427,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
...
@@ -425,7 +427,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
try
{
try
{
String
line
;
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
while
((
line
=
br
.
readLine
())
!=
null
)
{
String
[]
words
=
line
.
trim
().
split
(
"[ ]+"
);
String
[]
words
=
line
.
trim
().
split
(
"[
\t
]+"
);
pre_code_list
.
add
(
Integer
.
valueOf
(
words
[
0
]));
pre_code_list
.
add
(
Integer
.
valueOf
(
words
[
0
]));
released_code_list
.
add
(
Integer
.
valueOf
(
words
[
1
]));
released_code_list
.
add
(
Integer
.
valueOf
(
words
[
1
]));
...
@@ -433,7 +435,6 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
...
@@ -433,7 +435,6 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
Constants
.
TAG
,
e
+
""
);
Log
.
e
(
Constants
.
TAG
,
e
+
""
);
}
finally
{
}
finally
{
}
}
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
View file @
14d6c183
...
@@ -4,6 +4,9 @@ import static cn.garymb.ygomobile.Constants.ACTION_RELOAD;
...
@@ -4,6 +4,9 @@ import static cn.garymb.ygomobile.Constants.ACTION_RELOAD;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_AVATAR_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_AVATAR_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_BG_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_BG_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_CARD_COVER_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SKIN_CARD_COVER_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ID1
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ID2
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ID3
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_PICS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_PICS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_REPLAY
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_REPLAY
;
...
@@ -89,7 +92,6 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
...
@@ -89,7 +92,6 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
...
@@ -161,52 +163,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -161,52 +163,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
isInit
=
false
;
isInit
=
false
;
}
}
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_SETTING_GET_VERSION_OK:
if
(
msg
.
obj
.
toString
().
contains
(
"|"
)
&&
msg
.
obj
.
toString
().
contains
(
"\n"
))
{
Version
=
msg
.
obj
.
toString
().
substring
(
0
,
msg
.
obj
.
toString
().
indexOf
(
"|"
));
//截取版本号
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"|"
)
+
1
,
msg
.
obj
.
toString
().
indexOf
(
"\n"
));
//截取下载地址
Cache_pre_release_code
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
"\n"
)
+
1
);
//截取先行-正式对照文本
if
(!
TextUtils
.
isEmpty
(
Cache_pre_release_code
))
{
arrangeCodeList
(
Cache_pre_release_code
);
//转换成两个数组
}
if
(!
Version
.
equals
(
BuildConfig
.
VERSION_NAME
)
&&
!
TextUtils
.
isEmpty
(
Version
)
&&
!
TextUtils
.
isEmpty
(
Cache_link
))
{
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
(
Cache_link
));
startActivity
(
intent
);
dialog
.
dismiss
();
});
dialog
.
show
();
}
else
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
case
TYPE_SETTING_GET_VERSION_FAILED:
++
FailedCount
;
if
(
FailedCount
<=
2
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
Ask_to_Change_Other_Way
,
Toast
.
LENGTH_SHORT
).
show
();
checkUpgrade
(
URL_YGO233_FILE_ALT
);
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
}
}
};
@Override
@Override
public
boolean
onPreferenceChange
(
Preference
preference
,
Object
value
)
{
public
boolean
onPreferenceChange
(
Preference
preference
,
Object
value
)
{
super
.
onPreferenceChange
(
preference
,
value
);
super
.
onPreferenceChange
(
preference
,
value
);
...
@@ -290,7 +246,50 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -290,7 +246,50 @@ public class SettingFragment extends PreferenceFragmentPlus {
return
rs
;
return
rs
;
}
}
return
true
;
return
true
;
}
}
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_SETTING_GET_VERSION_OK:
if
(
msg
.
obj
.
toString
().
contains
(
ID1
)
&&
msg
.
obj
.
toString
().
contains
(
ID2
)
&&
msg
.
obj
.
toString
().
contains
(
ID3
))
{
Version
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
ID1
)
+
ID1
.
length
(),
msg
.
obj
.
toString
().
indexOf
(
";"
));
//截取版本号
Cache_link
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
ID2
)
+
ID2
.
length
(),
msg
.
obj
.
toString
().
indexOf
(
"$"
));
//截取下载地址
Cache_pre_release_code
=
msg
.
obj
.
toString
().
substring
(
msg
.
obj
.
toString
().
indexOf
(
ID3
)
+
ID3
.
length
()
+
1
);
//截取先行-正式对照文本
if
(!
TextUtils
.
isEmpty
(
Cache_pre_release_code
))
{
arrangeCodeList
(
Cache_pre_release_code
);
//转换成两个数组
}
if
(!
Version
.
equals
(
BuildConfig
.
VERSION_NAME
)
&&
!
TextUtils
.
isEmpty
(
Version
)
&&
!
TextUtils
.
isEmpty
(
Cache_link
))
{
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
(
Cache_link
));
startActivity
(
intent
);
dialog
.
dismiss
();
});
dialog
.
show
();
}
else
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
),
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
case
TYPE_SETTING_GET_VERSION_FAILED:
++
FailedCount
;
if
(
FailedCount
<=
2
)
{
checkUpgrade
(
URL_YGO233_FILE_ALT
);
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
();
}
break
;
}
}
};
@Override
@Override
public
boolean
onPreferenceClick
(
Preference
preference
)
{
public
boolean
onPreferenceClick
(
Preference
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