Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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-Cn-Ko-En
Commits
2c7d8c68
Commit
2c7d8c68
authored
Jul 04, 2025
by
wangfugui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
e36c905e
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
289 additions
and
168 deletions
+289
-168
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareApiUtil.java
...va/cn/garymb/ygomobile/deck_square/DeckSquareApiUtil.java
+169
-99
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareFileUtil.java
...a/cn/garymb/ygomobile/deck_square/DeckSquareFileUtil.java
+42
-20
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
...arymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/deck_square/api_response/DeckMultiIdResponse.java
...omobile/deck_square/api_response/DeckMultiIdResponse.java
+52
-0
mobile/src/main/java/cn/garymb/ygomobile/deck_square/api_response/SyncDecksResponse.java
...ygomobile/deck_square/api_response/SyncDecksResponse.java
+0
-38
mobile/src/main/java/cn/garymb/ygomobile/deck_square/bo/SyncMutliDeckResult.java
.../garymb/ygomobile/deck_square/bo/SyncMutliDeckResult.java
+22
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+2
-1
No files found.
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareApiUtil.java
View file @
2c7d8c68
This diff is collapsed.
Click to expand it.
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareFileUtil.java
View file @
2c7d8c68
...
...
@@ -26,7 +26,8 @@ import ocgcore.data.Card;
public
class
DeckSquareFileUtil
{
//
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
"seesee decksquareApiUtil"
;
//private static final String TAG = DeckSquareListAdapter.class.getSimpleName();
// public static List<String> readLastLinesWithNIO(File file, int numLines) {
// try {
...
...
@@ -57,7 +58,7 @@ public class DeckSquareFileUtil {
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
LogUtil
.
i
(
TAG
,
line
);
//
LogUtil.i(TAG, line);
if
(
line
.
startsWith
(
"###"
))
{
//注意,先判断###,后判断##。因为###会包括##的情况
try
{
String
data
=
line
.
replace
(
"#"
,
""
);
...
...
@@ -207,20 +208,10 @@ public class DeckSquareFileUtil {
return
content
;
}
/**
* 保存文件到指定路径,并设置指定的最后修改时间
*
* @param path 保存路径
* @param fileName 文件名
* @param content 文件内容
* @param modificationTime 期望的最后修改时间(毫秒时间戳)
* @return 保存是否成功
*/
public
static
boolean
saveFileToPath
(
String
path
,
String
fileName
,
String
content
,
long
modificationTime
)
{
public
static
boolean
saveFile
(
File
file
,
String
content
,
long
modificationTime
)
{
FileOutputStream
fos
=
null
;
try
{
// 创建文件对象
File
file
=
new
File
(
path
,
fileName
);
fos
=
new
FileOutputStream
(
file
);
// 创建文件输出流
// 写入内容
...
...
@@ -251,6 +242,33 @@ public class DeckSquareFileUtil {
return
true
;
}
/**
*
* @param fileFullPath 文件的完整路径
* @param content
* @param modificationTime
* @return
*/
public
static
boolean
saveFileToPath
(
String
fileFullPath
,
String
content
,
long
modificationTime
)
{
File
file
=
new
File
(
fileFullPath
);
return
saveFile
(
file
,
content
,
modificationTime
);
}
/**
* 保存文件到指定路径,并设置指定的最后修改时间
*
* @param fileParentPath 保存文件的父目录路径
* @param fileName 文件名
* @param content 文件内容
* @param modificationTime 最后修改时间(毫秒时间戳)
* @return 保存是否成功
*/
public
static
boolean
saveFileToPath
(
String
fileParentPath
,
String
fileName
,
String
content
,
long
modificationTime
)
{
File
file
=
new
File
(
fileParentPath
,
fileName
);
return
saveFile
(
file
,
content
,
modificationTime
);
}
public
static
List
<
Card
>
convertTempDeckYdk
(
String
deckYdk
)
{
String
[]
deckLine
=
deckYdk
.
split
(
"\r\n|\r|\n"
);
...
...
@@ -277,13 +295,17 @@ public class DeckSquareFileUtil {
}
public
static
long
convertToUnixTimestamp
(
String
dateTimeStr
)
throws
ParseException
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss"
);
sdf
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
sdf
.
setLenient
(
false
);
Date
date
=
sdf
.
parse
(
dateTimeStr
);
return
date
.
getTime
();
public
static
long
convertToUnixTimestamp
(
String
dateTimeStr
)
{
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss"
);
sdf
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
sdf
.
setLenient
(
false
);
Date
date
=
sdf
.
parse
(
dateTimeStr
);
return
date
.
getTime
();
}
catch
(
ParseException
e
){
e
.
printStackTrace
();
}
return
0
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareMyDeckFragment.java
View file @
2c7d8c68
...
...
@@ -128,7 +128,7 @@ public class DeckSquareMyDeckFragment extends Fragment {
LogUtil
.
i
(
TAG
,
"Sync decks fail"
+
e
.
getMessage
());
}).
done
((
result
)
->
{
String
info
=
"sync decks: upload "
+
result
.
toUpload
.
size
()
+
", download "
+
result
.
d
ownload
.
size
();
String
info
=
"sync decks: upload "
+
result
.
syncUpload
.
size
()
+
", download "
+
result
.
newD
ownload
.
size
();
YGOUtil
.
showTextToast
(
info
,
Toast
.
LENGTH_LONG
);
});
...
...
@@ -216,7 +216,7 @@ public class DeckSquareMyDeckFragment extends Fragment {
YGOUtil
.
showTextToast
(
"Sync decks fail"
,
Toast
.
LENGTH_LONG
);
LogUtil
.
i
(
TAG
,
"Sync decks fail"
+
e
.
getMessage
());
}).
done
((
result
)
->
{
String
info
=
"sync decks: upload "
+
result
.
toUpload
.
size
()
+
", download "
+
result
.
d
ownload
.
size
();
String
info
=
"sync decks: upload "
+
result
.
syncUpload
.
size
()
+
", download "
+
result
.
newD
ownload
.
size
();
YGOUtil
.
showTextToast
(
info
,
Toast
.
LENGTH_LONG
);
});
...
...
mobile/src/main/java/cn/garymb/ygomobile/deck_square/api_response/DeckMultiIdResponse.java
0 → 100644
View file @
2c7d8c68
package
cn.garymb.ygomobile.deck_square.api_response
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
public
class
DeckMultiIdResponse
{
@Expose
public
int
code
;
@Expose
public
String
message
;
@Expose
@SerializedName
(
"data"
)
public
List
<
String
>
deckId
;
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
List
<
String
>
getDeckId
()
{
return
deckId
;
}
public
void
setDeckId
(
List
<
String
>
deckId
)
{
this
.
deckId
=
deckId
;
}
@Override
public
String
toString
()
{
return
"DeckMultiIdResponse{"
+
"code="
+
code
+
", message='"
+
message
+
'\''
+
", deckId="
+
deckId
+
'}'
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/deck_square/api_response/SyncDecksResponse.java
deleted
100644 → 0
View file @
e36c905e
package
cn.garymb.ygomobile.deck_square.api_response
;
/* 同步卡组响应体类*/
public
class
SyncDecksResponse
{
private
Integer
code
;
private
String
message
;
private
Integer
data
;
public
SyncDecksResponse
(
Integer
code
,
String
message
,
Integer
data
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
data
=
data
;
}
// getters and setters
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
Integer
getData
()
{
return
data
;
}
public
void
setData
(
Integer
data
)
{
this
.
data
=
data
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/deck_square/bo/SyncMutliDeckResult.java
View file @
2c7d8c68
package
cn.garymb.ygomobile.deck_square.bo
;
import
org.minidns.record.A
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cn.garymb.ygomobile.deck_square.api_response.MyOnlineDeckDetail
;
import
cn.garymb.ygomobile.deck_square.api_response.
SyncDecks
Response
;
import
cn.garymb.ygomobile.deck_square.api_response.
PushDeck
Response
;
public
class
SyncMutliDeckResult
{
boolean
flag
=
false
;
String
info
=
null
;
public
SyncDecks
Response
pushResponse
;
public
PushDeck
Response
pushResponse
;
public
List
<
MyDeckItem
>
toUpload
;
//用于记录已推送的卡组
public
List
<
MyOnlineDeckDetail
>
download
;
public
List
<
MyDeckItem
>
syncUpload
;
//用于记录已推送的卡组
public
List
<
MyDeckItem
>
newUpload
;
//用于记录第一次推送到云的卡组
public
List
<
MyDeckItem
>
syncDownload
;
//用于记录已推送的卡组
public
List
<
MyOnlineDeckDetail
>
newDownload
;
public
List
<
DownloadResult
>
downloadResponse
;
public
static
class
DownloadResult
{
...
...
@@ -37,16 +41,20 @@ public class SyncMutliDeckResult {
public
SyncMutliDeckResult
()
{
flag
=
true
;
downloadResponse
=
new
ArrayList
<>();
download
=
new
ArrayList
<>();
toUpload
=
new
ArrayList
<>();
newDownload
=
new
ArrayList
<>();
syncUpload
=
new
ArrayList
<>();
newUpload
=
new
ArrayList
<>();
syncDownload
=
new
ArrayList
<>();
}
public
SyncMutliDeckResult
(
boolean
flag
,
String
info
)
{
this
.
flag
=
flag
;
this
.
info
=
info
;
downloadResponse
=
new
ArrayList
<>();
download
=
new
ArrayList
<>();
toUpload
=
new
ArrayList
<>();
newDownload
=
new
ArrayList
<>();
syncUpload
=
new
ArrayList
<>();
newUpload
=
new
ArrayList
<>();
syncDownload
=
new
ArrayList
<>();
}
public
boolean
isFlag
()
{
...
...
@@ -64,4 +72,10 @@ public class SyncMutliDeckResult {
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
public
String
getMessage
()
{
String
info
=
"sync decks: "
+
syncUpload
.
size
()
+
", push new:"
+
newUpload
.
size
()
+
", download "
+
newDownload
.
size
();
return
info
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
2c7d8c68
...
...
@@ -4,6 +4,7 @@ import static android.content.Context.CLIPBOARD_SERVICE;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
deck_square
.
DeckSquareFileUtil
.
convertToUnixTimestamp
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
...
...
@@ -1351,7 +1352,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
String
fileFullName
=
deckData
.
getDeckName
()
+
".ydk"
;
File
dir
=
new
File
(
getActivity
().
getApplicationInfo
().
dataDir
,
"cache"
);
//将卡组存到cache缓存目录中
boolean
result
=
DeckSquareFileUtil
.
saveFileToPath
(
dir
.
getPath
(),
fileFullName
,
deckData
.
getDeckYdk
(),
Long
.
valueOf
(
deckData
.
getDeckUpdateDate
()));
boolean
result
=
DeckSquareFileUtil
.
saveFileToPath
(
dir
.
getPath
(),
fileFullName
,
deckData
.
getDeckYdk
(),
convertToUnixTimestamp
(
deckData
.
getDeckUpdateDate
()));
if
(
result
)
{
//存储成功,使用预加载功能
LogUtil
.
i
(
TAG
,
"square deck detail done"
);
//File file = new File(dir, fileFullName);
...
...
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