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
5e136e20
Commit
5e136e20
authored
May 05, 2025
by
wangfugui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改卡组编辑功能,支持在线卡组
parent
7e3a7f78
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
457 additions
and
192 deletions
+457
-192
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckType.java
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckType.java
+27
-0
mobile/src/main/java/cn/garymb/ygomobile/bean/events/DeckFile.java
...c/main/java/cn/garymb/ygomobile/bean/events/DeckFile.java
+49
-8
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareApiUtil.java
...va/cn/garymb/ygomobile/deck_square/DeckSquareApiUtil.java
+18
-2
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareListAdapter.java
...n/garymb/ygomobile/deck_square/DeckSquareListAdapter.java
+7
-33
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/DeckListAdapter.java
...java/cn/garymb/ygomobile/ui/adapters/DeckListAdapter.java
+109
-87
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/TextSelectAdapter.java
...va/cn/garymb/ygomobile/ui/adapters/TextSelectAdapter.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+45
-3
mobile/src/main/java/cn/garymb/ygomobile/utils/DeckUtil.java
mobile/src/main/java/cn/garymb/ygomobile/utils/DeckUtil.java
+15
-5
mobile/src/main/java/cn/garymb/ygomobile/utils/YGODialogUtil.java
...rc/main/java/cn/garymb/ygomobile/utils/YGODialogUtil.java
+142
-17
mobile/src/main/res/layout/item_deck_list_swipe.xml
mobile/src/main/res/layout/item_deck_list_swipe.xml
+43
-35
No files found.
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckType.java
View file @
5e136e20
package
cn.garymb.ygomobile.bean
;
package
cn.garymb.ygomobile.bean
;
public
class
DeckType
extends
TextSelect
{
public
class
DeckType
extends
TextSelect
{
public
enum
ServerType
{
LOCAL
,
SQUARE
,
MY_SQUARE
,
}
private
String
name
;
private
String
name
;
private
String
path
;
private
String
path
;
private
ServerType
onServer
;
//true代表云端卡组,false代表本地卡组
public
DeckType
(
String
name
,
String
path
)
{
public
DeckType
(
String
name
,
String
path
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
path
=
path
;
this
.
path
=
path
;
onServer
=
ServerType
.
LOCAL
;
super
.
setName
(
name
);
super
.
setName
(
name
);
setObject
(
this
);
setObject
(
this
);
}
}
public
DeckType
(
String
name
,
String
path
,
ServerType
onServer
)
{
this
.
name
=
name
;
this
.
path
=
path
;
this
.
onServer
=
onServer
;
setObject
(
this
);
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
...
@@ -27,4 +42,16 @@ public class DeckType extends TextSelect {
...
@@ -27,4 +42,16 @@ public class DeckType extends TextSelect {
this
.
path
=
path
;
this
.
path
=
path
;
}
}
public
ServerType
getOnServer
()
{
return
onServer
;
}
public
void
setOnServer
(
ServerType
onServer
)
{
this
.
onServer
=
onServer
;
}
//true代表卡组位于本地
public
boolean
isLocal
()
{
return
(
this
.
onServer
==
ServerType
.
LOCAL
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/bean/events/DeckFile.java
View file @
5e136e20
...
@@ -2,16 +2,35 @@ package cn.garymb.ygomobile.bean.events;
...
@@ -2,16 +2,35 @@ package cn.garymb.ygomobile.bean.events;
import
java.io.File
;
import
java.io.File
;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.TextSelect
;
import
cn.garymb.ygomobile.bean.TextSelect
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
public
class
DeckFile
extends
TextSelect
{
public
class
DeckFile
extends
TextSelect
{
private
File
path
;
private
final
File
path
;
private
String
fileFullName
;
//本地文件对应的名称,仅在onServer为false时有效
private
final
String
fullName
;
// private final File path;
// private final String fullName;
//分类
//分类
private
String
typeName
;
private
String
typeName
;
//可取值包括cacheDeck,Pack
private
int
firstCode
;
private
int
firstCode
;
private
DeckType
.
ServerType
onServer
;
//true代表云端卡组,false代表本地卡组
private
String
deckId
;
//如果onServer为true,代表该卡组存储在云上,deckId是唯一id
// public DeckFile(boolean onServer) {
// this.onServer = onServer;
// }
public
DeckFile
(
String
name
,
String
typeName
,
DeckType
.
ServerType
onServer
,
String
deckId
)
{
this
.
typeName
=
typeName
;
this
.
onServer
=
onServer
;
this
.
deckId
=
deckId
;
this
.
setName
(
name
);
this
.
fileFullName
=
null
;
this
.
path
=
null
;
this
.
firstCode
=
-
1
;
setObject
(
this
);
}
public
DeckFile
(
String
path
)
{
public
DeckFile
(
String
path
)
{
this
(
new
File
(
path
));
this
(
new
File
(
path
));
...
@@ -19,10 +38,10 @@ public class DeckFile extends TextSelect {
...
@@ -19,10 +38,10 @@ public class DeckFile extends TextSelect {
public
DeckFile
(
File
file
)
{
public
DeckFile
(
File
file
)
{
path
=
file
;
path
=
file
;
fullName
=
file
.
getName
();
f
ileF
ullName
=
file
.
getName
();
String
name
=
fullName
;
String
name
=
f
ileF
ullName
;
int
index
=
name
.
lastIndexOf
(
"."
);
int
index
=
name
.
lastIndexOf
(
"."
);
if
(
index
>
0
)
{
if
(
index
>
0
)
{
name
=
name
.
substring
(
0
,
index
);
name
=
name
.
substring
(
0
,
index
);
}
}
typeName
=
DeckUtil
.
getDeckTypeName
(
path
.
getAbsolutePath
());
typeName
=
DeckUtil
.
getDeckTypeName
(
path
.
getAbsolutePath
());
...
@@ -49,7 +68,7 @@ public class DeckFile extends TextSelect {
...
@@ -49,7 +68,7 @@ public class DeckFile extends TextSelect {
}
}
public
String
getFileName
()
{
public
String
getFileName
()
{
return
fullName
;
return
f
ileF
ullName
;
}
}
public
File
getPathFile
()
{
public
File
getPathFile
()
{
...
@@ -64,4 +83,26 @@ public class DeckFile extends TextSelect {
...
@@ -64,4 +83,26 @@ public class DeckFile extends TextSelect {
return
path
.
lastModified
();
return
path
.
lastModified
();
}
}
public
DeckType
.
ServerType
getOnServer
()
{
return
onServer
;
}
public
void
setOnServer
(
DeckType
.
ServerType
onServer
)
{
this
.
onServer
=
onServer
;
}
//true代表卡组位于本地
public
boolean
isLocal
()
{
return
(
this
.
onServer
==
DeckType
.
ServerType
.
LOCAL
);
}
public
String
getDeckId
()
{
return
deckId
;
}
public
void
setDeckId
(
String
deckId
)
{
this
.
deckId
=
deckId
;
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareApiUtil.java
View file @
5e136e20
...
@@ -16,6 +16,7 @@ import cn.garymb.ygomobile.deck_square.api_response.LoginResponse;
...
@@ -16,6 +16,7 @@ import cn.garymb.ygomobile.deck_square.api_response.LoginResponse;
import
cn.garymb.ygomobile.deck_square.api_response.MyDeckResponse
;
import
cn.garymb.ygomobile.deck_square.api_response.MyDeckResponse
;
import
cn.garymb.ygomobile.deck_square.api_response.PushCardJson
;
import
cn.garymb.ygomobile.deck_square.api_response.PushCardJson
;
import
cn.garymb.ygomobile.deck_square.api_response.PushDeckResponse
;
import
cn.garymb.ygomobile.deck_square.api_response.PushDeckResponse
;
import
cn.garymb.ygomobile.deck_square.api_response.SquareDeckResponse
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
...
@@ -29,9 +30,25 @@ public class DeckSquareApiUtil {
...
@@ -29,9 +30,25 @@ public class DeckSquareApiUtil {
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
public
static
SquareDeckResponse
getSquareDecks
()
throws
IOException
{
SquareDeckResponse
result
=
null
;
String
url
=
"http://rarnu.xyz:38383/api/mdpro3/deck/list"
;
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"ReqSource"
,
"MDPro3"
);
Response
response
=
OkhttpUtil
.
synchronousGet
(
url
,
null
,
headers
);
String
responseBodyString
=
response
.
body
().
string
();
// Type listType = new TypeToken<List<DeckInfo>>() {
// }.getType();
Gson
gson
=
new
Gson
();
// Convert JSON to Java object using Gson
result
=
gson
.
fromJson
(
responseBodyString
,
SquareDeckResponse
.
class
);
return
result
;
}
/**
/**
* 阻塞方法
* 阻塞方法
* 获取指定用户的卡组列表
* 获取指定用户的卡组列表
(只能用于获取登录用户本人的卡组)
*
*
* @param serverUserId
* @param serverUserId
* @param serverToken
* @param serverToken
...
@@ -221,7 +238,6 @@ public class DeckSquareApiUtil {
...
@@ -221,7 +238,6 @@ public class DeckSquareApiUtil {
}
}
return
result
;
return
result
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/deck_square/DeckSquareListAdapter.java
View file @
5e136e20
...
@@ -6,25 +6,19 @@ import android.widget.ImageView;
...
@@ -6,25 +6,19 @@ import android.widget.ImageView;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.google.gson.Gson
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
cn.garymb.ygomobile.deck_square.api_response.
ApiDeckRecord
;
import
cn.garymb.ygomobile.deck_square.api_response.
OnlineDeckDetail
;
import
cn.garymb.ygomobile.deck_square.api_response.
Api
Response
;
import
cn.garymb.ygomobile.deck_square.api_response.
SquareDeck
Response
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
okhttp3.Response
;
//提供recyclerview的数据
//提供recyclerview的数据
public
class
DeckSquareListAdapter
extends
BaseQuickAdapter
<
ApiDeckRecord
,
BaseViewHolder
>
{
public
class
DeckSquareListAdapter
extends
BaseQuickAdapter
<
OnlineDeckDetail
,
BaseViewHolder
>
{
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
DeckSquareListAdapter
.
class
.
getSimpleName
();
private
ImageLoader
imageLoader
;
private
ImageLoader
imageLoader
;
...
@@ -37,27 +31,7 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<ApiDeckRecord, BaseV
...
@@ -37,27 +31,7 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<ApiDeckRecord, BaseV
public
void
loadData
()
{
public
void
loadData
()
{
final
DialogPlus
dialog_read_ex
=
DialogPlus
.
show
(
getContext
(),
null
,
getContext
().
getString
(
R
.
string
.
fetch_ex_card
));
final
DialogPlus
dialog_read_ex
=
DialogPlus
.
show
(
getContext
(),
null
,
getContext
().
getString
(
R
.
string
.
fetch_ex_card
));
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
LogUtil
.
d
(
TAG
,
"start fetch"
);
SquareDeckResponse
result
=
DeckSquareApiUtil
.
getSquareDecks
();
ApiResponse
result
=
null
;
try
{
String
url
=
"http://rarnu.xyz:38383/api/mdpro3/deck/list"
;
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"ReqSource"
,
"MDPro3"
);
Response
response
=
OkhttpUtil
.
synchronousGet
(
url
,
null
,
headers
);
String
responseBodyString
=
response
.
body
().
string
();
// Type listType = new TypeToken<List<DeckInfo>>() {
// }.getType();
Gson
gson
=
new
Gson
();
// Convert JSON to Java object using Gson
result
=
gson
.
fromJson
(
responseBodyString
,
ApiResponse
.
class
);
LogUtil
.
i
(
TAG
,
responseBodyString
);
int
a
=
0
;
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"Error occured when fetching data from pre-card server"
);
return
null
;
}
if
(
result
==
null
)
{
if
(
result
==
null
)
{
return
null
;
return
null
;
}
else
{
}
else
{
...
@@ -73,11 +47,11 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<ApiDeckRecord, BaseV
...
@@ -73,11 +47,11 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<ApiDeckRecord, BaseV
}
}
}
}
LogUtil
.
i
(
TAG
,
"
webCrawler
fail"
);
LogUtil
.
i
(
TAG
,
"
Get square deck
fail"
);
}).
done
((
exCardDataList
)
->
{
}).
done
((
exCardDataList
)
->
{
if
(
exCardDataList
!=
null
)
{
if
(
exCardDataList
!=
null
)
{
LogUtil
.
i
(
TAG
,
"
webCrawler done
"
);
LogUtil
.
i
(
TAG
,
"
Get square deck success
"
);
getData
().
clear
();
getData
().
clear
();
addData
(
exCardDataList
);
addData
(
exCardDataList
);
notifyDataSetChanged
();
notifyDataSetChanged
();
...
@@ -102,7 +76,7 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<ApiDeckRecord, BaseV
...
@@ -102,7 +76,7 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<ApiDeckRecord, BaseV
}
}
@Override
@Override
protected
void
convert
(
BaseViewHolder
helper
,
ApiDeckRecord
item
)
{
protected
void
convert
(
BaseViewHolder
helper
,
OnlineDeckDetail
item
)
{
helper
.
setText
(
R
.
id
.
deck_info_name
,
item
.
getDeckName
());
helper
.
setText
(
R
.
id
.
deck_info_name
,
item
.
getDeckName
());
helper
.
setText
(
R
.
id
.
deck_contributor
,
item
.
getDeckContributor
());
helper
.
setText
(
R
.
id
.
deck_contributor
,
item
.
getDeckContributor
());
helper
.
setText
(
R
.
id
.
deck_last_date
,
item
.
getLastDate
());
helper
.
setText
(
R
.
id
.
deck_last_date
,
item
.
getLastDate
());
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/DeckListAdapter.java
View file @
5e136e20
...
@@ -38,7 +38,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
...
@@ -38,7 +38,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
private
OnItemSelectListener
onItemSelectListener
;
private
OnItemSelectListener
onItemSelectListener
;
private
int
selectPosition
;
private
int
selectPosition
;
private
final
boolean
isSelect
;
private
final
boolean
isSelect
;
private
boolean
isManySelect
;
private
boolean
isManySelect
;
//标志位,是否选中多个卡组
private
final
List
<
T
>
selectList
;
private
final
List
<
T
>
selectList
;
public
DeckListAdapter
(
Context
context
,
List
<
T
>
data
,
int
select
)
{
public
DeckListAdapter
(
Context
context
,
List
<
T
>
data
,
int
select
)
{
...
@@ -74,6 +74,19 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
...
@@ -74,6 +74,19 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
int
position
=
holder
.
getAdapterPosition
();
int
position
=
holder
.
getAdapterPosition
();
//item是deckFile类型
//item是deckFile类型
this
.
deckFile
=
(
DeckFile
)
item
;
this
.
deckFile
=
(
DeckFile
)
item
;
if
(!
deckFile
.
isLocal
())
{
//卡组位于服务器上
holder
.
deckId
.
setVisibility
(
View
.
VISIBLE
);
holder
.
deck_info
.
setVisibility
(
View
.
GONE
);
holder
.
deckName
.
setText
(
item
.
getName
());
holder
.
deckId
.
setText
(((
DeckFile
)
item
).
getDeckId
());
}
else
{
//卡组位于本地
holder
.
deckId
.
setVisibility
(
View
.
GONE
);
holder
.
deck_info
.
setVisibility
(
View
.
VISIBLE
);
holder
.
deckName
.
setText
(
item
.
getName
());
holder
.
deckName
.
setText
(
item
.
getName
());
//预读卡组信息
//预读卡组信息
this
.
deckInfo
=
DeckLoader
.
readDeck
(
mCardLoader
,
deckFile
.
getPathFile
(),
mLimitList
);
this
.
deckInfo
=
DeckLoader
.
readDeck
(
mCardLoader
,
deckFile
.
getPathFile
(),
mLimitList
);
...
@@ -179,6 +192,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
...
@@ -179,6 +192,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
}
}
}
}
}
public
void
setSelectPosition
(
int
selectPosition
)
{
public
void
setSelectPosition
(
int
selectPosition
)
{
this
.
selectPosition
=
selectPosition
;
this
.
selectPosition
=
selectPosition
;
...
@@ -199,6 +213,12 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
...
@@ -199,6 +213,12 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
selectList
.
add
(
t
);
selectList
.
add
(
t
);
}
}
/**
* 内部维护了selectList,用于存储当前选中的卡组
* DeckListAdapter支持多选,传入false清除已选中的卡组,并更新adapter。传入true将标志位置1
*
* @param manySelect
*/
public
void
setManySelect
(
boolean
manySelect
)
{
public
void
setManySelect
(
boolean
manySelect
)
{
isManySelect
=
manySelect
;
isManySelect
=
manySelect
;
if
(!
isManySelect
)
{
if
(!
isManySelect
)
{
...
@@ -229,6 +249,7 @@ class DeckViewHolder extends com.chad.library.adapter.base.viewholder.BaseViewHo
...
@@ -229,6 +249,7 @@ class DeckViewHolder extends com.chad.library.adapter.base.viewholder.BaseViewHo
ImageView
prerelease_star
;
ImageView
prerelease_star
;
ImageView
banned_mark
;
ImageView
banned_mark
;
TextView
deckName
;
TextView
deckName
;
TextView
deckId
;
TextView
main
;
TextView
main
;
TextView
extra
;
TextView
extra
;
TextView
side
;
TextView
side
;
...
@@ -242,6 +263,7 @@ class DeckViewHolder extends com.chad.library.adapter.base.viewholder.BaseViewHo
...
@@ -242,6 +263,7 @@ class DeckViewHolder extends com.chad.library.adapter.base.viewholder.BaseViewHo
item_deck_list
=
findView
(
R
.
id
.
item_deck_list
);
item_deck_list
=
findView
(
R
.
id
.
item_deck_list
);
cardImage
=
findView
(
R
.
id
.
card_image
);
cardImage
=
findView
(
R
.
id
.
card_image
);
deckName
=
findView
(
R
.
id
.
deck_name
);
deckName
=
findView
(
R
.
id
.
deck_name
);
deckId
=
findView
(
R
.
id
.
onlie_deck_id
);
main
=
findView
(
R
.
id
.
count_main
);
main
=
findView
(
R
.
id
.
count_main
);
extra
=
findView
(
R
.
id
.
count_ex
);
extra
=
findView
(
R
.
id
.
count_ex
);
side
=
findView
(
R
.
id
.
count_side
);
side
=
findView
(
R
.
id
.
count_side
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/TextSelectAdapter.java
View file @
5e136e20
...
@@ -37,7 +37,7 @@ public class TextSelectAdapter<T extends TextSelect> extends BaseQuickAdapter<T,
...
@@ -37,7 +37,7 @@ public class TextSelectAdapter<T extends TextSelect> extends BaseQuickAdapter<T,
selectPosition
=
position
;
selectPosition
=
position
;
notifyDataSetChanged
();
notifyDataSetChanged
();
if
(
onItemSelectListener
!=
null
)
if
(
onItemSelectListener
!=
null
)
onItemSelectListener
.
onItemSelect
(
position
,
data
.
get
(
position
)
.
getObject
()
);
onItemSelectListener
.
onItemSelect
(
position
,
data
.
get
(
position
));
}
}
});
});
}
}
...
@@ -59,7 +59,7 @@ public class TextSelectAdapter<T extends TextSelect> extends BaseQuickAdapter<T,
...
@@ -59,7 +59,7 @@ public class TextSelectAdapter<T extends TextSelect> extends BaseQuickAdapter<T,
}
else
{
}
else
{
helper
.
setBackgroundResource
(
R
.
id
.
ll_layout
,
Color
.
TRANSPARENT
);
helper
.
setBackgroundResource
(
R
.
id
.
ll_layout
,
Color
.
TRANSPARENT
);
}
}
}
else
{
}
else
{
helper
.
setBackgroundResource
(
R
.
id
.
ll_layout
,
Color
.
TRANSPARENT
);
helper
.
setBackgroundResource
(
R
.
id
.
ll_layout
,
Color
.
TRANSPARENT
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
5e136e20
...
@@ -76,6 +76,9 @@ import cn.garymb.ygomobile.bean.events.CardInfoEvent;
...
@@ -76,6 +76,9 @@ import cn.garymb.ygomobile.bean.events.CardInfoEvent;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.deck_square.DeckSquareActivity
;
import
cn.garymb.ygomobile.deck_square.DeckSquareActivity
;
import
cn.garymb.ygomobile.deck_square.DeckSquareApiUtil
;
import
cn.garymb.ygomobile.deck_square.DeckSquareFileUtil
;
import
cn.garymb.ygomobile.deck_square.api_response.DownloadDeckResponse
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.CardLoader
;
import
cn.garymb.ygomobile.loader.CardLoader
;
import
cn.garymb.ygomobile.loader.CardSearchInfo
;
import
cn.garymb.ygomobile.loader.CardSearchInfo
;
...
@@ -99,6 +102,7 @@ import cn.garymb.ygomobile.utils.BitmapUtil;
...
@@ -99,6 +102,7 @@ import cn.garymb.ygomobile.utils.BitmapUtil;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
...
@@ -207,6 +211,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -207,6 +211,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
mContext
=
(
BaseActivity
)
getActivity
();
mContext
=
(
BaseActivity
)
getActivity
();
}
}
//通过本文件,外部调用fragment时,如果通过setArguments(mBundle)方法设置了ydk文件路径,则直接打开它
public
void
preLoadFile
()
{
public
void
preLoadFile
()
{
String
preLoadFile
=
""
;
String
preLoadFile
=
""
;
if
(
getArguments
()
!=
null
)
{
if
(
getArguments
()
!=
null
)
{
...
@@ -382,6 +387,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -382,6 +387,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
}
}
//region load deck
//region load deck
private
void
loadDeckFromFile
(
File
file
)
{
private
void
loadDeckFromFile
(
File
file
)
{
if
(!
mCardLoader
.
isOpen
()
||
file
==
null
||
!
file
.
exists
())
{
if
(!
mCardLoader
.
isOpen
()
||
file
==
null
||
!
file
.
exists
())
{
...
@@ -397,7 +403,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -397,7 +403,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
}).
done
((
rs
)
->
{
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
dlg
.
dismiss
();
setCurDeck
(
rs
,
file
.
getParent
().
equals
(
mSettings
.
getPackDeckDir
())
||
file
.
getParent
().
equals
(
mSettings
.
getCacheDeckDir
()));
//setCurDeck(rs, file.getParent().equals(mSettings.getPackDeckDir()) || file.getParent().equals(mSettings.getCacheDeckDir()));
setCurDeck
(
rs
,
file
.
getParent
().
equals
(
mSettings
.
getPackDeckDir
()));
});
});
}
}
...
@@ -445,7 +452,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -445,7 +452,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
/**
/**
*
设置当前卡组
*
用户选中某个卡组后,更新当前界面,显示已选中的卡组。包括更新界面显示(tv_deck)、更新AppsSettings、通知DeckAdapter
*/
*/
private
void
setCurDeck
(
DeckInfo
deckInfo
,
boolean
isPack
)
{
private
void
setCurDeck
(
DeckInfo
deckInfo
,
boolean
isPack
)
{
if
(
deckInfo
==
null
)
{
if
(
deckInfo
==
null
)
{
...
@@ -1231,8 +1238,43 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1231,8 +1238,43 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
@Override
@Override
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
if
(!
deckFile
.
isLocal
())
{
//不在本地,在云上(卡组广场中或用户的云上)
VUiKit
.
defer
().
when
(()
->
{
DownloadDeckResponse
response
=
DeckSquareApiUtil
.
getDeckById
(
deckFile
.
getDeckId
());
if
(
response
!=
null
)
{
return
response
.
getData
();
}
else
{
return
null
;
}
}).
fail
((
e
)
->
{
LogUtil
.
i
(
TAG
,
"square deck detail fail"
+
e
.
getMessage
());
}).
done
((
deckData
)
->
{
if
(
deckData
!=
null
)
{
deckData
.
getDeckYdk
();
String
fileFullName
=
deckData
.
getDeckName
()
+
".ydk"
;
String
path
=
AppsSettings
.
get
().
getCacheDeckDir
();
File
dir
=
new
File
(
getActivity
().
getApplicationInfo
().
dataDir
,
"cache"
);
boolean
result
=
DeckSquareFileUtil
.
saveFileToPath
(
dir
.
getPath
(),
fileFullName
,
deckData
.
getDeckYdk
());
if
(
result
)
{
LogUtil
.
i
(
TAG
,
"square deck detail done"
);
File
file
=
new
File
(
dir
,
fileFullName
);
loadDeckFromFile
(
file
);
}
}
});
}
else
{
loadDeckFromFile
(
deckFile
.
getPathFile
());
loadDeckFromFile
(
deckFile
.
getPathFile
());
}
}
}
@Override
@Override
public
void
onDeckDel
(
List
<
DeckFile
>
deckFileList
)
{
public
void
onDeckDel
(
List
<
DeckFile
>
deckFileList
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/DeckUtil.java
View file @
5e136e20
...
@@ -68,11 +68,19 @@ public class DeckUtil {
...
@@ -68,11 +68,19 @@ public class DeckUtil {
}
}
};
};
/**
* 生成卡组类型的list
*
* @param context
* @return
*/
public
static
List
<
DeckType
>
getDeckTypeList
(
Context
context
)
{
public
static
List
<
DeckType
>
getDeckTypeList
(
Context
context
)
{
List
<
DeckType
>
deckTypeList
=
new
ArrayList
<>();
List
<
DeckType
>
deckTypeList
=
new
ArrayList
<>();
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_pack
),
AppsSettings
.
get
().
getPackDeckDir
()));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_pack
),
AppsSettings
.
get
().
getPackDeckDir
(),
DeckType
.
ServerType
.
LOCAL
));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_windbot_deck
),
AppsSettings
.
get
().
getAiDeckDir
()));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_windbot_deck
),
AppsSettings
.
get
().
getAiDeckDir
(),
DeckType
.
ServerType
.
LOCAL
));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_Uncategorized
),
AppsSettings
.
get
().
getDeckDir
()));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_Uncategorized
),
AppsSettings
.
get
().
getDeckDir
(),
DeckType
.
ServerType
.
LOCAL
));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_online_deck
),
""
,
DeckType
.
ServerType
.
SQUARE
));
deckTypeList
.
add
(
new
DeckType
(
YGOUtil
.
s
(
R
.
string
.
category_my_online_deck
),
""
,
DeckType
.
ServerType
.
MY_SQUARE
));
File
[]
files
=
new
File
(
AppsSettings
.
get
().
getDeckDir
()).
listFiles
();
File
[]
files
=
new
File
(
AppsSettings
.
get
().
getDeckDir
()).
listFiles
();
if
(
files
!=
null
)
{
if
(
files
!=
null
)
{
...
@@ -138,6 +146,7 @@ public class DeckUtil {
...
@@ -138,6 +146,7 @@ public class DeckUtil {
/**
/**
* 根据卡组绝对路径获取卡组分类名称
* 根据卡组绝对路径获取卡组分类名称
*
* @param deckPath
* @param deckPath
* @return
* @return
*/
*/
...
@@ -149,7 +158,7 @@ public class DeckUtil {
...
@@ -149,7 +158,7 @@ public class DeckUtil {
if
(
name
.
equals
(
"pack"
)
||
name
.
equals
(
"cacheDeck"
))
{
if
(
name
.
equals
(
"pack"
)
||
name
.
equals
(
"cacheDeck"
))
{
//卡包
//卡包
return
YGOUtil
.
s
(
R
.
string
.
category_pack
);
return
YGOUtil
.
s
(
R
.
string
.
category_pack
);
}
else
if
(
name
.
equals
(
"Decks"
)
&&
lastName
.
equals
(
Constants
.
WINDBOT_PATH
))
{
}
else
if
(
name
.
equals
(
"Decks"
)
&&
lastName
.
equals
(
Constants
.
WINDBOT_PATH
))
{
//ai卡组
//ai卡组
return
YGOUtil
.
s
(
R
.
string
.
category_windbot_deck
);
return
YGOUtil
.
s
(
R
.
string
.
category_windbot_deck
);
}
else
if
(
name
.
equals
(
"deck"
)
&&
lastName
.
equals
(
Constants
.
PREF_DEF_GAME_DIR
))
{
}
else
if
(
name
.
equals
(
"deck"
)
&&
lastName
.
equals
(
Constants
.
PREF_DEF_GAME_DIR
))
{
...
@@ -162,6 +171,7 @@ public class DeckUtil {
...
@@ -162,6 +171,7 @@ public class DeckUtil {
return
null
;
return
null
;
}
}
//获取扩展卡的列表
public
static
List
<
DeckFile
>
getExpansionsDeckList
()
throws
IOException
{
public
static
List
<
DeckFile
>
getExpansionsDeckList
()
throws
IOException
{
AppsSettings
appsSettings
=
AppsSettings
.
get
();
AppsSettings
appsSettings
=
AppsSettings
.
get
();
List
<
DeckFile
>
deckList
=
new
ArrayList
<>();
List
<
DeckFile
>
deckList
=
new
ArrayList
<>();
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/YGODialogUtil.java
View file @
5e136e20
This diff is collapsed.
Click to expand it.
mobile/src/main/res/layout/item_deck_list_swipe.xml
View file @
5e136e20
...
@@ -34,12 +34,19 @@
...
@@ -34,12 +34,19 @@
<cn.garymb.ygomobile.ui.widget.AlwaysMarqueeTextView
<cn.garymb.ygomobile.ui.widget.AlwaysMarqueeTextView
android:id=
"@+id/deck_name"
android:id=
"@+id/deck_name"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_cont
ent"
android:layout_height=
"
match_par
ent"
android:maxLines=
"1"
android:maxLines=
"1"
android:singleLine=
"true"
android:singleLine=
"true"
android:textColor=
"@color/white"
android:textColor=
"@color/white"
tools:text=
"Deck Name"
/>
tools:text=
"Deck Name"
/>
<TextView
android:id=
"@+id/onlie_deck_id"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/holo_blue_bright"
android:textSize=
"10sp"
tools:text=
"40"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/deck_info"
android:id=
"@+id/deck_info"
...
@@ -53,16 +60,16 @@
...
@@ -53,16 +60,16 @@
android:layout_width=
"15dp"
android:layout_width=
"15dp"
android:layout_height=
"15dp"
android:layout_height=
"15dp"
android:layout_marginRight=
"5dp"
android:layout_marginRight=
"5dp"
android:
visibility=
"visible
"
android:
background=
"@drawable/ic_expansions
"
android:
background=
"@drawable/ic_expansions"
/>
android:
visibility=
"visible"
/>
<ImageView
<ImageView
android:id=
"@+id/banned_mark"
android:id=
"@+id/banned_mark"
android:layout_width=
"15dp"
android:layout_width=
"15dp"
android:layout_height=
"15dp"
android:layout_height=
"15dp"
android:layout_marginRight=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
android:
visibility=
"visible
"
android:
background=
"@drawable/ic_banned
"
android:
background=
"@drawable/ic_banned"
/>
android:
visibility=
"visible"
/>
<TextView
<TextView
android:id=
"@+id/count_main"
android:id=
"@+id/count_main"
...
@@ -71,6 +78,7 @@
...
@@ -71,6 +78,7 @@
android:textColor=
"@color/holo_blue_bright"
android:textColor=
"@color/holo_blue_bright"
android:textSize=
"10sp"
android:textSize=
"10sp"
tools:text=
"40"
/>
tools:text=
"40"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/ll_extra_n_side"
android:id=
"@+id/ll_extra_n_side"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
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