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
dc24cce4
Commit
dc24cce4
authored
Nov 24, 2025
by
xiaoye
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'online-deck-id' of
https://github.com/jwyxym/YGOMobile-cn-ko-en
into online-deck-id
parents
4f85c097
d47d4d5e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
49 deletions
+60
-49
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/DeckPreviewListAdapter.java
.../garymb/ygomobile/ui/adapters/DeckPreviewListAdapter.java
+0
-35
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckItemUtils.java
...java/cn/garymb/ygomobile/ui/cards/deck/DeckItemUtils.java
+55
-9
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
...ymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
...mb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
+3
-4
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/api_response/MyDeckResponse.java
...ile/ui/cards/deck_square/api_response/MyDeckResponse.java
+1
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/DeckPreviewListAdapter.java
deleted
100644 → 0
View file @
4f85c097
package
cn.garymb.ygomobile.ui.adapters
;
import
androidx.annotation.NonNull
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
java.util.List
;
import
cn.garymb.ygomobile.ex_card.ExCardListAdapter
;
import
cn.garymb.ygomobile.lite.R
;
import
ocgcore.data.Card
;
//卡组预览的adapter
public
class
DeckPreviewListAdapter
extends
BaseQuickAdapter
<
Card
,
BaseViewHolder
>
{
private
static
final
String
TAG
=
ExCardListAdapter
.
class
.
getSimpleName
();
public
DeckPreviewListAdapter
(
int
layoutResId
)
{
super
(
layoutResId
);
}
public
void
updateData
(
List
<
Card
>
dataList
)
{
getData
().
clear
();
addData
(
dataList
);
notifyDataSetChanged
();
}
@Override
protected
void
convert
(
@NonNull
BaseViewHolder
baseViewHolder
,
Card
item
)
{
baseViewHolder
.
setText
(
R
.
id
.
preview_card_name
,
item
.
Name
);
baseViewHolder
.
setText
(
R
.
id
.
preview_card_id
,
Integer
.
toString
(
item
.
Code
));
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckItemUtils.java
View file @
dc24cce4
...
...
@@ -109,28 +109,40 @@ class DeckItemUtils {
return
deck
;
}
/**
* 将file内容更新为List<DeckItem>中的内容
* 删除file,之后将List<DeckItem>中的内容保存到file中
* @param items
* @param file 原有file
* @return 如果file为null,返回false
* 将指定文件内容更新为List<DeckItem>中的卡组数据。
* 操作流程:删除原文件,创建新文件,并将卡组信息按格式写入文件。
* 文件结构包括主卡组、额外卡组、副卡组以及可选的deckId和userId标识。
*
* @param items 包含卡组信息的列表,其中包含主卡组、额外卡组和副卡组的数据
* @param deckId 可选参数,表示卡组ID,若非空则写入文件末尾(以 ## 开头)
* @param userId 可选参数,表示用户ID,若非空则写入文件末尾(以 ### 开头)
* @param file 要被覆盖写入的文件对象,如果为null则直接返回false
* @return 操作成功返回true;如果file为null或发生IO异常则返回false
*/
public
static
boolean
save
(
List
<
DeckItem
>
items
,
String
deckId
,
Integer
userId
,
File
file
)
{
FileOutputStream
outputStream
=
null
;
OutputStreamWriter
writer
=
null
;
try
{
// 参数校验:如果文件为空,直接返回失败
if
(
file
==
null
)
{
return
false
;
}
// 若文件已存在,则先删除旧文件再重新创建
if
(
file
.
exists
())
{
file
.
delete
();
}
file
.
createNewFile
();
// 初始化输出流并设置编码为UTF-8
outputStream
=
new
FileOutputStream
(
file
);
writer
=
new
OutputStreamWriter
(
outputStream
,
StandardCharsets
.
UTF_8
);
// 写入文件头部标识
writer
.
write
(
"#created by ygomobile"
.
toCharArray
());
// 写入主卡组部分
writer
.
write
(
"\n#main"
.
toCharArray
());
for
(
int
i
=
DeckItem
.
MainStart
;
i
<
DeckItem
.
MainStart
+
Constants
.
DECK_MAIN_MAX
;
i
++)
{
DeckItem
deckItem
=
items
.
get
(
i
);
...
...
@@ -142,6 +154,8 @@ class DeckItemUtils {
writer
.
write
((
"\n"
+
cardInfo
.
Code
).
toCharArray
());
}
}
// 写入额外卡组部分
writer
.
write
(
"\n#extra"
.
toCharArray
());
for
(
int
i
=
DeckItem
.
ExtraStart
;
i
<
DeckItem
.
ExtraStart
+
Constants
.
DECK_EXTRA_MAX
;
i
++)
{
DeckItem
deckItem
=
items
.
get
(
i
);
...
...
@@ -153,6 +167,8 @@ class DeckItemUtils {
writer
.
write
((
"\n"
+
cardInfo
.
Code
).
toCharArray
());
}
}
// 写入副卡组部分
writer
.
write
(
"\n!side"
.
toCharArray
());
for
(
int
i
=
DeckItem
.
SideStart
;
i
<
DeckItem
.
SideStart
+
Constants
.
DECK_SIDE_MAX
;
i
++)
{
DeckItem
deckItem
=
items
.
get
(
i
);
...
...
@@ -164,45 +180,70 @@ class DeckItemUtils {
writer
.
write
((
"\n"
+
cardInfo
.
Code
).
toCharArray
());
}
}
// 如果提供了deckId和userId,追加到文件末尾
if
(
deckId
!=
null
)
writer
.
write
((
"\n##"
+
deckId
).
toCharArray
());
if
(
userId
!=
null
)
writer
.
write
((
"\n###"
+
userId
).
toCharArray
());
// 刷新缓冲区确保所有数据写入磁盘
writer
.
flush
();
outputStream
.
flush
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
finally
{
// 关闭资源,避免内存泄漏
IOUtils
.
close
(
writer
);
IOUtils
.
close
(
outputStream
);
}
return
true
;
}
/**
* 根据传入的卡组信息构建并添加卡组项到适配器中。
*
* @param deckInfo 卡组信息对象,包含主卡组、额外卡组和副卡组等数据
* @param isPack 是否为卡包模式,影响布局和显示方式
* @param adapater 用于接收和管理卡组项的适配器对象
*/
public
static
void
makeItems
(
DeckInfo
deckInfo
,
boolean
isPack
,
DeckAdapater
adapater
)
{
if
(
deckInfo
!=
null
)
{
// 设置卡组ID和用户ID(如果存在)
if
(
deckInfo
.
deckId
!=
null
)
adapater
.
setDeckId
(
deckInfo
.
deckId
);
if
(
deckInfo
.
userId
!=
null
)
adapater
.
setUserId
(
deckInfo
.
userId
);
// 重置标签状态
DeckItem
.
resetLabel
(
deckInfo
,
isPack
);
// 添加主卡区域标签
adapater
.
addItem
(
new
DeckItem
(
DeckItemType
.
MainLabel
));
List
<
Card
>
main
=
deckInfo
.
getMainCards
();
// 构建主卡区域内容
if
(
main
==
null
)
{
// 主卡为空时,填充默认数量的空位
for
(
int
i
=
0
;
i
<
Constants
.
DECK_MAIN_MAX
;
i
++)
{
adapater
.
addItem
(
new
DeckItem
());
}
}
else
{
// 添加实际主卡项
for
(
Card
card
:
main
)
{
adapater
.
addItem
(
new
DeckItem
(
card
,
DeckItemType
.
MainCard
));
}
// 补足剩余空位或根据需要填充空白以避免UI重叠
if
(
main
.
size
()
<
Constants
.
DECK_MAIN_MAX
)
{
for
(
int
i
=
main
.
size
();
i
<
Constants
.
DECK_MAIN_MAX
;
i
++)
{
adapater
.
addItem
(
new
DeckItem
());
}
}
else
{
//填充空舍的位置便于滚动到底部时不和底部功能按钮重叠
//
填充空舍的位置便于滚动到底部时不和底部功能按钮重叠
int
emty
=
Constants
.
DECK_WIDTH_COUNT
-
deckInfo
.
getMainCount
()
%
Constants
.
DECK_WIDTH_COUNT
;
for
(
int
i
=
main
.
size
();
i
<
(
isPack
?
emty
:
0
)
+
deckInfo
.
getMainCount
();
i
++)
{
adapater
.
addItem
(
new
DeckItem
());
...
...
@@ -210,10 +251,12 @@ class DeckItemUtils {
}
}
// 非卡包模式下处理额外卡组与副卡组
if
(!
isPack
)
{
List
<
Card
>
extra
=
deckInfo
.
getExtraCards
();
List
<
Card
>
side
=
deckInfo
.
getSideCards
();
//extra
// 处理额外卡组
adapater
.
addItem
(
new
DeckItem
(
DeckItemType
.
ExtraLabel
));
if
(
extra
==
null
)
{
for
(
int
i
=
0
;
i
<
Constants
.
DECK_EXTRA_COUNT
;
i
++)
{
...
...
@@ -227,7 +270,8 @@ class DeckItemUtils {
adapater
.
addItem
(
new
DeckItem
());
}
}
//side
// 处理副卡组
adapater
.
addItem
(
new
DeckItem
(
DeckItemType
.
SideLabel
));
if
(
side
==
null
)
{
for
(
int
i
=
0
;
i
<
Constants
.
DECK_SIDE_COUNT
;
i
++)
{
...
...
@@ -241,6 +285,8 @@ class DeckItemUtils {
adapater
.
addItem
(
new
DeckItem
());
}
}
// 添加一个占位空间项
adapater
.
addItem
(
new
DeckItem
(
DeckItemType
.
Space
));
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
View file @
dc24cce4
...
...
@@ -448,7 +448,7 @@ public class DeckSquareApiUtil {
localDeck
.
setDeckName
(
localDeckName
);
localDeck
.
setDeckCoverCard1
(
DeckUtil
.
getFirstCardCode
(
localDeck
.
getDeckPath
()));
localDeck
.
setDelete
(
false
);
LogUtil
.
e
(
TAG
,
"本地卡组名称:"
+
localDeck
.
getDeck
Name
()+
"\n本地卡组分类:"
+
localDeck
.
getDeckTyp
e
()+
"\n本地卡组ID:"
+
localDeck
.
getDeckId
());
LogUtil
.
e
(
TAG
,
"本地卡组名称:"
+
localDeck
.
getDeck
Type
()+
"-"
+
localDeck
.
getDeckNam
e
()+
"\n本地卡组ID:"
+
localDeck
.
getDeckId
());
// 2. 使用在线卡组的迭代器遍历(支持安全删除)
Iterator
<
MyOnlineDeckDetail
>
onlineIterator
=
onlineDecks
.
iterator
();
while
(
onlineIterator
.
hasNext
())
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
View file @
dc24cce4
...
...
@@ -55,7 +55,7 @@ public class DeckSquareFileUtil {
}
//读取file指定的ydk文件,返回其内包含的deckId。如果不包含deckId,返回null
public
static
String
getId
(
File
file
)
{
public
static
String
get
Deck
Id
(
File
file
)
{
String
deckId
=
null
;
Integer
userId
=
null
;
FileInputStream
inputStream
=
null
;
...
...
@@ -73,9 +73,8 @@ public class DeckSquareFileUtil {
try
{
line
=
line
.
replace
(
"#"
,
""
);
if
(!
line
.
isEmpty
())
{
userId
=
Integer
.
parseInt
(
line
);
userId
=
Integer
.
parseInt
(
line
.
replaceAll
(
"###"
,
""
)
);
}
// userId = Integer.parseInt(line.replaceAll("###", ""));
}
catch
(
NumberFormatException
e
)
{
LogUtil
.
e
(
TAG
,
"getId(77): integer"
+
line
+
"parse error"
+
e
.
toString
());
}
...
...
@@ -206,7 +205,7 @@ public class DeckSquareFileUtil {
List
<
MyDeckItem
>
result
=
new
ArrayList
<>();
File
[]
files
=
getAllYdk
();
for
(
File
file
:
files
)
{
String
deckId
=
getId
(
file
);
String
deckId
=
get
Deck
Id
(
file
);
MyDeckItem
item
=
new
MyDeckItem
();
item
.
setDeckName
(
file
.
getName
());
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/api_response/MyDeckResponse.java
View file @
dc24cce4
...
...
@@ -24,6 +24,7 @@ public class MyDeckResponse {
}
public
List
<
MyOnlineDeckDetail
>
getData
()
{
List
<
MyOnlineDeckDetail
>
data
=
this
.
data
;
//根据deckType排序,提高观感
if
(!
data
.
isEmpty
()
||
data
!=
null
)
{
data
.
sort
((
o1
,
o2
)
->
{
...
...
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