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
89d3c398
Commit
89d3c398
authored
Dec 21, 2024
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加PackManager管理卡包展示文件名和codes
在卡片详情添加显示卡包名称
parent
1e3b3746
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
149 additions
and
35 deletions
+149
-35
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListAdapter.java
...n/java/cn/garymb/ygomobile/ex_card/ExCardListAdapter.java
+1
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
...rc/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
+5
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+0
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+0
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/DeckUtil.java
mobile/src/main/java/cn/garymb/ygomobile/utils/DeckUtil.java
+1
-3
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
+0
-3
mobile/src/main/java/ocgcore/DataManager.java
mobile/src/main/java/ocgcore/DataManager.java
+6
-10
mobile/src/main/java/ocgcore/PackManager.java
mobile/src/main/java/ocgcore/PackManager.java
+130
-0
mobile/src/main/java/ocgcore/StringManager.java
mobile/src/main/java/ocgcore/StringManager.java
+3
-2
mobile/src/main/res/layout/dialog_cardinfo.xml
mobile/src/main/res/layout/dialog_cardinfo.xml
+2
-6
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListAdapter.java
View file @
89d3c398
...
...
@@ -60,7 +60,7 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold
}
}).
fail
((
e
)
->
{
Log
.
e
(
"seesee"
,
e
+
""
);
Log
.
e
(
TAG
,
e
+
""
);
if
(
dialog_read_ex
.
isShowing
())
{
//关闭异常
try
{
dialog_read_ex
.
dismiss
();
...
...
@@ -71,7 +71,6 @@ public class ExCardListAdapter extends BaseQuickAdapter<ExCardData, BaseViewHold
LogUtil
.
i
(
TAG
,
"webCrawler fail"
);
}).
done
((
exCardDataList
)
->
{
Log
.
w
(
"seesee"
,
exCardDataList
+
""
);
if
(
exCardDataList
!=
null
)
{
LogUtil
.
i
(
TAG
,
"webCrawler done"
);
getData
().
clear
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
View file @
89d3c398
...
...
@@ -40,6 +40,7 @@ import cn.garymb.ygomobile.utils.FileUtils;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.CardManager
;
import
ocgcore.DataManager
;
import
ocgcore.PackManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.enums.CardType
;
...
...
@@ -55,6 +56,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
private
static
final
String
TAG
=
String
.
valueOf
(
CardDetail
.
class
);
private
final
CardManager
cardManager
;
private
final
PackManager
packManager
;
private
final
ImageView
cardImage
;
private
final
TextView
name
;
private
final
TextView
desc
;
...
...
@@ -162,6 +164,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
attrView
=
findViewById
(
R
.
id
.
card_attribute
);
lbSetCode
=
findViewById
(
R
.
id
.
label_setcode
);
cardManager
=
DataManager
.
get
().
getCardManager
();
packManager
=
DataManager
.
get
().
getPackManager
();
close
.
setOnClickListener
((
v
)
->
{
if
(
mListener
!=
null
)
{
mListener
.
onClose
();
...
...
@@ -274,7 +277,8 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
cardImage
.
setOnClickListener
((
v
)
->
{
showCardImageDetail
(
cardInfo
.
Code
);
});
packName
.
setText
(
getPackName
());
packName
.
setText
(
packManager
.
findFileNameById
(
cardInfo
.
Alias
!=
0
?
cardInfo
.
Alias
:
cardInfo
.
Code
));
name
.
setText
(
cardInfo
.
Name
);
if
(
cardInfo
.
Name
.
equals
(
"Unknown"
))
{
desc
.
setText
(
R
.
string
.
tip_card_info_diff
);
...
...
@@ -367,11 +371,6 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
}
}
private
String
getPackName
(
Card
cardInfo
)
{
String
packname
=
""
;
return
packname
;
}
private
void
showCardImageDetail
(
int
code
)
{
View
view
=
dialog
.
initDialog
(
context
,
R
.
layout
.
dialog_photo
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
89d3c398
...
...
@@ -35,7 +35,6 @@ import android.widget.EditText;
import
android.widget.ImageView
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
89d3c398
...
...
@@ -18,7 +18,6 @@ import android.util.Log;
import
android.view.Gravity
;
import
android.view.MenuItem
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
89d3c398
...
...
@@ -154,7 +154,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
try
{
ServerUtil
.
refreshServer
(
activity
);
}
catch
(
IOException
e
)
{
Log
.
e
(
"seesee"
,
e
+
""
);
Log
.
e
(
TAG
,
e
+
""
);
}
//showNewbieGuide("homePage");
return
layoutView
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/DeckUtil.java
View file @
89d3c398
...
...
@@ -186,9 +186,7 @@ public class DeckUtil {
String
name
=
entry
.
getName
();
name
=
name
.
substring
(
name
.
lastIndexOf
(
"/"
));
InputStream
inputStream
=
zipFile
.
getInputStream
(
entry
);
deckList
.
add
(
new
DeckFile
(
IOUtils
.
asFile
(
inputStream
,
appsSettings
.
getCacheDeckDir
()
+
"/"
+
name
)));
deckList
.
add
(
new
DeckFile
(
IOUtils
.
asFile
(
inputStream
,
appsSettings
.
getCacheDeckDir
()
+
"/"
+
name
)));
}
}
}
finally
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
View file @
89d3c398
...
...
@@ -58,7 +58,6 @@ public class ServerUtil {
LogUtil
.
i
(
TAG
,
"server util, old pre-card version:"
+
oldVer
);
String
URL_DATAVER
=
URL_CN_DATAVER
;
URL_DATAVER
=
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
Chinese
.
code
)
?
URL_CN_DATAVER
:
"https://github.com/DaruKani/TransSuperpre/blob/main/"
+
getLanguageId
()
+
"/version.txt"
;
Log
.
w
(
"seesee"
,
URL_DATAVER
);
OkhttpUtil
.
get
(
URL_DATAVER
,
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
...
...
@@ -318,7 +317,6 @@ public class ServerUtil {
String
url
;
url
=
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
Chinese
.
code
)
?
URL_SUPERPRE_CN_FILE
:
"https://raw.githubusercontent.com/DaruKani/TransSuperpre/refs/heads/main/"
+
getLanguageId
()
+
"/ygopro-super-pre.ypk"
;
Log
.
w
(
"seesee"
,
url
);
return
url
;
}
...
...
@@ -326,7 +324,6 @@ public class ServerUtil {
String
json
;
json
=
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
Chinese
.
code
)
?
URL_PRE_CARD
:
"https://raw.githubusercontent.com/DaruKani/TransSuperpre/refs/heads/main/"
+
getLanguageId
()
+
"/test-release.json"
;
Log
.
w
(
"seesee"
,
json
);
return
json
;
}
public
enum
ExCardState
{
...
...
mobile/src/main/java/ocgcore/DataManager.java
View file @
89d3c398
package
ocgcore
;
import
org.greenrobot.eventbus.EventBus
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.loader.CardLoader
;
/**
* 单例模式,使用get()方式自动获取单例
* 其field包括StringManager、LimitManager、CardManager
* 其field包括StringManager、
PackManager、
LimitManager、CardManager
*/
public
class
DataManager
{
private
static
DataManager
sLoader
=
null
;
...
...
@@ -28,29 +25,27 @@ public class DataManager {
}
private
final
StringManager
mStringManager
;
private
final
PackManager
mPackManager
;
private
final
LimitManager
mLimitManager
;
private
final
CardManager
mCardManager
;
private
DataManager
()
{
mStringManager
=
new
StringManager
();
mPackManager
=
new
PackManager
();
mLimitManager
=
new
LimitManager
();
mCardManager
=
new
CardManager
(
AppsSettings
.
get
().
getDataBasePath
(),
AppsSettings
.
get
().
getExpansionsPath
().
getAbsolutePath
());
}
public
StringManager
getStringManager
()
{
return
mStringManager
;
}
public
StringManager
getStringManager
()
{
return
mStringManager
;}
public
PackManager
getPackManager
()
{
return
mPackManager
;}
public
LimitManager
getLimitManager
()
{
return
mLimitManager
;
}
public
CardManager
getCardManager
()
{
return
mCardManager
;
}
private
boolean
mInit
;
public
void
load
(
boolean
force
)
{
...
...
@@ -64,6 +59,7 @@ public class DataManager {
}
if
(
needLoad
)
{
mStringManager
.
load
();
mPackManager
.
load
();
mLimitManager
.
load
();
mCardManager
.
loadCards
();
}
...
...
mobile/src/main/java/ocgcore/PackManager.java
0 → 100644
View file @
89d3c398
package
ocgcore
;
import
android.util.Log
;
import
java.io.BufferedReader
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.nio.charset.StandardCharsets
;
import
java.util.AbstractMap
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
public
class
PackManager
implements
Closeable
{
private
static
final
String
TAG
=
PackManager
.
class
.
getSimpleName
();
private
final
List
<
Map
.
Entry
<
String
,
List
<
Integer
>>>
packList
=
new
ArrayList
<>();
public
PackManager
()
{
}
@Override
public
void
close
()
{
// 如果有需要清理的资源,在这里处理
packList
.
clear
();
}
public
boolean
load
()
{
packList
.
clear
();
boolean
rs1
=
loadFile
(
AppsSettings
.
get
().
getResourcePath
()
+
"/"
+
Constants
.
CORE_PACK_PATH
);
boolean
rs2
=
loadFile
(
AppsSettings
.
get
().
getExpansionsPath
()
+
"/"
+
Constants
.
CORE_PACK_PATH
);
boolean
res3
=
loadFile
(
AppsSettings
.
get
().
getCacheDeckDir
());
return
rs1
&&
rs2
&&
res3
;
}
public
boolean
loadFile
(
String
path
)
{
if
(
path
==
null
||
path
.
isEmpty
())
{
Log
.
e
(
TAG
,
"Invalid path provided."
);
return
false
;
}
File
file
=
new
File
(
path
);
File
[]
fileList
=
file
.
listFiles
();
if
(
fileList
==
null
||
fileList
.
length
==
0
)
{
Log
.
w
(
TAG
,
"No files found in the directory: "
+
path
);
return
false
;
}
VUiKit
.
defer
().
when
(()
->
{
for
(
File
packYdk
:
fileList
)
{
if
(
packYdk
.
isFile
()
&&
packYdk
.
getName
().
endsWith
(
Constants
.
YDK_FILE_EX
))
{
try
{
processFile
(
packYdk
);
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"Error processing file: "
+
packYdk
.
getAbsolutePath
(),
e
);
}
}
}
return
packList
;
}).
done
((
list
)
->
{
Log
.
i
(
TAG
,
"Loaded "
+
list
.
size
()
+
" files."
);
Log
.
i
(
TAG
,
toString
());
// 在异步任务完成后打印packList
}).
fail
((
error
)
->
{
Log
.
e
(
TAG
,
"Error loading files: "
+
error
.
getMessage
());
});
return
true
;
}
private
void
processFile
(
File
file
)
throws
IOException
{
List
<
Integer
>
ids
=
new
ArrayList
<>();
try
(
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
InputStreamReader
in
=
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
);
BufferedReader
reader
=
new
BufferedReader
(
in
))
{
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
startsWith
(
"#"
))
{
continue
;
}
try
{
int
id
=
Integer
.
parseInt
(
line
.
trim
());
ids
.
add
(
id
);
}
catch
(
NumberFormatException
e
)
{
Log
.
w
(
TAG
,
"Skipping invalid line in file "
+
file
.
getName
()
+
": "
+
line
);
}
}
if
(!
ids
.
isEmpty
())
{
packList
.
add
(
new
AbstractMap
.
SimpleEntry
<>(
file
.
getName
(),
ids
));
}
}
}
/**
* 通过给定的ID在packList中查找对应的String名称。
*
* @param id 要查找的ID。
* @return 如果找到匹配项,则返回对应的文件名;否则返回null。
*/
public
String
findFileNameById
(
Integer
id
)
{
for
(
Map
.
Entry
<
String
,
List
<
Integer
>>
entry
:
packList
)
{
if
(
entry
.
getValue
().
contains
(
id
))
{
return
entry
.
getKey
().
substring
(
0
,
entry
.
getKey
().
lastIndexOf
(
Constants
.
YDK_FILE_EX
));
}
}
return
null
;
// 如果没有找到匹配项,则返回null
}
/**
* 将packList的内容转换为字符串表示。
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
"PackList content:\n"
);
for
(
int
i
=
0
;
i
<
packList
.
size
();
i
++)
{
Map
.
Entry
<
String
,
List
<
Integer
>>
entry
=
packList
.
get
(
i
);
sb
.
append
(
"Entry "
).
append
(
i
+
1
).
append
(
": "
).
append
(
entry
.
getKey
()).
append
(
" -> ["
);
sb
.
append
(
String
.
join
(
", "
,
entry
.
getValue
().
stream
().
map
(
String:
:
valueOf
).
toArray
(
String
[]::
new
)));
sb
.
append
(
"]\n"
);
}
return
sb
.
toString
();
}
}
\ No newline at end of file
mobile/src/main/java/ocgcore/StringManager.java
View file @
89d3c398
...
...
@@ -4,6 +4,9 @@ import android.text.TextUtils;
import
android.util.Log
;
import
android.util.SparseArray
;
import
com.file.zip.ZipEntry
;
import
com.file.zip.ZipFile
;
import
java.io.BufferedReader
;
import
java.io.Closeable
;
import
java.io.File
;
...
...
@@ -16,8 +19,6 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.List
;
import
com.file.zip.ZipEntry
;
import
com.file.zip.ZipFile
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
...
...
mobile/src/main/res/layout/dialog_cardinfo.xml
View file @
89d3c398
...
...
@@ -179,7 +179,7 @@
android:id=
"@+id/ll_pack"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"
horizont
al"
>
android:orientation=
"
vertic
al"
>
<TextView
android:layout_width=
"wrap_content"
...
...
@@ -195,7 +195,6 @@
android:layout_gravity=
"center"
android:gravity=
"center_vertical"
android:maxLines=
"1"
android:paddingLeft=
"4dp"
android:singleLine=
"true"
android:textAppearance=
"@style/TextAppearance.AppCompat.Caption"
android:textColor=
"@color/holo_blue_bright"
...
...
@@ -205,7 +204,7 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"
horizont
al"
>
android:orientation=
"
vertic
al"
>
<TextView
android:layout_width=
"wrap_content"
...
...
@@ -218,7 +217,6 @@
android:id=
"@+id/card_ot"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"5dp"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"@color/white"
tools:text=
"Test"
/>
...
...
@@ -336,7 +334,6 @@
android:id=
"@+id/card_type"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:lines=
"2"
android:maxLines=
"2"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"@color/holo_green_bright"
/>
...
...
@@ -355,7 +352,6 @@
android:id=
"@+id/card_setname"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:lines=
"4"
android:maxLines=
"4"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textColor=
"@color/holo_orange_bright"
...
...
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