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
Expand all
Show 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 {
...
@@ -20,9 +20,9 @@ public class DeckInfo {
Side
,
Side
,
}
}
p
rivate
final
List
<
Card
>
mainCards
;
p
ublic
List
<
Card
>
mainCards
;
p
rivate
final
List
<
Card
>
extraCards
;
p
ublic
List
<
Card
>
extraCards
;
p
rivate
final
List
<
Card
>
sideCards
;
p
ublic
List
<
Card
>
sideCards
;
private
final
List
<
Card
>
allCards
;
private
final
List
<
Card
>
allCards
;
public
File
source
;
//当前打开的ydk文件的file
public
File
source
;
//当前打开的ydk文件的file
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
70fb40fa
This diff is collapsed.
Click to expand it.
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
...
@@ -40,12 +40,14 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private
final
SparseArray
<
Integer
>
mCount
=
new
SparseArray
<>();
private
final
SparseArray
<
Integer
>
mCount
=
new
SparseArray
<>();
private
final
Context
context
;
private
final
Context
context
;
private
final
LayoutInflater
mLayoutInflater
;
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
ImageTop
mImageTop
;
private
int
mMainCount
;
private
int
mMainCount
;
private
int
mExtraCount
;
private
int
mExtraCount
;
private
int
mSideCount
;
private
int
mSideCount
;
private
int
mMainMonsterCount
;
private
int
mMainMonsterCount
;
private
int
mMainSpellCount
;
private
int
mMainSpellCount
;
private
int
mMainTrapCount
;
private
int
mMainTrapCount
;
...
@@ -56,18 +58,13 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
...
@@ -56,18 +58,13 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private
int
mSideMonsterCount
;
private
int
mSideMonsterCount
;
private
int
mSideSpellCount
;
private
int
mSideSpellCount
;
private
int
mSideTrapCount
;
private
int
mSideTrapCount
;
private
int
mFullWidth
;
private
int
mFullWidth
;
private
int
mWidth
;
private
int
mWidth
;
private
int
mHeight
;
private
int
mHeight
;
private
final
int
Padding
=
1
;
private
final
RecyclerView
recyclerView
;
private
final
Random
mRandom
;
private
DeckViewHolder
mHeadHolder
;
private
DeckViewHolder
mHeadHolder
;
private
DeckItem
mRemoveItem
;
private
DeckItem
mRemoveItem
;
private
int
mRemoveIndex
;
private
int
mRemoveIndex
;
private
LimitList
mLimitList
;
private
LimitList
mLimitList
;
private
final
ImageLoader
imageLoader
;
private
boolean
showHead
=
false
;
private
boolean
showHead
=
false
;
private
String
mDeckMd5
;
private
String
mDeckMd5
;
private
DeckInfo
mDeckInfo
;
private
DeckInfo
mDeckInfo
;
...
@@ -98,6 +95,46 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
...
@@ -98,6 +95,46 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
return
mCount
;
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
)
{
public
boolean
AddCard
(
Card
cardInfo
,
DeckItemType
type
)
{
if
(
cardInfo
==
null
)
return
false
;
if
(
cardInfo
==
null
)
return
false
;
if
(
cardInfo
.
isType
(
CardType
.
Token
))
{
if
(
cardInfo
.
isType
(
CardType
.
Token
))
{
...
@@ -151,10 +188,6 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
...
@@ -151,10 +188,6 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
notifyItemRangeChanged
(
DeckItem
.
MainStart
,
DeckItem
.
MainStart
+
getMainCount
());
notifyItemRangeChanged
(
DeckItem
.
MainStart
,
DeckItem
.
MainStart
+
getMainCount
());
}
}
public
void
setLimitList
(
LimitList
limitList
)
{
mLimitList
=
limitList
;
}
private
boolean
comp
(
DeckItem
d1
,
DeckItem
d2
)
{
private
boolean
comp
(
DeckItem
d1
,
DeckItem
d2
)
{
if
(
d1
.
getType
()
==
d2
.
getType
())
{
if
(
d1
.
getType
()
==
d2
.
getType
())
{
Card
c1
=
d1
.
getCardInfo
();
Card
c1
=
d1
.
getCardInfo
();
...
@@ -386,6 +419,10 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
...
@@ -386,6 +419,10 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
return
mLimitList
;
return
mLimitList
;
}
}
public
void
setLimitList
(
LimitList
limitList
)
{
mLimitList
=
limitList
;
}
public
@Nullable
public
@Nullable
File
getYdkFile
()
{
File
getYdkFile
()
{
if
(
mDeckInfo
!=
null
)
{
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 @@
...
@@ -24,7 +24,7 @@
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
100dp
"
android:layout_height=
"
wrap_content
"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
...
@@ -41,8 +41,8 @@
...
@@ -41,8 +41,8 @@
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<TextView
<TextView
...
@@ -81,17 +81,16 @@
...
@@ -81,17 +81,16 @@
android:layout_marginStart=
"5dp"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"5dp"
android:layout_marginEnd=
"5dp"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:textSize=
"10sp"
android:maxLines=
"1"
android:gravity=
"center"
android:gravity=
"center"
android:maxLines=
"1"
android:shadowColor=
"@color/black"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDx=
"1"
android:shadowDy=
"1"
android:shadowDy=
"1"
android:shadowRadius=
"2"
android:shadowRadius=
"2"
android:text=
"@string/like_deck_thumb"
android:text=
"@string/like_deck_thumb"
android:textColor=
"@color/white"
/>
android:textColor=
"@color/white"
android:textSize=
"10sp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
...
@@ -99,8 +98,8 @@
...
@@ -99,8 +98,8 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:layout_weight=
"1"
android:layout_marginTop=
"2dp"
android:layout_marginTop=
"2dp"
android:layout_weight=
"1"
android:background=
"@drawable/button_radius_black_transparents"
android:background=
"@drawable/button_radius_black_transparents"
android:ellipsize=
"end"
android:ellipsize=
"end"
android:gravity=
"center|left"
android:gravity=
"center|left"
...
@@ -125,9 +124,47 @@
...
@@ -125,9 +124,47 @@
android:layout_weight=
"1"
android:layout_weight=
"1"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<!-- 撤销/重做按钮 -->
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginBottom=
"10dp"
android:orientation=
"horizontal"
>
<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:orientation=
"horizontal"
>
<LinearLayout
<LinearLayout
android:id=
"@+id/nav_list"
android:id=
"@+id/nav_list"
android:layout_width=
"60dp
"
android:layout_width=
"wrap_content
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
...
@@ -141,7 +178,7 @@
...
@@ -141,7 +178,7 @@
<TextView
<TextView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_cont
ent"
android:layout_height=
"match_par
ent"
android:gravity=
"bottom|center_horizontal"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDx=
"1"
...
@@ -155,8 +192,8 @@
...
@@ -155,8 +192,8 @@
<LinearLayout
<LinearLayout
android:id=
"@+id/nav_search"
android:id=
"@+id/nav_search"
android:layout_width=
"60dp
"
android:layout_width=
"wrap_content
"
android:layout_height=
"wrap_cont
ent"
android:layout_height=
"match_par
ent"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
...
@@ -169,7 +206,7 @@
...
@@ -169,7 +206,7 @@
<TextView
<TextView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_cont
ent"
android:layout_height=
"match_par
ent"
android:gravity=
"bottom|center_horizontal"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDx=
"1"
...
@@ -183,8 +220,8 @@
...
@@ -183,8 +220,8 @@
<LinearLayout
<LinearLayout
android:id=
"@+id/deck_menu"
android:id=
"@+id/deck_menu"
android:layout_width=
"60dp
"
android:layout_width=
"wrap_content
"
android:layout_height=
"wrap_cont
ent"
android:layout_height=
"match_par
ent"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
android:layout_marginLeft=
"2dp"
android:layout_marginLeft=
"2dp"
android:layout_marginRight=
"2dp"
android:layout_marginRight=
"2dp"
...
@@ -212,7 +249,7 @@
...
@@ -212,7 +249,7 @@
<TextView
<TextView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_cont
ent"
android:layout_height=
"match_par
ent"
android:gravity=
"bottom|center_horizontal"
android:gravity=
"bottom|center_horizontal"
android:shadowColor=
"@color/black"
android:shadowColor=
"@color/black"
android:shadowDx=
"1"
android:shadowDx=
"1"
...
@@ -224,6 +261,8 @@
...
@@ -224,6 +261,8 @@
android:textStyle=
"bold"
/>
android:textStyle=
"bold"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</FrameLayout>
<LinearLayout
<LinearLayout
...
...
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