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
e2fc6b18
Commit
e2fc6b18
authored
Jul 21, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
找不到保存路径时创建
parent
a2045025
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
11 deletions
+32
-11
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
...ymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
+9
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
...mb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
+22
-7
mobile/src/main/res/values-zh/strings.xml
mobile/src/main/res/values-zh/strings.xml
+1
-1
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareApiUtil.java
View file @
e2fc6b18
package
cn.garymb.ygomobile.ui.cards.deck_square
;
package
cn.garymb.ygomobile.ui.cards.deck_square
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_DECK_PATH
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -757,12 +759,16 @@ public class DeckSquareApiUtil {
...
@@ -757,12 +759,16 @@ public class DeckSquareApiUtil {
}
}
String
fileFullPath
=
AppsSettings
.
get
().
getDeckDir
()
+
"/"
+
fileName
;
String
fileFullPath
=
AppsSettings
.
get
().
getDeckDir
()
+
"/"
+
fileName
;
if
(!
onlineDeck
.
getDeckType
().
equals
(
CORE_DECK_PATH
))
fileFullPath
=
AppsSettings
.
get
().
getDeckDir
()
+
"/"
+
onlineDeck
.
getDeckType
()+
"/"
+
fileName
;
// 保存在线卡组到本地
// 保存在线卡组到本地
boolean
saved
=
DeckSquareFileUtil
.
saveFileToPath
(
fileFullPath
,
onlineDeck
.
getDeckYdk
(),
onlineDeck
.
getDeckUpdateDate
());
boolean
saved
=
DeckSquareFileUtil
.
saveFileToPath
(
fileFullPath
,
onlineDeck
.
getDeckYdk
(),
onlineDeck
.
getDeckUpdateDate
());
if
(!
saved
)
LogUtil
.
e
(
TAG
,
"synchronizeDecks(761) 保存失败!的 云备份卡组: "
+
fileFullPath
);
if
(!
saved
)
{
LogUtil
.
e
(
TAG
,
"synchronizeDecks(761) 保存失败!的 云备份卡组: "
+
fileFullPath
);
LogUtil
.
i
(
TAG
,
"synchronizeDecks(763) 保存成功√的 云备份卡组: "
+
fileFullPath
);
}
else
{
LogUtil
.
i
(
TAG
,
"synchronizeDecks(763) 保存成功√的 云备份卡组: "
+
fileFullPath
);
}
}
}
// 上传本地卡组覆盖在线卡组
// 上传本地卡组覆盖在线卡组
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
View file @
e2fc6b18
...
@@ -217,25 +217,40 @@ public class DeckSquareFileUtil {
...
@@ -217,25 +217,40 @@ public class DeckSquareFileUtil {
public
static
boolean
saveFile
(
File
file
,
String
content
,
long
modificationTime
)
{
public
static
boolean
saveFile
(
File
file
,
String
content
,
long
modificationTime
)
{
FileOutputStream
fos
=
null
;
FileOutputStream
fos
=
null
;
try
{
try
{
// 创建文件对象
// 确保父目录存在
fos
=
new
FileOutputStream
(
file
);
File
parentDir
=
file
.
getParentFile
();
if
(
parentDir
!=
null
&&
!
parentDir
.
exists
())
{
boolean
dirsCreated
=
parentDir
.
mkdirs
();
// 创建所有缺失的父目录
if
(!
dirsCreated
)
{
LogUtil
.
e
(
TAG
,
"无法创建文件目录: "
+
parentDir
.
getAbsolutePath
());
return
false
;
}
}
// 创建文件对象(如果文件不存在,会自动创建)
if
(!
file
.
exists
())
{
boolean
fileCreated
=
file
.
createNewFile
();
if
(!
fileCreated
)
{
LogUtil
.
e
(
TAG
,
"无法创建文件: "
+
file
.
getAbsolutePath
());
return
false
;
}
}
// 创建文件输出流
// 创建文件输出流
fos
=
new
FileOutputStream
(
file
);
// 写入内容
// 写入内容
fos
.
write
(
content
.
getBytes
(
));
fos
.
write
(
content
.
getBytes
(
StandardCharsets
.
UTF_8
));
// 使用 UTF-8 编码
fos
.
flush
();
fos
.
flush
();
// 设置指定的最后修改时间
// 设置指定的最后修改时间
boolean
timeSet
=
file
.
setLastModified
(
modificationTime
);
boolean
timeSet
=
file
.
setLastModified
(
modificationTime
);
if
(!
timeSet
)
{
if
(!
timeSet
)
{
LogUtil
.
w
(
TAG
,
"设置文件修改时间失败: "
+
file
.
getPath
());
LogUtil
.
w
(
TAG
,
"设置文件修改时间失败: "
+
file
.
getPath
());
}
else
{
}
else
{
LogUtil
.
d
(
TAG
,
"设置文件修改时间成功: "
+
file
.
getPath
());
LogUtil
.
w
(
TAG
,
"设置文件修改时间成功: "
+
file
.
getPath
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LogUtil
.
e
(
TAG
,
"保存文件失败"
,
e
);
LogUtil
.
e
(
TAG
,
"保存文件失败"
,
e
);
e
.
printStackTrace
();
return
false
;
return
false
;
}
finally
{
}
finally
{
if
(
fos
!=
null
)
{
if
(
fos
!=
null
)
{
...
...
mobile/src/main/res/values-zh/strings.xml
View file @
e2fc6b18
...
@@ -379,7 +379,7 @@
...
@@ -379,7 +379,7 @@
<string
name=
"register"
>
注册萌卡
</string>
<string
name=
"register"
>
注册萌卡
</string>
<string
name=
"sign_out"
>
切换账号
</string>
<string
name=
"sign_out"
>
切换账号
</string>
<string
name=
"deck_square"
>
卡组广场
</string>
<string
name=
"deck_square"
>
卡组广场
</string>
<string
name=
"my_deck_online"
>
云
备份
</string>
<string
name=
"my_deck_online"
>
在线
备份
</string>
<string
name=
"input_contributor_name"
>
输入共享者名称
</string>
<string
name=
"input_contributor_name"
>
输入共享者名称
</string>
<string
name=
"sort_by_time"
>
按时间顺序
</string>
<string
name=
"sort_by_time"
>
按时间顺序
</string>
<string
name=
"sort_by_thumb"
>
按点赞顺序
</string>
<string
name=
"sort_by_thumb"
>
按点赞顺序
</string>
...
...
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