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
3bbae057
Commit
3bbae057
authored
Jul 06, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化同步逻辑
parent
cc0cd259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
17 deletions
+11
-17
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
...ymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
+11
-17
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
View file @
3bbae057
...
@@ -302,7 +302,6 @@ public class DeckSquareApiUtil {
...
@@ -302,7 +302,6 @@ public class DeckSquareApiUtil {
* @throws IOException
* @throws IOException
*/
*/
public
static
PushDeckResponse
requestIdAndPushNewDecks
(
List
<
MyDeckItem
>
deckDataList
,
LoginToken
loginToken
)
throws
IOException
{
public
static
PushDeckResponse
requestIdAndPushNewDecks
(
List
<
MyDeckItem
>
deckDataList
,
LoginToken
loginToken
)
throws
IOException
{
LogUtil
.
d
(
"seesee"
,
"有没有运行这里啊"
+
deckDataList
+
" "
+
loginToken
);
if
(
loginToken
==
null
)
{
if
(
loginToken
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -356,9 +355,7 @@ public class DeckSquareApiUtil {
...
@@ -356,9 +355,7 @@ public class DeckSquareApiUtil {
return
pushMultiDecks
(
dataList
,
loginToken
);
return
pushMultiDecks
(
dataList
,
loginToken
);
}
}
public
static
PushDeckResponse
pushMultiDecks
public
static
PushDeckResponse
pushMultiDecks
(
List
<
PushMultiDeck
.
DeckData
>
dataList
,
LoginToken
loginToken
)
throws
IOException
{
(
List
<
PushMultiDeck
.
DeckData
>
dataList
,
LoginToken
loginToken
)
throws
IOException
{
String
url
=
"http://rarnu.xyz:38383/api/mdpro3/sync/multi"
;
String
url
=
"http://rarnu.xyz:38383/api/mdpro3/sync/multi"
;
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"ReqSource"
,
"YGOMobile"
);
headers
.
put
(
"ReqSource"
,
"YGOMobile"
);
...
@@ -647,14 +644,15 @@ public class DeckSquareApiUtil {
...
@@ -647,14 +644,15 @@ public class DeckSquareApiUtil {
}
}
List
<
MyOnlineDeckDetail
>
onlineDecks
=
onlineDecksResponse
.
getData
();
List
<
MyOnlineDeckDetail
>
onlineDecks
=
onlineDecksResponse
.
getData
();
// 用于标记在线卡组是否在本地有对应
// 用于标记在线卡组是否在本地有对应
Map
<
String
,
Boolean
>
onlineDeckProcessed
=
new
HashMap
<>();
Map
<
String
,
Boolean
>
onlineDeckProcessed
=
new
HashMap
<>();
for
(
MyOnlineDeckDetail
onlineDeck
:
onlineDecks
)
{
for
(
MyOnlineDeckDetail
onlineDeck
:
onlineDecks
)
{
onlineDeckProcessed
.
put
(
onlineDeck
.
getDeckName
(),
false
);
onlineDeckProcessed
.
put
(
onlineDeck
.
getDeckName
(),
false
);
}
}
List
<
MyDeckItem
>
syncUploadDecks
=
new
ArrayList
<>();
List
<
MyDeckItem
>
syncUploadDecks
=
new
ArrayList
<>();
List
<
MyDeckItem
>
newPushDecks
=
new
ArrayList
<>();
List
<
MyDeckItem
>
newPushDecks
=
new
ArrayList
<>();
// 遍历本地卡组,处理同名卡组的情况
// 遍历本地卡组,处理同名卡组的情况
for
(
MyDeckItem
localDeck
:
localDecks
)
{
for
(
MyDeckItem
localDeck
:
localDecks
)
{
boolean
foundOnlineDeck
=
false
;
boolean
foundOnlineDeck
=
false
;
...
@@ -681,37 +679,33 @@ public class DeckSquareApiUtil {
...
@@ -681,37 +679,33 @@ public class DeckSquareApiUtil {
if
(!
foundOnlineDeck
)
{
if
(!
foundOnlineDeck
)
{
localDeck
.
setDeckName
(
localDeck
.
getDeckName
().
replace
(
Constants
.
YDK_FILE_EX
,
""
));
localDeck
.
setDeckName
(
localDeck
.
getDeckName
().
replace
(
Constants
.
YDK_FILE_EX
,
""
));
localDeck
.
setDeckCoverCard1
(
DeckUtil
.
getFirstCardCode
(
localDeck
.
getDeckPath
()));
localDeck
.
setDeckCoverCard1
(
DeckUtil
.
getFirstCardCode
(
localDeck
.
getDeckPath
()));
LogUtil
.
w
(
TAG
,
"seesee +要上传的 本地卡组: "
+
localDeck
.
getDeckName
());
newPushDecks
.
add
(
localDeck
);
newPushDecks
.
add
(
localDeck
);
autoSyncResult
.
newUpload
.
add
(
localDeck
);
autoSyncResult
.
newUpload
.
add
(
localDeck
);
}
}
}
}
// 上传本地卡组覆盖在线卡组
PushDeckResponse
response
=
syncMyDecks
(
syncUploadDecks
,
loginToken
);
autoSyncResult
.
pushResponse
=
response
;
if
(!
newPushDecks
.
isEmpty
())
{
if
(!
newPushDecks
.
isEmpty
())
{
LogUtil
.
w
(
TAG
,
"seesee
*newPushDecks: "
+
newPushDecks
.
isEmpty
()
+
": "
+
newPushDecks
);
LogUtil
.
w
(
TAG
,
"seesee
+要上传的 本地卡组: "
+
newPushDecks
);
requestIdAndPushNewDecks
(
newPushDecks
,
loginToken
);
requestIdAndPushNewDecks
(
newPushDecks
,
loginToken
);
}
}
// 处理只存在于在线的卡组(即本地没有同名卡组)
// 处理只存在于在线的卡组(即本地没有同名卡组)
for
(
MyOnlineDeckDetail
onlineDeck
:
onlineDecks
)
{
for
(
MyOnlineDeckDetail
onlineDeck
:
onlineDecks
)
{
String
onLineDeckName
=
onlineDeck
.
getDeckName
().
replace
(
Constants
.
YDK_FILE_EX
,
""
);
String
onLineDeckName
=
onlineDeck
.
getDeckName
().
replace
(
Constants
.
YDK_FILE_EX
,
""
);
LogUtil
.
w
(
TAG
,
"seesee *在线卡组*onLineDeckName: "
+
onLineDeckName
);
if
(!
onlineDeckProcessed
.
get
(
onLineDeckName
))
{
if
(!
onlineDeckProcessed
.
get
(
onLineDeckName
))
{
autoSyncResult
.
newDownload
.
add
(
onlineDeck
);
autoSyncResult
.
newDownload
.
add
(
onlineDeck
);
LogUtil
.
w
(
TAG
,
"see sync-download new deck: "
+
onlineDeck
.
getDeckName
());
LogUtil
.
w
(
TAG
,
"see
see
sync-download new deck: "
+
onlineDeck
.
getDeckName
());
SyncMutliDeckResult
.
DownloadResult
downloadResult
=
downloadMissingDeckToLocal
(
onlineDeck
,
DeckSquareFileUtil
.
convertToUnixTimestamp
(
onlineDeck
.
getDeckUpdateDate
()));
SyncMutliDeckResult
.
DownloadResult
downloadResult
=
downloadMissingDeckToLocal
(
onlineDeck
,
DeckSquareFileUtil
.
convertToUnixTimestamp
(
onlineDeck
.
getDeckUpdateDate
()));
autoSyncResult
.
downloadResponse
.
add
(
downloadResult
);
autoSyncResult
.
downloadResponse
.
add
(
downloadResult
);
}
}
}
}
LogUtil
.
w
(
TAG
,
"seesee *结果*newDownload: "
+
autoSyncResult
.
newDownload
);
//LogUtil.w(TAG, "seesee *结果*newUpload: " + autoSyncResult.syncDownload);
// 上传本地卡组覆盖在线卡组
LogUtil
.
w
(
TAG
,
"seesee *结果*downloadResponse: "
+
autoSyncResult
.
downloadResponse
);
PushDeckResponse
response
=
syncMyDecks
(
syncUploadDecks
,
loginToken
);
//TODO 一定要最后执行这行,否则会直接终止后续执行
autoSyncResult
.
pushResponse
=
response
;
return
autoSyncResult
;
return
autoSyncResult
;
}
}
...
...
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