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
aaa3775f
Commit
aaa3775f
authored
Jul 11, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将云备份需要获取的列表类型改为MyOnlineDeckDetail,并启动卡组编辑时缓存一份
parent
0db316ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
83 deletions
+81
-83
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+17
-7
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
...mb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
+17
-16
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/MyDeckListAdapter.java
...ymb/ygomobile/ui/cards/deck_square/MyDeckListAdapter.java
+47
-60
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
aaa3775f
...
...
@@ -63,6 +63,7 @@ import org.greenrobot.eventbus.Subscribe;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -95,9 +96,7 @@ import cn.garymb.ygomobile.ui.cards.deck_square.DeckSquareApiUtil;
import
cn.garymb.ygomobile.ui.cards.deck_square.DeckSquareFileUtil
;
import
cn.garymb.ygomobile.ui.cards.deck_square.api_response.BasicResponse
;
import
cn.garymb.ygomobile.ui.cards.deck_square.api_response.DownloadDeckResponse
;
import
cn.garymb.ygomobile.ui.cards.deck_square.api_response.LoginToken
;
import
cn.garymb.ygomobile.ui.cards.deck_square.api_response.MyOnlineDeckDetail
;
import
cn.garymb.ygomobile.ui.cards.deck_square.api_response.PushSingleDeckResponse
;
import
cn.garymb.ygomobile.ui.home.HomeActivity
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
...
...
@@ -127,7 +126,7 @@ import ocgcore.enums.LimitType;
* RecyclerViewItemListener.OnItemListener中
*/
public
class
DeckManagerFragment
extends
BaseFragemnt
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
,
YGODeckDialogUtil
.
OnDeckMenuListener
,
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
private
static
final
String
TAG
=
"
seesee
"
;
private
static
final
String
TAG
=
"
DeckManagerFragment
"
;
protected
DrawerLayout
mDrawerLayout
;
protected
RecyclerView
mListView
;
protected
CardLoader
mCardLoader
;
...
...
@@ -140,7 +139,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
private
String
mDeckId
;
private
LinearLayout
ll_click_like
;
private
TextView
tv_add_1
;
public
static
List
<
MyOnlineDeckDetail
>
originalData
;
// 保存原始数据
protected
int
screenWidth
;
//region ui onCreate/onDestroy
...
...
@@ -165,7 +164,10 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
activity
=
(
HomeActivity
)
getActivity
();
originalData
=
new
ArrayList
<>();
layoutView
=
inflater
.
inflate
(
R
.
layout
.
fragment_deck_cards
,
container
,
false
);
AnimationShake2
(
layoutView
);
initView
(
layoutView
);
...
...
@@ -252,11 +254,15 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/** 自动同步 */
if
(
SharedPreferenceUtil
.
getServerToken
()
!=
null
)
{
VUiKit
.
defer
().
when
(()
->
{
return
DeckSquareApiUtil
.
synchronizeDecks
();
try
{
DeckSquareApiUtil
.
synchronizeDecks
();
}
catch
(
IOException
e
)
{
return
e
;
}
return
0
;
}).
fail
((
e
)
->
{
LogUtil
.
i
(
TAG
,
"sync deck fail"
+
e
.
getMessage
()
);
YGOUtil
.
showTextToast
(
"Sync decks failed: "
+
e
);
}).
done
((
result
)
->
{
LogUtil
.
i
(
TAG
,
"sync deck success"
);
});
}
}
...
...
@@ -1303,6 +1309,10 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
YGOUtil
.
showTextToast
(
R
.
string
.
done
);
}
public
static
List
<
MyOnlineDeckDetail
>
getOriginalData
()
{
return
originalData
;
}
//在卡组选择的dialog中点击某个卡组(来自本地或服务器)后,dialog通过本回调函数通知本页面。
//在本页面中根据卡组来源(本地或服务器)显示卡组内容
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/DeckSquareFileUtil.java
View file @
aaa3775f
...
...
@@ -23,6 +23,7 @@ import java.util.TimeZone;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.ui.cards.deck_square.api_response.MyOnlineDeckDetail
;
import
cn.garymb.ygomobile.ui.cards.deck_square.bo.MyDeckItem
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
...
...
@@ -33,22 +34,22 @@ import ocgcore.data.Card;
public
class
DeckSquareFileUtil
{
//
private
static
final
String
TAG
=
"decksquareApiUtil"
;
//private static final String TAG = DeckSquareListAdapter.class.getSimpleName();
// public static List<String> readLastLinesWithNIO(File file, int numLine
s) {
// try {
// List<String> lines = Files.readAllLines(file);
// int fromIndex = Math.max(0, lines.size() - numLines
);
// return lines.subList(fromIndex, lines.siz
e());
// } catch (IOException e) {
// e.printStackTrace(
);
// return Collections.emptyList(
);
// }
// }
//
// 使用示例
// Path logPath = Paths.get(context.getFilesDir().getAbsolutePath(), "log.txt")
;
// List<String> lastTwo = readLastLinesWithNIO(logPath, 2);
//将MyOnlineDeckDetail转MyDeckItem类型list,有时候会需要用到
public
static
List
<
MyDeckItem
>
toDeckItemList
(
List
<
MyOnlineDeckDetail
>
serverDeck
s
)
{
List
<
MyDeckItem
>
myOnlineDecks
=
new
ArrayList
<>();
for
(
MyOnlineDeckDetail
detail
:
serverDecks
)
{
MyDeckItem
item
=
new
MyDeckItem
(
);
item
.
setDeckName
(
detail
.
getDeckNam
e
());
item
.
setDeckId
(
detail
.
getDeckId
());
item
.
setUserId
(
detail
.
getUserId
()
);
item
.
setDeckCoverCard1
(
detail
.
getDeckCoverCard1
()
);
item
.
setUpdateDate
(
detail
.
getDeckUpdateDate
());
item
.
setPublic
(
detail
.
isPublic
());
myOnlineDecks
.
add
(
item
);
}
return
myOnlineDecks
;
}
//读取file指定的ydk文件,返回其内包含的deckId。如果不包含deckId,返回null
public
static
String
getId
(
File
file
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck_square/MyDeckListAdapter.java
View file @
aaa3775f
package
cn.garymb.ygomobile.ui.cards.deck_square
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
cards
.
DeckManagerFragment
.
originalData
;
import
android.util.Log
;
import
android.widget.ImageView
;
...
...
@@ -26,90 +28,78 @@ import cn.garymb.ygomobile.utils.YGODeckDialogUtil;
import
cn.garymb.ygomobile.utils.YGOUtil
;
//提供“我的”卡组数据,打开后先从sharePreference查询,没有则从服务器查询,然后缓存到sharePreference
public
class
MyDeckListAdapter
extends
BaseQuickAdapter
<
My
DeckItem
,
BaseViewHolder
>
{
public
class
MyDeckListAdapter
extends
BaseQuickAdapter
<
My
OnlineDeckDetail
,
BaseViewHolder
>
{
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
YGODeckDialogUtil
.
OnDeckMenuListener
onDeckMenuListener
;
//通知外部调用方,(如调用本fragment的activity)
private
YGODeckDialogUtil
.
OnDeckDialogListener
mDialogListener
;
private
ImageLoader
imageLoader
;
private
List
<
MyDeckItem
>
originalData
;
// 保存原始数据
public
MyDeckListAdapter
(
int
layoutResId
,
YGODeckDialogUtil
.
OnDeckMenuListener
onDeckMenuListener
,
YGODeckDialogUtil
.
OnDeckDialogListener
mDialogListener
)
{
super
(
layoutResId
);
originalData
=
new
ArrayList
<>();
imageLoader
=
new
ImageLoader
();
this
.
onDeckMenuListener
=
onDeckMenuListener
;
this
.
mDialogListener
=
mDialogListener
;
}
public
void
loadData
()
{
List
<
MyDeckItem
>
myOnlineDecks
=
new
ArrayList
<>();
LoginToken
loginToken
=
DeckSquareApiUtil
.
getLoginData
();
if
(
loginToken
==
null
)
{
return
;
}
if
(
originalData
.
isEmpty
()){
final
DialogPlus
dialog_read_ex
=
DialogPlus
.
show
(
getContext
(),
null
,
getContext
().
getString
(
R
.
string
.
fetch_online_deck
));
VUiKit
.
defer
().
when
(()
->
{
MyDeckResponse
result
=
DeckSquareApiUtil
.
getUserDecks
(
loginToken
);
if
(
result
==
null
)
return
null
;
else
return
result
.
getData
();
}).
fail
((
e
)
->
{
Log
.
e
(
TAG
,
e
+
""
);
if
(
dialog_read_ex
.
isShowing
())
{
//关闭异常
try
{
dialog_read_ex
.
dismiss
();
}
catch
(
Exception
ex
)
{
}
}
LogUtil
.
i
(
TAG
,
"load mycard from server failed:"
+
e
);
}).
done
((
serverDecks
)
->
{
if
(
serverDecks
!=
null
)
{
//将服务端的卡组也放到LocalDecks中
originalData
.
clear
();
//虽然判断originalData是空的才会执行到这里,但还是写上保险
originalData
.
addAll
(
serverDecks
);
// 保存原始数据
}
final
DialogPlus
dialog_read_ex
=
DialogPlus
.
show
(
getContext
(),
null
,
getContext
().
getString
(
R
.
string
.
fetch_online_deck
));
VUiKit
.
defer
().
when
(()
->
{
MyDeckResponse
result
=
DeckSquareApiUtil
.
getUserDecks
(
loginToken
);
if
(
result
==
null
)
{
return
null
;
}
else
{
return
result
.
getData
();
}
LogUtil
.
i
(
TAG
,
"load mycard from server done"
);
}).
fail
((
e
)
->
{
Log
.
e
(
TAG
,
e
+
""
);
if
(
dialog_read_ex
.
isShowing
())
{
//关闭异常
try
{
dialog_read_ex
.
dismiss
();
}
catch
(
Exception
ex
)
{
getData
().
clear
();
addData
(
serverDecks
);
notifyDataSetChanged
();
if
(
dialog_read_ex
.
isShowing
())
{
try
{
dialog_read_ex
.
dismiss
();
}
catch
(
Exception
ex
)
{
}
}
}
LogUtil
.
i
(
TAG
,
"load mycard from server fail"
);
}).
done
((
serverDecks
)
->
{
if
(
serverDecks
!=
null
)
{
//将服务端的卡组也放到LocalDecks中
for
(
MyOnlineDeckDetail
detail
:
serverDecks
)
{
MyDeckItem
item
=
new
MyDeckItem
();
item
.
setDeckName
(
detail
.
getDeckName
());
item
.
setDeckId
(
detail
.
getDeckId
());
item
.
setUserId
(
detail
.
getUserId
());
item
.
setDeckCoverCard1
(
detail
.
getDeckCoverCard1
());
item
.
setUpdateDate
(
detail
.
getDeckUpdateDate
());
item
.
setPublic
(
detail
.
isPublic
());
myOnlineDecks
.
add
(
item
);
}
}
LogUtil
.
i
(
TAG
,
"load mycard from server done"
);
originalData
.
clear
();
originalData
.
addAll
(
myOnlineDecks
);
// 保存原始数据
});
}
else
{
LogUtil
.
i
(
TAG
,
"load originalData done"
);
getData
().
clear
();
addData
(
myOnlineDecks
);
addData
(
originalData
);
notifyDataSetChanged
();
}
if
(
dialog_read_ex
.
isShowing
())
{
try
{
dialog_read_ex
.
dismiss
();
}
catch
(
Exception
ex
)
{
}
}
});
}
// 筛选函数
public
void
filter
(
String
keyword
)
{
List
<
My
DeckItem
>
filteredList
=
new
ArrayList
<>();
List
<
My
OnlineDeckDetail
>
filteredList
=
new
ArrayList
<>();
if
(
keyword
.
isEmpty
())
{
// 如果关键词为空,则显示所有数据
filteredList
.
addAll
(
originalData
);
}
else
{
// 遍历原始数据,筛选出包含关键词的item
for
(
My
DeckItem
item
:
originalData
)
{
for
(
My
OnlineDeckDetail
item
:
originalData
)
{
if
(
item
.
getDeckName
().
contains
(
keyword
))
{
filteredList
.
add
(
item
);
}
...
...
@@ -121,10 +111,7 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
notifyDataSetChanged
();
}
public
List
<
MyDeckItem
>
getOriginalData
(){
return
this
.
originalData
;
}
private
void
deleteMyDeckOnLine
(
MyDeckItem
item
)
{
private
void
deleteMyDeckOnLine
(
MyOnlineDeckDetail
item
)
{
if
(
item
!=
null
)
{
LoginToken
loginToken
=
DeckSquareApiUtil
.
getLoginData
();
if
(
loginToken
==
null
)
{
...
...
@@ -150,14 +137,14 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
* 注意,更新卡组状态要过很久才生效(实测延迟偶尔达5s)
* @param item
*/
private
void
changeDeckPublicState
(
My
DeckItem
item
)
{
private
void
changeDeckPublicState
(
My
OnlineDeckDetail
item
)
{
if
(
item
!=
null
)
{
LoginToken
loginToken
=
DeckSquareApiUtil
.
getLoginData
();
if
(
loginToken
==
null
)
{
return
;
}
VUiKit
.
defer
().
when
(()
->
{
BasicResponse
result
=
DeckSquareApiUtil
.
setDeckPublic
(
item
.
getDeckId
(),
loginToken
,
item
.
get
Public
());
BasicResponse
result
=
DeckSquareApiUtil
.
setDeckPublic
(
item
.
getDeckId
(),
loginToken
,
item
.
is
Public
());
return
result
;
}).
fail
(
e
->
{
LogUtil
.
i
(
TAG
,
"切换显示失败"
+
e
.
getMessage
());
...
...
@@ -168,12 +155,12 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
}
@Override
protected
void
convert
(
BaseViewHolder
helper
,
My
DeckItem
item
)
{
protected
void
convert
(
BaseViewHolder
helper
,
My
OnlineDeckDetail
item
)
{
helper
.
setText
(
R
.
id
.
my_deck_name
,
item
.
getDeckName
());
helper
.
setText
(
R
.
id
.
deck_update_date
,
item
.
getUpdateDate
());
helper
.
setText
(
R
.
id
.
deck_update_date
,
item
.
get
Deck
UpdateDate
());
ImageView
cardImage
=
helper
.
getView
(
R
.
id
.
deck_info_image
);
long
code
=
item
.
getDeckCoverCard1
();
if
(
item
.
get
Public
())
{
if
(
item
.
is
Public
())
{
helper
.
setText
(
R
.
id
.
change_show_or_hide
,
R
.
string
.
in_public
);
helper
.
getView
(
R
.
id
.
show_on_deck_square
).
setBackgroundResource
(
R
.
drawable
.
baseline_remove_red_eye_24
);
helper
.
getView
(
R
.
id
.
ll_switch_show
).
setBackgroundResource
(
R
.
drawable
.
button_radius_red
);
...
...
@@ -191,7 +178,7 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
deleteMyDeckOnLine
(
item
);
});
helper
.
getView
(
R
.
id
.
ll_switch_show
).
setOnClickListener
(
view
->
{
if
(
item
.
get
Public
())
{
if
(
item
.
is
Public
())
{
helper
.
setText
(
R
.
id
.
change_show_or_hide
,
R
.
string
.
in_personal_use
);
helper
.
getView
(
R
.
id
.
show_on_deck_square
).
setBackgroundResource
(
R
.
drawable
.
closed_eyes_24
);
helper
.
getView
(
R
.
id
.
ll_switch_show
).
setBackgroundResource
(
R
.
drawable
.
button_radius_n
);
...
...
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