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
70fb40fa
Commit
70fb40fa
authored
Nov 10, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加undo与redo功能
对挪动,删除,添加都存一份历史deckinfo数组
parent
94c7fd18
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
378 additions
and
143 deletions
+378
-143
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
+3
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+184
-35
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckAdapater.java
.../java/cn/garymb/ygomobile/ui/cards/deck/DeckAdapater.java
+48
-11
mobile/src/main/res/drawable/ic_redo.xml
mobile/src/main/res/drawable/ic_redo.xml
+5
-0
mobile/src/main/res/drawable/ic_undo.xml
mobile/src/main/res/drawable/ic_undo.xml
+5
-0
mobile/src/main/res/layout/fragment_deck_cards.xml
mobile/src/main/res/layout/fragment_deck_cards.xml
+133
-94
No files found.
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
View file @
70fb40fa
...
...
@@ -20,9 +20,9 @@ public class DeckInfo {
Side
,
}
p
rivate
final
List
<
Card
>
mainCards
;
p
rivate
final
List
<
Card
>
extraCards
;
p
rivate
final
List
<
Card
>
sideCards
;
p
ublic
List
<
Card
>
mainCards
;
p
ublic
List
<
Card
>
extraCards
;
p
ublic
List
<
Card
>
sideCards
;
private
final
List
<
Card
>
allCards
;
public
File
source
;
//当前打开的ydk文件的file
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
70fb40fa
...
...
@@ -4,7 +4,6 @@ import static android.content.Context.CLIPBOARD_SERVICE;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
cards
.
deck_square
.
DeckSquareFileUtil
.
convertToUnixTimestamp
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
...
...
@@ -33,6 +32,7 @@ import android.view.animation.AnimationUtils;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.Spinner
;
...
...
@@ -127,6 +127,9 @@ import ocgcore.enums.LimitType;
*/
public
class
DeckManagerFragment
extends
BaseFragemnt
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
,
YGODeckDialogUtil
.
OnDeckMenuListener
,
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
private
static
final
String
TAG
=
"DeckManagerFragment"
;
public
static
List
<
MyOnlineDeckDetail
>
originalData
;
// 保存原始数据
private
final
AppsSettings
mSettings
=
AppsSettings
.
get
();
public
DeckAdapater
mDeckAdapater
;
protected
DrawerLayout
mDrawerLayout
;
protected
RecyclerView
mListView
;
protected
CardLoader
mCardLoader
;
...
...
@@ -135,19 +138,19 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
protected
PackManager
mPackManager
;
protected
CardListAdapter
mCardListAdapter
;
protected
boolean
isLoad
=
false
;
protected
int
screenWidth
;
long
exitLasttime
=
0
;
private
HomeActivity
activity
;
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
private
RecyclerView
mRecyclerView
;
public
DeckAdapater
mDeckAdapater
;
private
final
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
BaseActivity
mContext
;
long
exitLasttime
=
0
;
// 历史记录列表,用于存储卡组状态
private
List
<
DeckInfo
>
deckHistory
=
new
ArrayList
<>();
// 当前历史记录索引
private
int
historyIndex
=
-
1
;
private
File
mPreLoadFile
;
//预加载卡组,用于外部打开ydk文件或通过卡组广场预览卡组时,值为file。当未通过预加载打开ydk(打开卡组时),值为null
private
DeckItemTouchHelper
mDeckItemTouchHelper
;
...
...
@@ -158,13 +161,21 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
private
DialogPlus
mDialog
;
private
DialogPlus
builderShareLoading
;
private
ImageButton
btnUndo
;
private
ImageButton
btnRedo
;
private
View
layoutView
;
public
static
List
<
MyOnlineDeckDetail
>
getOriginalData
()
{
return
originalData
;
}
/**
* 创建并返回Fragment的视图层次结构
*
* @param inflater 用于将XML布局文件转换为View对象的LayoutInflater实例,不可为空
* @param container 父容器ViewGroup,可为空
* @param inflater
用于将XML布局文件转换为View对象的LayoutInflater实例,不可为空
* @param container
父容器ViewGroup,可为空
* @param savedInstanceState 保存Fragment状态的Bundle对象,可为空
* @return 返回创建的View对象,如果创建失败则返回null
*/
...
...
@@ -295,6 +306,16 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
getActivity
().
getSupportFragmentManager
(),
"pagerDialog"
);
});
// 初始化撤销/重做按钮
btnUndo
=
layoutView
.
findViewById
(
R
.
id
.
btn_undo
);
btnRedo
=
layoutView
.
findViewById
(
R
.
id
.
btn_redo
);
btnUndo
.
setOnClickListener
(
v
->
undo
());
btnRedo
.
setOnClickListener
(
v
->
redo
());
// 初始化按钮状态
updateUndoRedoButtons
();
mContext
=
(
BaseActivity
)
getActivity
();
/**
...
...
@@ -367,7 +388,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 设置列表项点击监听器和滚动监听器
*
*
<p>
* 该方法主要完成以下功能:
* 1. 为卡片列表适配器设置点击和长按事件监听器
* 2. 为列表视图添加滚动监听器,用于控制图片加载框架的暂停和恢复
...
...
@@ -452,12 +473,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
/**
* 处理卡组中卡片的长按删除操作
* 当用户长按卡片时,根据设置决定是否显示删除确认对话框或直接删除
*
* @param pos 被长按的卡片在列表中的位置索引
*/
@Override
public
void
onDragLongPress
(
int
pos
)
{
// 检查位置索引有效性
...
...
@@ -481,6 +496,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
dialogPlus
.
setLeftButtonListener
((
dlg
,
v
)
->
{
dlg
.
dismiss
();
mDeckItemTouchHelper
.
remove
(
pos
);
// 添加到历史记录
addDeckToHistory
(
mDeckAdapater
.
getCurrentState
());
});
dialogPlus
.
show
();
}
else
{
...
...
@@ -493,7 +510,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
public
void
onDragLongPressEnd
()
{
mDeckAdapater
.
hideHeadView
();
}
//endregion
public
void
AnimationShake2
(
View
view
)
{
Animation
shake
=
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
shake
);
//加载动画资源文件
...
...
@@ -502,7 +518,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 隐藏所有打开的抽屉菜单
*
*
<p>
* 该方法会检查左右两侧的抽屉是否处于打开状态,如果打开则将其关闭。
* 主要用于在特定场景下统一关闭所有抽屉菜单,确保界面的一致性。
*/
...
...
@@ -528,6 +544,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
//region load deck
protected
void
showResult
(
boolean
autoClose
)
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
...
...
@@ -540,7 +558,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
//region load deck
//region init
/**
* 从指定文件中加载卡牌包数据
*
...
...
@@ -572,7 +591,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
});
}
//region init
/**
* 初始化函数,用于加载卡组数据和相关配置
*
...
...
@@ -635,8 +653,9 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 设置当前选中的卡组并更新界面显示
*
* @param deckInfo 选中的卡组信息,如果为null则创建新的空卡组信息对象
* @param isPack 是否为卡包模式
* @param isPack
是否为卡包模式
*/
private
void
setCurDeck
(
DeckInfo
deckInfo
,
boolean
isPack
)
{
// 处理空卡组信息情况
...
...
@@ -653,8 +672,118 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
// 通知适配器更新卡组数据和界面
mDeckAdapater
.
setDeck
(
deckInfo
,
isPack
);
mDeckAdapater
.
notifyDataSetChanged
();
// 清空历史记录并添加初始状态
clearDeckHistory
();
addDeckToHistory
(
deckInfo
);
// 更新按钮状态
updateUndoRedoButtons
();
}
/**
* 清空卡组历史记录
*/
private
void
clearDeckHistory
()
{
deckHistory
.
clear
();
historyIndex
=
-
1
;
}
/**
* 将当前卡组状态添加到历史记录中
*
* @param deckInfo 当前卡组状态
*/
private
void
addDeckToHistory
(
DeckInfo
deckInfo
)
{
// 如果当前不在历史记录的最新位置,需要删除之后的历史记录
if
(
historyIndex
<
deckHistory
.
size
()
-
1
)
{
deckHistory
.
subList
(
historyIndex
+
1
,
deckHistory
.
size
()).
clear
();
}
// 添加新的历史记录
deckHistory
.
add
(
deckInfo
);
// 使用clone确保是深拷贝
historyIndex
=
deckHistory
.
size
()
-
1
;
// 更新按钮状态
updateUndoRedoButtons
();
}
/**
* 撤销操作
*/
private
void
undo
()
{
if
(
canUndo
())
{
historyIndex
--;
DeckInfo
previousState
=
deckHistory
.
get
(
historyIndex
);
mDeckAdapater
.
setDeck
(
previousState
,
false
);
mDeckAdapater
.
notifyDataSetChanged
();
// 更新按钮状态
updateUndoRedoButtons
();
}
}
/**
* 重做操作
*/
private
void
redo
()
{
if
(
canRedo
())
{
historyIndex
++;
DeckInfo
nextState
=
deckHistory
.
get
(
historyIndex
);
mDeckAdapater
.
setDeck
(
nextState
,
false
);
mDeckAdapater
.
notifyDataSetChanged
();
// 更新按钮状态
updateUndoRedoButtons
();
}
}
/**
* 检查是否可以撤销
*
* @return 如果可以撤销返回true,否则返回false
*/
private
boolean
canUndo
()
{
return
historyIndex
>
0
;
}
/**
* 检查是否可以重做
*
* @return 如果可以重做返回true,否则返回false
*/
private
boolean
canRedo
()
{
return
historyIndex
<
deckHistory
.
size
()
-
1
;
}
/**
* 更新撤销/重做按钮的状态和可见性
*/
private
void
updateUndoRedoButtons
()
{
if
(
btnUndo
!=
null
&&
btnRedo
!=
null
)
{
// 只有历史记录大于1时才显示按钮
if
(
deckHistory
.
size
()
>
1
)
{
btnUndo
.
setVisibility
(
View
.
VISIBLE
);
btnRedo
.
setVisibility
(
View
.
VISIBLE
);
// 根据是否可以撤销/重做来启用/禁用按钮
btnUndo
.
setEnabled
(
canUndo
());
btnRedo
.
setEnabled
(
canRedo
());
// 当无法撤销或重做时隐藏对应按钮
if
(!
canUndo
())
{
btnUndo
.
setVisibility
(
View
.
GONE
);
}
if
(!
canRedo
())
{
btnRedo
.
setVisibility
(
View
.
GONE
);
}
}
else
{
// 历史记录小于等于1时隐藏按钮
btnUndo
.
setVisibility
(
View
.
GONE
);
btnRedo
.
setVisibility
(
View
.
GONE
);
}
}
}
/**
* 判断指定文件是否位于卡牌目录中
*
...
...
@@ -755,12 +884,12 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
mDialog
!=
null
&&
mDialog
.
isShowing
();
}
/**
/**
* 显示卡片详情对话框
*
* @param provider
卡片列表提供者,用于获取当前卡片的上下文数据
* @param cardInfo
要显示的卡片信息,如果为null则不执行任何操作
* @param pos
当前卡片在列表中的位置
* @param provider 卡片列表提供者,用于获取当前卡片的上下文数据
* @param cardInfo 要显示的卡片信息,如果为null则不执行任何操作
* @param pos 当前卡片在列表中的位置
*/
protected
void
showCardDialog
(
CardListProvider
provider
,
Card
cardInfo
,
int
pos
)
{
// 如果卡片信息为空,则不进行任何操作
...
...
@@ -855,7 +984,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
private
void
showSearchKeyWord
(
String
keyword
)
{
//使用此方法,可以适用关键词查询逻辑,让完全符合关键词的卡名置顶显示,并同时搜索字段和效果文本
CardSearchInfo
searchInfo
=
new
CardSearchInfo
.
Builder
().
keyword
(
keyword
).
types
(
new
long
[]{}).
build
();
//构建CardSearchInfo时type不能为null
mCardLoader
.
search
(
searchInfo
);
...
...
@@ -869,11 +997,21 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
/**
* 添加到副卡组
*
* @param cardInfo 要添加的卡片信息
* @return 添加成功返回true,添加失败返回false
*/
private
boolean
addSideCard
(
Card
cardInfo
)
{
// 检查卡片添加限制
if
(
checkLimit
(
cardInfo
))
{
// 执行添加卡片操作
boolean
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
SideCard
);
if
(
rs
)
{
YGOUtil
.
showTextToast
(
R
.
string
.
add_card_tip_ok
);
// 添加到历史记录
addDeckToHistory
(
mDeckAdapater
.
getCurrentState
());
}
else
{
YGOUtil
.
showTextToast
(
R
.
string
.
add_card_tip_fail
);
}
...
...
@@ -882,16 +1020,27 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
false
;
}
/**
* 添加主卡组卡片
*
* @param cardInfo 要添加的卡片信息
* @return 添加成功返回true,否则返回false
*/
private
boolean
addMainCard
(
Card
cardInfo
)
{
// 检查卡片添加限制
if
(
checkLimit
(
cardInfo
))
{
boolean
rs
;
// 根据卡片类型选择添加位置
if
(
cardInfo
.
isExtraCard
())
{
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
ExtraCard
);
}
else
{
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
MainCard
);
}
// 处理添加结果
if
(
rs
)
{
YGOUtil
.
showTextToast
(
R
.
string
.
add_card_tip_ok
);
// 添加到历史记录
addDeckToHistory
(
mDeckAdapater
.
getCurrentState
());
}
else
{
YGOUtil
.
showTextToast
(
R
.
string
.
add_card_tip_fail
);
}
...
...
@@ -1116,6 +1265,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 创建新的卡组文件
*
* @param savePath 新卡组文件的保存路径
*/
private
void
createDeck
(
String
savePath
)
{
...
...
@@ -1260,7 +1410,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
// shareUrl(uriString, label);
}
private
void
shareUrl
(
String
uri
,
String
label
)
{
String
url
=
getString
(
R
.
string
.
deck_share_head
)
+
" "
+
uri
;
ShareUtil
.
shareText
(
getContext
(),
getString
(
R
.
string
.
share_deck
),
url
,
null
);
...
...
@@ -1283,6 +1432,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 从存储卡组的文件夹中获取所有名字以.ydk结尾的文件,并将mPreLoadFile也加入到返回结果中
*
* @return 包含所有.ydk文件的文件列表,如果目录不存在或无法访问则返回null
*/
private
List
<
File
>
getYdkFiles
()
{
...
...
@@ -1311,8 +1461,9 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 初始化限制列表下拉框
*
* @param spinner 要初始化的Spinner控件
* @param cur 当前选中的限制列表对象,用于设置默认选中项
* @param cur
当前选中的限制列表对象,用于设置默认选中项
*/
private
void
initLimitListSpinners
(
Spinner
spinner
,
LimitList
cur
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
...
...
@@ -1360,6 +1511,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
/**
* 设置限制列表并更新相关适配器
*
* @param limitList 限制列表对象,如果为null则直接返回
*/
private
void
setLimitList
(
LimitList
limitList
)
{
...
...
@@ -1444,7 +1596,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
private
void
initBoomMenuButton
(
BoomMenuButton
menu
)
{
final
SparseArray
<
Integer
>
mMenuIds
=
new
SparseArray
<>();
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_share_deck
,
R
.
string
.
share_deck
,
R
.
drawable
.
shareicon
);
...
...
@@ -1511,10 +1662,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
YGOUtil
.
showTextToast
(
R
.
string
.
done
);
}
public
static
List
<
MyOnlineDeckDetail
>
getOriginalData
()
{
return
originalData
;
}
//在卡组选择的dialog中点击某个卡组(来自本地或服务器)后,dialog通过本回调函数通知本页面。
//在本页面中根据卡组来源(本地或服务器)显示卡组内容
@Override
...
...
@@ -1532,7 +1679,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}).
done
((
deckData
)
->
{
if
(
deckData
!=
null
)
{
mDeckId
=
deckData
.
getDeckId
();
LogUtil
.
i
(
TAG
,
deckData
.
toString
());
LogUtil
.
i
(
TAG
,
deckData
.
toString
());
String
fileFullName
=
deckData
.
getDeckName
()
+
YDK_FILE_EX
;
File
dir
=
new
File
(
getActivity
().
getApplicationInfo
().
dataDir
,
"cache"
);
//将卡组存到cache缓存目录中
...
...
@@ -1559,7 +1706,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
;
String
currentDeckPath
=
deck
.
getAbsolutePath
();
for
(
DeckFile
deckFile
:
deckFileList
)
{
LogUtil
.
w
(
TAG
,
"要删除的卡组:"
+
"\n卡组分类"
+
deckFile
.
getTypeName
()+
"\n卡组名称:"
+
deckFile
.
getFileName
()+
"\n卡组id"
+
deckFile
.
getDeckId
());
LogUtil
.
w
(
TAG
,
"要删除的卡组:"
+
"\n卡组分类"
+
deckFile
.
getTypeName
()
+
"\n卡组名称:"
+
deckFile
.
getFileName
()
+
"\n卡组id"
+
deckFile
.
getDeckId
());
if
(
TextUtils
.
equals
(
deckFile
.
getPath
(),
currentDeckPath
))
{
List
<
File
>
files
=
getYdkFiles
();
File
file
=
null
;
...
...
@@ -1627,6 +1774,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
@Override
public
void
onDragEnd
()
{
// 在拖拽结束后添加当前状态到历史记录中
addDeckToHistory
(
mDeckAdapater
.
getCurrentState
());
}
//https://www.jianshu.com/p/99649af3b191
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckAdapater.java
View file @
70fb40fa
...
...
@@ -40,12 +40,14 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private
final
SparseArray
<
Integer
>
mCount
=
new
SparseArray
<>();
private
final
Context
context
;
private
final
LayoutInflater
mLayoutInflater
;
private
final
int
Padding
=
1
;
private
final
RecyclerView
recyclerView
;
private
final
Random
mRandom
;
private
final
ImageLoader
imageLoader
;
private
ImageTop
mImageTop
;
private
int
mMainCount
;
private
int
mExtraCount
;
private
int
mSideCount
;
private
int
mMainMonsterCount
;
private
int
mMainSpellCount
;
private
int
mMainTrapCount
;
...
...
@@ -56,18 +58,13 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private
int
mSideMonsterCount
;
private
int
mSideSpellCount
;
private
int
mSideTrapCount
;
private
int
mFullWidth
;
private
int
mWidth
;
private
int
mHeight
;
private
final
int
Padding
=
1
;
private
final
RecyclerView
recyclerView
;
private
final
Random
mRandom
;
private
DeckViewHolder
mHeadHolder
;
private
DeckItem
mRemoveItem
;
private
int
mRemoveIndex
;
private
LimitList
mLimitList
;
private
final
ImageLoader
imageLoader
;
private
boolean
showHead
=
false
;
private
String
mDeckMd5
;
private
DeckInfo
mDeckInfo
;
...
...
@@ -98,6 +95,46 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
return
mCount
;
}
/**
* 获取当前卡组状态的副本
*
* @return 当前卡组状态的副本
*/
public
DeckInfo
getCurrentState
()
{
// 创建当前状态的深拷贝
DeckInfo
currentState
=
new
DeckInfo
();
// 从 mItems 中提取不同类型的卡片
List
<
Card
>
mainCards
=
new
ArrayList
<>();
List
<
Card
>
extraCards
=
new
ArrayList
<>();
List
<
Card
>
sideCards
=
new
ArrayList
<>();
for
(
DeckItem
item
:
mItems
)
{
if
(
item
!=
null
&&
item
.
getCardInfo
()
!=
null
)
{
switch
(
item
.
getType
())
{
case
MainCard:
mainCards
.
add
(
item
.
getCardInfo
());
break
;
case
ExtraCard:
extraCards
.
add
(
item
.
getCardInfo
());
break
;
case
SideCard:
sideCards
.
add
(
item
.
getCardInfo
());
break
;
}
}
}
currentState
.
mainCards
=
mainCards
;
currentState
.
extraCards
=
extraCards
;
currentState
.
sideCards
=
sideCards
;
// 通过 mDeckInfo 获取 source
if
(
mDeckInfo
!=
null
)
{
currentState
.
source
=
mDeckInfo
.
source
;
}
return
currentState
;
}
public
boolean
AddCard
(
Card
cardInfo
,
DeckItemType
type
)
{
if
(
cardInfo
==
null
)
return
false
;
if
(
cardInfo
.
isType
(
CardType
.
Token
))
{
...
...
@@ -151,10 +188,6 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
notifyItemRangeChanged
(
DeckItem
.
MainStart
,
DeckItem
.
MainStart
+
getMainCount
());
}
public
void
setLimitList
(
LimitList
limitList
)
{
mLimitList
=
limitList
;
}
private
boolean
comp
(
DeckItem
d1
,
DeckItem
d2
)
{
if
(
d1
.
getType
()
==
d2
.
getType
())
{
Card
c1
=
d1
.
getCardInfo
();
...
...
@@ -386,6 +419,10 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
return
mLimitList
;
}
public
void
setLimitList
(
LimitList
limitList
)
{
mLimitList
=
limitList
;
}
public
@Nullable
File
getYdkFile
()
{
if
(
mDeckInfo
!=
null
)
{
...
...
mobile/src/main/res/drawable/ic_redo.xml
0 → 100644
View file @
70fb40fa
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:height=
"24dp"
android:tint=
"#91BF03"
android:viewportHeight=
"24"
android:viewportWidth=
"24"
android:width=
"24dp"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M18.4,10.6C16.55,8.99 14.15,8 11.5,8c-4.65,0 -8.58,3.03 -9.96,7.22L3.9,16c1.05,-3.19 4.05,-5.5 7.6,-5.5 1.95,0 3.73,0.72 5.12,1.88L13,16h9V7l-3.6,3.6z"
/>
</vector>
mobile/src/main/res/drawable/ic_undo.xml
0 → 100644
View file @
70fb40fa
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:height=
"24dp"
android:tint=
"#91BF03"
android:viewportHeight=
"24"
android:viewportWidth=
"24"
android:width=
"24dp"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M12.5,8c-2.65,0 -5.05,0.99 -6.9,2.6L2,7v9h9l-3.62,-3.62c1.39,-1.16 3.16,-1.88 5.12,-1.88 3.54,0 6.55,2.31 7.6,5.5l2.37,-0.78C21.08,11.03 17.15,8 12.5,8z"
/>
</vector>
mobile/src/main/res/layout/fragment_deck_cards.xml
View file @
70fb40fa
...
...
@@ -24,7 +24,7 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"
100dp
"
android:layout_height=
"
wrap_content
"
android:layout_gravity=
"bottom"
android:layout_marginLeft=
"10dp"
android:orientation=
"horizontal"
>
...
...
@@ -41,8 +41,8 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:layout_gravity=
"bottom"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<TextView
...
...
@@ -81,17 +81,16 @@
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"5dp"
android:layout_weight=
"1"
android:textSize=
"10sp"
android:maxLines=
"1"
android:gravity=
"center"
android:maxLines=
"1"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/like_deck_thumb"
android:textColor=
"@color/white"
/>
android:textColor=
"@color/white"
android:textSize=
"10sp"
/>
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
...
...
@@ -99,8 +98,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"bottom"
android:layout_weight=
"1"
android:layout_marginTop=
"2dp"
android:layout_weight=
"1"
android:background=
"@drawable/button_radius_black_transparents"
android:ellipsize=
"end"
android:gravity=
"center|left"
...
...
@@ -126,102 +125,142 @@
android:visibility=
"gone"
/>
<LinearLayout
android:id=
"@+id/nav_list"
android:layout_width=
"60dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/btn_nav_list"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
<!-- 撤销/重做按钮 -->
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:src=
"@drawable/listicon"
/>
android:layout_marginBottom=
"10dp"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"match_parent"
<ImageButton
android:id=
"@+id/btn_undo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginRight=
"5dp"
android:gravity=
"center"
android:enabled=
"false"
android:background=
"@drawable/ic_radius_bg"
android:src=
"@drawable/ic_undo"
/>
<ImageButton
android:id=
"@+id/btn_redo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"5dp"
android:background=
"@drawable/ic_radius_bg"
android:gravity=
"center"
android:enabled=
"false"
android:src=
"@drawable/ic_redo"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/searchresult"
android:textColor=
"@color/white"
android:textSize=
"10sp"
android:textStyle=
"bold"
/>
</LinearLayout>
android:orientation=
"horizontal"
>
<LinearLayout
android:id=
"@+id/nav_search
"
android:layout_width=
"60dp
"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:orientation=
"vertical"
>
<LinearLayout
android:id=
"@+id/nav_list
"
android:layout_width=
"wrap_content
"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/btn_nav_search
"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_gravity=
"center"
android:src=
"@drawable/search
"
/>
<ImageView
android:id=
"@+id/btn_nav_list
"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_gravity=
"center"
android:src=
"@drawable/listicon
"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_cont
ent"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/card_search
"
android:textColor=
"@color/white"
android:textSize=
"10sp"
android:textStyle=
"bold"
/>
</LinearLayout>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"match_par
ent"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/searchresult
"
android:textColor=
"@color/white"
android:textSize=
"10sp"
android:textStyle=
"bold"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/deck_menu"
android:layout_width=
"60dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_marginLeft=
"2dp"
android:layout_marginRight=
"2dp"
android:orientation=
"vertical"
>
<LinearLayout
android:id=
"@+id/nav_search"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"bottom"
android:orientation=
"vertical"
>
<com.nightonke.boommenu.BoomMenuButton
android:id=
"@+id/bmb"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:layout_gravity=
"center_vertical"
android:background=
"@drawable/buttonfunction"
app:bmb_buttonEnum=
"textOutsideCircle"
app:bmb_buttonPlaceEnum=
"buttonPlace_sc_9_1"
app:bmb_dimColor=
"#80000000"
app:bmb_normalColor=
"@android:color/transparent"
app:bmb_piecePlaceEnum=
"piecePlace_dot_9_1"
>
<ImageView
android:id=
"@+id/cube2"
android:layout_width=
"35dp"
android:layout_height=
"35dp"
android:layout_gravity=
"center"
app:srcCompat=
"@drawable/cube"
/>
</com.nightonke.boommenu.BoomMenuButton>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/Function_Menu"
android:textColor=
"@color/white"
android:textSize=
"10sp"
android:textStyle=
"bold"
/>
<ImageView
android:id=
"@+id/btn_nav_search"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_gravity=
"center"
android:src=
"@drawable/search"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/card_search"
android:textColor=
"@color/white"
android:textSize=
"10sp"
android:textStyle=
"bold"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/deck_menu"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"bottom"
android:layout_marginLeft=
"2dp"
android:layout_marginRight=
"2dp"
android:orientation=
"vertical"
>
<com.nightonke.boommenu.BoomMenuButton
android:id=
"@+id/bmb"
android:layout_width=
"wrap_content"
android:layout_height=
"48dp"
android:layout_gravity=
"center_vertical"
android:background=
"@drawable/buttonfunction"
app:bmb_buttonEnum=
"textOutsideCircle"
app:bmb_buttonPlaceEnum=
"buttonPlace_sc_9_1"
app:bmb_dimColor=
"#80000000"
app:bmb_normalColor=
"@android:color/transparent"
app:bmb_piecePlaceEnum=
"piecePlace_dot_9_1"
>
<ImageView
android:id=
"@+id/cube2"
android:layout_width=
"35dp"
android:layout_height=
"35dp"
android:layout_gravity=
"center"
app:srcCompat=
"@drawable/cube"
/>
</com.nightonke.boommenu.BoomMenuButton>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:text=
"@string/Function_Menu"
android:textColor=
"@color/white"
android:textSize=
"10sp"
android:textStyle=
"bold"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
...
...
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