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
46f7285a
Commit
46f7285a
authored
Jul 03, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取本地全部卡组也遍历子文件夹
parent
1b7c45aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
10 deletions
+44
-10
mobile/build.gradle
mobile/build.gradle
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareFileUtil.java
...a/cn/garymb/ygomobile/deck_square/DeckSquareFileUtil.java
+41
-7
mobile/src/main/java/ocgcore/PackManager.java
mobile/src/main/java/ocgcore/PackManager.java
+1
-1
No files found.
mobile/build.gradle
View file @
46f7285a
...
...
@@ -9,8 +9,8 @@ android {
minSdkVersion
25
//noinspection ExpiredTargetSdkVersion
targetSdkVersion
29
versionCode
31200000
5
versionName
"3.12.4"
versionCode
31200000
6
versionName
"3.12.4
fix1
"
flavorDimensions
"versionCode"
vectorDrawables
.
useSupportLibrary
=
true
ndkVersion
"21.3.6528147"
...
...
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareFileUtil.java
View file @
46f7285a
package
cn.garymb.ygomobile.deck_square
;
import
androidx.annotation.Nullable
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
...
...
@@ -82,12 +84,47 @@ public class DeckSquareFileUtil {
return
deckId
;
}
//查询卡组目录下的所有ydk文件,返回File[]
/**
* 查询卡组目录下的所有ydk文件(包含子文件夹)
* @return 包含所有ydk文件的File数组
*/
public
static
File
[]
getAllYdk
()
{
File
dir
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_DECK_PATH
);
File
[]
files
=
dir
.
listFiles
((
file
,
s
)
->
s
.
toLowerCase
(
Locale
.
US
).
endsWith
(
Constants
.
YDK_FILE_EX
));
if
(!
dir
.
exists
()
||
!
dir
.
isDirectory
())
{
return
new
File
[
0
];
}
// 使用ArrayList存储结果,方便动态添加
ArrayList
<
File
>
ydkFiles
=
new
ArrayList
<>();
// 递归遍历目录和子目录
findYdkFiles
(
dir
,
ydkFiles
);
// 将ArrayList转换为File数组
return
ydkFiles
.
toArray
(
new
File
[
0
]);
}
return
files
;
/**
* 递归查找指定目录下的所有YDK文件
* @param dir 当前查找的目录
* @param ydkFiles 存储找到的YDK文件
*/
private
static
void
findYdkFiles
(
File
dir
,
ArrayList
<
File
>
ydkFiles
)
{
// 获取目录下的所有文件和子目录
File
[]
files
=
dir
.
listFiles
();
if
(
files
==
null
)
{
return
;
// 目录不可访问或为空
}
for
(
File
file
:
files
)
{
if
(
file
.
isDirectory
())
{
// 如果是子目录,递归查找
findYdkFiles
(
file
,
ydkFiles
);
}
else
{
// 如果是文件,检查是否为YDK文件
String
fileName
=
file
.
getName
().
toLowerCase
(
Locale
.
US
);
if
(
fileName
.
endsWith
(
Constants
.
YDK_FILE_EX
))
{
ydkFiles
.
add
(
file
);
}
}
}
}
//读取卡组目录下的所有ydk文件,解析ydk文件(包括从ydk文件内容中读取deckId),生成List<MyDeckItem>解析结果
...
...
@@ -98,9 +135,6 @@ public class DeckSquareFileUtil {
String
deckId
=
getId
(
file
);
MyDeckItem
item
=
new
MyDeckItem
();
item
.
deckName
=
file
.
getName
();
item
.
setUpdateDate
(
String
.
valueOf
(
file
.
lastModified
()));
item
.
setDeckSouce
(
0
);
item
.
setDeckPath
(
file
.
getPath
());
...
...
@@ -180,7 +214,7 @@ public class DeckSquareFileUtil {
fos
.
flush
();
fos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
);
LogUtil
.
e
(
TAG
,
"保存文件失败"
,
e
);
return
false
;
}
return
true
;
...
...
mobile/src/main/java/ocgcore/PackManager.java
View file @
46f7285a
...
...
@@ -145,7 +145,7 @@ public class PackManager implements Closeable {
public
List
<
Integer
>
getAllIdsById
(
Integer
id
)
{
String
packName
=
findPackNameById
(
id
);
if
(
packName
==
null
)
{
Log
.
w
(
"seesee"
,
"No pack found for ID: "
+
id
);
Log
.
w
(
TAG
,
"No pack found for ID: "
+
id
);
return
new
ArrayList
<>();
}
return
findIdsByPackName
(
packName
);
...
...
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