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
Hide 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,109 +74,123 @@ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, D
...
@@ -74,109 +74,123 @@ 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
;
holder
.
deckName
.
setText
(
item
.
getName
());
if
(!
deckFile
.
isLocal
())
{
//预读卡组信息
//卡组位于服务器上
this
.
deckInfo
=
DeckLoader
.
readDeck
(
mCardLoader
,
deckFile
.
getPathFile
(),
mLimitList
);
holder
.
deckId
.
setVisibility
(
View
.
VISIBLE
);
//加载卡组第一张卡的图
holder
.
deck_info
.
setVisibility
(
View
.
GONE
);
holder
.
cardImage
.
setVisibility
(
View
.
VISIBLE
);
imageLoader
.
bindImage
(
holder
.
cardImage
,
deckFile
.
getFirstCode
(),
ImageLoader
.
Type
.
middle
);
holder
.
deckName
.
setText
(
item
.
getName
());
//填入内容
holder
.
deckId
.
setText
(((
DeckFile
)
item
).
getDeckId
());
if
(
deckInfo
!=
null
)
{
holder
.
main
.
setText
(
String
.
valueOf
(
deckInfo
.
getMainCount
()));
if
(
deckInfo
.
getMainCount
()
<
40
)
{
holder
.
main
.
setTextColor
(
Color
.
YELLOW
);
}
else
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
holder
.
main
.
setTextColor
(
mContext
.
getColor
(
R
.
color
.
holo_blue_bright
));
}
}
}
else
{
holder
.
main
.
setText
(
"-"
);
holder
.
main
.
setTextColor
(
Color
.
RED
);
}
if
(
deckInfo
!=
null
)
{
//有时候主卡数量是空指,原因待查,暂且空指时显示红色“-”
holder
.
extra
.
setText
(
String
.
valueOf
(
deckInfo
.
getExtraCount
()));
}
else
{
holder
.
extra
.
setText
(
"-"
);
holder
.
extra
.
setTextColor
(
Color
.
RED
);
}
if
(
deckInfo
!=
null
)
{
holder
.
side
.
setText
(
String
.
valueOf
(
deckInfo
.
getSideCount
()));
}
else
{
holder
.
side
.
setText
(
"-"
);
holder
.
side
.
setTextColor
(
Color
.
RED
);
}
if
(
deckFile
.
getTypeName
().
equals
(
YGOUtil
.
s
(
R
.
string
.
category_pack
))
||
deckFile
.
getPath
().
contains
(
"cacheDeck"
))
{
//卡包展示时不显示额外和副卡组数量文本
holder
.
ll_extra_n_side
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
holder
.
ll_extra_n_side
.
setVisibility
(
View
.
VISIBLE
);
//卡组位于本地
}
holder
.
deckId
.
setVisibility
(
View
.
GONE
);
if
(
deckInfo
!=
null
)
{
holder
.
deck_info
.
setVisibility
(
View
.
VISIBLE
);
//判断是否含有先行卡
holder
.
deckName
.
setText
(
item
.
getName
());
Deck
deck
=
this
.
deckInfo
.
toDeck
();
//预读卡组信息
List
<
String
>
strList
=
new
ArrayList
<>();
this
.
deckInfo
=
DeckLoader
.
readDeck
(
mCardLoader
,
deckFile
.
getPathFile
(),
mLimitList
);
for
(
int
i
=
0
;
i
<
deck
.
getDeckCount
();
i
++)
{
//加载卡组第一张卡的图
strList
.
add
(
deck
.
getAlllist
().
get
(
i
).
toString
());
holder
.
cardImage
.
setVisibility
(
View
.
VISIBLE
);
}
imageLoader
.
bindImage
(
holder
.
cardImage
,
deckFile
.
getFirstCode
(),
ImageLoader
.
Type
.
middle
);
for
(
int
i
=
0
;
i
<
deck
.
getDeckCount
();
i
++)
{
//填入内容
if
(
strList
.
get
(
i
).
length
()
>
8
)
{
if
(
deckInfo
!=
null
)
{
holder
.
prerelease_star
.
setVisibility
(
View
.
VISIBLE
);
holder
.
main
.
setText
(
String
.
valueOf
(
deckInfo
.
getMainCount
()));
break
;
if
(
deckInfo
.
getMainCount
()
<
40
)
{
holder
.
main
.
setTextColor
(
Color
.
YELLOW
);
}
else
{
}
else
{
holder
.
prerelease_star
.
setVisibility
(
View
.
GONE
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
continue
;
holder
.
main
.
setTextColor
(
mContext
.
getColor
(
R
.
color
.
holo_blue_bright
));
}
}
}
}
else
{
holder
.
main
.
setText
(
"-"
);
holder
.
main
.
setTextColor
(
Color
.
RED
);
}
if
(
deckInfo
!=
null
)
{
//有时候主卡数量是空指,原因待查,暂且空指时显示红色“-”
holder
.
extra
.
setText
(
String
.
valueOf
(
deckInfo
.
getExtraCount
()));
}
else
{
holder
.
extra
.
setText
(
"-"
);
holder
.
extra
.
setTextColor
(
Color
.
RED
);
}
if
(
deckInfo
!=
null
)
{
holder
.
side
.
setText
(
String
.
valueOf
(
deckInfo
.
getSideCount
()));
}
else
{
holder
.
side
.
setText
(
"-"
);
holder
.
side
.
setTextColor
(
Color
.
RED
);
}
if
(
deckFile
.
getTypeName
().
equals
(
YGOUtil
.
s
(
R
.
string
.
category_pack
))
||
deckFile
.
getPath
().
contains
(
"cacheDeck"
))
{
//卡包展示时不显示额外和副卡组数量文本
holder
.
ll_extra_n_side
.
setVisibility
(
View
.
GONE
);
}
else
{
holder
.
ll_extra_n_side
.
setVisibility
(
View
.
VISIBLE
);
}
}
//判断是否符合默认禁卡表以显示标识
if
(
deckInfo
!=
null
)
{
if
(
mLimitList
!=
null
)
{
//判断是否含有先行卡
Deck
deck
=
this
.
deckInfo
.
toDeck
();
List
<
String
>
strList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
deck
.
getDeckCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
deck
.
getDeckCount
();
i
++)
{
if
(
mLimitList
.
getStringForbidden
().
contains
(
strList
.
get
(
i
)))
{
strList
.
add
(
deck
.
getAlllist
().
get
(
i
).
toString
());
holder
.
banned_mark
.
setVisibility
(
View
.
VISIBLE
);
}
for
(
int
i
=
0
;
i
<
deck
.
getDeckCount
();
i
++)
{
if
(
strList
.
get
(
i
).
length
()
>
8
)
{
holder
.
prerelease_star
.
setVisibility
(
View
.
VISIBLE
);
break
;
break
;
}
else
if
(
mLimitList
.
getStringLimit
().
contains
(
strList
.
get
(
i
)))
{
}
else
{
int
limitcount
=
0
;
holder
.
prerelease_star
.
setVisibility
(
View
.
GONE
);
for
(
int
j
=
0
;
j
<
deck
.
getDeckCount
();
j
++)
{
continue
;
if
(
strList
.
get
(
i
).
equals
(
strList
.
get
(
j
)))
{
}
limitcount
++;
}
}
//判断是否符合默认禁卡表以显示标识
}
if
(
mLimitList
!=
null
)
{
if
(
limitcount
>
1
)
{
for
(
int
i
=
0
;
i
<
deck
.
getDeckCount
();
i
++)
{
if
(
mLimitList
.
getStringForbidden
().
contains
(
strList
.
get
(
i
)))
{
holder
.
banned_mark
.
setVisibility
(
View
.
VISIBLE
);
holder
.
banned_mark
.
setVisibility
(
View
.
VISIBLE
);
break
;
break
;
}
}
else
if
(
mLimitList
.
getStringLimit
().
contains
(
strList
.
get
(
i
)))
{
}
else
if
(
mLimitList
.
getStringSemiLimit
().
contains
(
strList
.
get
(
i
)))
{
int
limitcount
=
0
;
int
semicount
=
0
;
for
(
int
j
=
0
;
j
<
deck
.
getDeckCount
();
j
++)
{
for
(
int
k
=
0
;
k
<
deck
.
getDeckCount
();
k
++
)
{
if
(
strList
.
get
(
i
).
equals
(
strList
.
get
(
j
))
)
{
if
(
strList
.
get
(
i
).
equals
(
strList
.
get
(
k
)))
{
limitcount
++;
semicount
++;
}
}
}
if
(
limitcount
>
1
)
{
holder
.
banned_mark
.
setVisibility
(
View
.
VISIBLE
);
break
;
}
}
else
if
(
mLimitList
.
getStringSemiLimit
().
contains
(
strList
.
get
(
i
)))
{
int
semicount
=
0
;
for
(
int
k
=
0
;
k
<
deck
.
getDeckCount
();
k
++)
{
if
(
strList
.
get
(
i
).
equals
(
strList
.
get
(
k
)))
{
semicount
++;
}
}
if
(
semicount
>
2
)
{
holder
.
banned_mark
.
setVisibility
(
View
.
VISIBLE
);
break
;
}
}
else
{
holder
.
banned_mark
.
setVisibility
(
View
.
GONE
);
continue
;
}
}
if
(
semicount
>
2
)
{
holder
.
banned_mark
.
setVisibility
(
View
.
VISIBLE
);
break
;
}
}
else
{
holder
.
banned_mark
.
setVisibility
(
View
.
GONE
);
continue
;
}
}
}
}
}
}
}
//多选
//多选
if
(
isManySelect
)
{
if
(
isManySelect
)
{
if
(
selectList
.
contains
(
item
))
if
(
selectList
.
contains
(
item
))
holder
.
item_deck_list
.
setBackgroundColor
(
YGOUtil
.
c
(
R
.
color
.
colorMain
));
holder
.
item_deck_list
.
setBackgroundColor
(
YGOUtil
.
c
(
R
.
color
.
colorMain
));
else
else
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
}
else
if
(
isSelect
)
{
}
else
if
(
isSelect
)
{
if
(
position
==
selectPosition
)
{
if
(
position
==
selectPosition
)
{
holder
.
item_deck_list
.
setBackgroundColor
(
YGOUtil
.
c
(
R
.
color
.
colorMain
));
holder
.
item_deck_list
.
setBackgroundColor
(
YGOUtil
.
c
(
R
.
color
.
colorMain
));
}
else
{
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
}
}
else
{
}
else
{
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
}
}
}
else
{
holder
.
item_deck_list
.
setBackgroundResource
(
Color
.
TRANSPARENT
);
}
}
}
}
...
@@ -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,7 +1238,42 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1231,7 +1238,42 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
@Override
@Override
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
loadDeckFromFile
(
deckFile
.
getPathFile
());
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
());
}
}
}
@Override
@Override
...
...
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,19 +158,20 @@ public class DeckUtil {
...
@@ -149,19 +158,20 @@ 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
))
{
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
return
YGOUtil
.
s
(
R
.
string
.
category_Uncategorized
);
return
YGOUtil
.
s
(
R
.
string
.
category_Uncategorized
);
}
else
{
}
else
{
return
name
;
return
name
;
}
}
}
}
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
...
@@ -37,17 +37,63 @@ import cn.garymb.ygomobile.AppsSettings;
...
@@ -37,17 +37,63 @@ import cn.garymb.ygomobile.AppsSettings;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.deck_square.DeckSquareApiUtil
;
import
cn.garymb.ygomobile.deck_square.api_response.MyDeckResponse
;
import
cn.garymb.ygomobile.deck_square.api_response.MyOnlineDeckDetail
;
import
cn.garymb.ygomobile.deck_square.api_response.OnlineDeckDetail
;
import
cn.garymb.ygomobile.deck_square.api_response.SquareDeckResponse
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.adapters.DeckListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.DeckListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.TextSelectAdapter
;
import
cn.garymb.ygomobile.ui.adapters.TextSelectAdapter
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
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.utils.recyclerview.DeckTypeTouchHelperCallback
;
import
cn.garymb.ygomobile.utils.recyclerview.DeckTypeTouchHelperCallback
;
public
class
YGODialogUtil
{
public
class
YGODialogUtil
{
/* public enum DeckTypeEnum {
CARD_PACK(0, "PACK"),
WINDBOT(1, "WINDBOT"),
Uncategorized(2, "Uncategorized"),
ONLINE(3, "Online");
private final int code;
private final String description;
// Constructor
DeckTypeEnum(int code, String description) {
this.code = code;
this.description = description;
}
// Getter methods
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
// Lookup by code
public static DeckTypeEnum fromCode(int code) {
for (DeckTypeEnum status : DeckTypeEnum.values()) {
if (status.code == code) {
return status;
}
}
throw new IllegalArgumentException("No DeckTypeEnum found for code: " + code);
}
}
*/
private
static
final
String
TAG
=
"YGODialogUtil"
;
private
static
final
String
TAG
=
"YGODialogUtil"
;
/**
* @param context
* @param selectDeckPath 卡组路径。由调用方传入,本dialog根据selectDeckPath的值来确定“默认选中的卡组分类”。
* @param onDeckMenuListener
*/
public
static
void
dialogDeckSelect
(
Context
context
,
String
selectDeckPath
,
OnDeckMenuListener
onDeckMenuListener
)
{
public
static
void
dialogDeckSelect
(
Context
context
,
String
selectDeckPath
,
OnDeckMenuListener
onDeckMenuListener
)
{
ViewHolder
viewHolder
=
new
ViewHolder
(
context
,
selectDeckPath
,
onDeckMenuListener
);
ViewHolder
viewHolder
=
new
ViewHolder
(
context
,
selectDeckPath
,
onDeckMenuListener
);
viewHolder
.
show
();
viewHolder
.
show
();
...
@@ -71,6 +117,9 @@ public class YGODialogUtil {
...
@@ -71,6 +117,9 @@ public class YGODialogUtil {
void
onDeckTypeListener
(
int
position
);
void
onDeckTypeListener
(
int
position
);
}
}
/**
* 封装DialogPlus,在本类中调用DialogPlus.setContentView()
*/
private
static
class
ViewHolder
{
private
static
class
ViewHolder
{
private
final
int
IMAGE_MOVE
=
0
;
private
final
int
IMAGE_MOVE
=
0
;
...
@@ -89,15 +138,20 @@ public class YGODialogUtil {
...
@@ -89,15 +138,20 @@ public class YGODialogUtil {
private
final
TextView
tv_move
;
private
final
TextView
tv_move
;
private
final
TextView
tv_copy
;
private
final
TextView
tv_copy
;
private
final
TextView
tv_del
;
private
final
TextView
tv_del
;
private
final
TextSelectAdapter
<
DeckType
>
typeAdp
;
private
final
TextSelectAdapter
<
DeckType
>
typeAdp
;
//卡组dialog中,左列的adapter
private
final
DeckListAdapter
<
DeckFile
>
deckAdp
;
private
final
DeckListAdapter
<
DeckFile
>
deckAdp
;
//卡组dialog中,右列的adapter
private
final
DeckListAdapter
<
DeckFile
>
resultListAdapter
;
private
final
DeckListAdapter
<
DeckFile
>
resultListAdapter
;
private
final
List
<
DeckFile
>
allDeckList
;
private
final
List
<
DeckFile
>
allDeckList
;
//存储所有卡组DeckFile,用于支持“根据关键词搜索卡组”功能
private
final
RecyclerView
rv_type
,
rv_deck
,
rv_result_list
;
private
final
RecyclerView
rv_type
,
rv_deck
,
rv_result_list
;
private
final
List
<
DeckFile
>
resultList
;
private
final
List
<
DeckFile
>
resultList
;
//存储卡组“根据关键词搜索”的结果
private
final
DialogPlus
ygoDialog
;
private
final
DialogPlus
ygoDialog
;
/**
* @param context
* @param selectDeckPath 外部传入当前选中的卡组路径
* @param onDeckMenuListener
*/
public
ViewHolder
(
Context
context
,
String
selectDeckPath
,
OnDeckMenuListener
onDeckMenuListener
)
{
public
ViewHolder
(
Context
context
,
String
selectDeckPath
,
OnDeckMenuListener
onDeckMenuListener
)
{
ygoDialog
=
new
DialogPlus
(
context
);
ygoDialog
=
new
DialogPlus
(
context
);
ygoDialog
.
setContentView
(
R
.
layout
.
dialog_deck_select
);
ygoDialog
.
setContentView
(
R
.
layout
.
dialog_deck_select
);
...
@@ -131,9 +185,10 @@ public class YGODialogUtil {
...
@@ -131,9 +185,10 @@ public class YGODialogUtil {
List
<
DeckType
>
typeList
=
DeckUtil
.
getDeckTypeList
(
context
);
List
<
DeckType
>
typeList
=
DeckUtil
.
getDeckTypeList
(
context
);
int
typeSelectPosition
=
2
;
int
typeSelectPosition
=
2
;
//卡组分类选择,默认值为2(未分类卡组)。0代表“卡包展示”,1代表“人机卡组”
int
deckSelectPosition
=
-
1
;
int
deckSelectPosition
=
-
1
;
List
<
DeckFile
>
deckList
;
List
<
DeckFile
>
deckList
;
//存储当前卡组分类下的所有卡组
//根据卡组路径得到该卡组所属分类
if
(!
TextUtils
.
isEmpty
(
selectDeckPath
))
{
if
(!
TextUtils
.
isEmpty
(
selectDeckPath
))
{
File
file
=
new
File
(
selectDeckPath
);
File
file
=
new
File
(
selectDeckPath
);
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
...
@@ -147,6 +202,7 @@ public class YGODialogUtil {
...
@@ -147,6 +202,7 @@ public class YGODialogUtil {
typeSelectPosition
=
1
;
typeSelectPosition
=
1
;
}
else
if
(
cateName
.
equals
(
"deck"
)
&&
parentName
.
equals
(
Constants
.
PREF_DEF_GAME_DIR
))
{
}
else
if
(
cateName
.
equals
(
"deck"
)
&&
parentName
.
equals
(
Constants
.
PREF_DEF_GAME_DIR
))
{
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
typeSelectPosition
=
2
;
}
else
{
}
else
{
//其他卡包
//其他卡包
for
(
int
i
=
3
;
i
<
typeList
.
size
();
i
++)
{
for
(
int
i
=
3
;
i
<
typeList
.
size
();
i
++)
{
...
@@ -159,11 +215,14 @@ public class YGODialogUtil {
...
@@ -159,11 +215,14 @@ public class YGODialogUtil {
}
}
}
}
}
}
//根据卡组分类查出属于该分类下的所有卡组
deckList
=
DeckUtil
.
getDeckList
(
typeList
.
get
(
typeSelectPosition
).
getPath
());
deckList
=
DeckUtil
.
getDeckList
(
typeList
.
get
(
typeSelectPosition
).
getPath
());
for
(
int
i
=
0
;
i
<
typeList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
typeList
.
size
();
i
++)
{
allDeckList
.
addAll
(
DeckUtil
.
getDeckList
(
typeList
.
get
(
i
).
getPath
()));
//把所有分类里的卡组全部纳入,用于关键词查询目标
if
(
typeList
.
get
(
i
).
isLocal
())
{
allDeckList
.
addAll
(
DeckUtil
.
getDeckList
(
typeList
.
get
(
i
).
getPath
()));
//把所有分类里的卡组全部纳入,用于关键词查询目标
}
//在线卡组对应的项的path是空字符串
}
}
if
(
typeSelectPosition
==
0
)
{
if
(
typeSelectPosition
==
0
)
{
//如果选中卡包,判断是否开启了先行卡,是的话加载先行卡
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
try
{
try
{
deckList
.
addAll
(
0
,
DeckUtil
.
getExpansionsDeckList
());
//置顶ypk缓存的cacheDeck下的先行卡ydk
deckList
.
addAll
(
0
,
DeckUtil
.
getExpansionsDeckList
());
//置顶ypk缓存的cacheDeck下的先行卡ydk
...
@@ -181,19 +240,71 @@ public class YGODialogUtil {
...
@@ -181,19 +240,71 @@ public class YGODialogUtil {
public
void
onItemSelect
(
int
position
,
DeckType
item
)
{
public
void
onItemSelect
(
int
position
,
DeckType
item
)
{
clearDeckSelect
();
clearDeckSelect
();
deckList
.
clear
();
deckList
.
clear
();
deckList
.
addAll
(
DeckUtil
.
getDeckList
(
item
.
getPath
()));
if
(
item
.
getOnServer
()
==
DeckType
.
ServerType
.
SQUARE
)
{
if
(
position
==
0
)
{
VUiKit
.
defer
().
when
(()
->
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
SquareDeckResponse
result
=
DeckSquareApiUtil
.
getSquareDecks
();
try
{
if
(!
DeckUtil
.
getExpansionsDeckList
().
isEmpty
())
{
if
(
result
==
null
)
{
deckList
.
addAll
(
0
,
DeckUtil
.
getExpansionsDeckList
());
return
null
;
}
else
{
return
result
.
getData
().
getRecords
();
}
}).
fail
(
e
->
{
YGOUtil
.
showTextToast
(
"Fetch square deck fail"
);
}).
done
(
exCardDataList
->
{
if
(
exCardDataList
!=
null
)
{
LogUtil
.
i
(
TAG
,
"Get square deck success"
);
for
(
OnlineDeckDetail
deckRecord
:
exCardDataList
)
{
DeckFile
deckFile
=
new
DeckFile
(
deckRecord
.
getDeckName
(),
""
,
DeckType
.
ServerType
.
SQUARE
,
deckRecord
.
getDeckId
());
deckList
.
add
(
deckFile
);
}
deckAdp
.
notifyDataSetChanged
();
}
});
}
else
if
(
item
.
getOnServer
()
==
DeckType
.
ServerType
.
MY_SQUARE
)
{
VUiKit
.
defer
().
when
(()
->
{
String
serverToken
=
SharedPreferenceUtil
.
getServerToken
();
Integer
serverUserId
=
SharedPreferenceUtil
.
getServerUserId
();
MyDeckResponse
result
=
DeckSquareApiUtil
.
getUserDecks
(
serverUserId
,
serverToken
);
if
(
result
==
null
)
{
return
null
;
}
else
{
return
result
.
getData
();
}
}).
fail
(
e
->
{
YGOUtil
.
showTextToast
(
"Fetch square deck fail"
);
}).
done
(
exCardDataList
->
{
if
(
exCardDataList
!=
null
)
{
LogUtil
.
i
(
TAG
,
"Get square deck success"
);
for
(
MyOnlineDeckDetail
deckRecord
:
exCardDataList
)
{
DeckFile
deckFile
=
new
DeckFile
(
deckRecord
.
getDeckName
(),
""
,
DeckType
.
ServerType
.
MY_SQUARE
,
deckRecord
.
getDeckId
());
deckList
.
add
(
deckFile
);
}
deckAdp
.
notifyDataSetChanged
();
}
});
}
else
{
deckList
.
addAll
(
DeckUtil
.
getDeckList
(
item
.
getPath
()));
if
(
position
==
0
)
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
try
{
if
(!
DeckUtil
.
getExpansionsDeckList
().
isEmpty
())
{
deckList
.
addAll
(
0
,
DeckUtil
.
getExpansionsDeckList
());
}
}
catch
(
IOException
e
)
{
YGOUtil
.
showTextToast
(
"额外卡库加载失败,原因为"
+
e
);
}
}
}
catch
(
IOException
e
)
{
YGOUtil
.
showTextToast
(
"额外卡库加载失败,原因为"
+
e
);
}
}
}
}
deckAdp
.
notifyDataSetChanged
();
}
}
deckAdp
.
notifyDataSetChanged
();
}
}
});
});
deckAdp
.
setOnItemSelectListener
(
new
DeckListAdapter
.
OnItemSelectListener
<
DeckFile
>()
{
deckAdp
.
setOnItemSelectListener
(
new
DeckListAdapter
.
OnItemSelectListener
<
DeckFile
>()
{
...
@@ -503,6 +614,9 @@ public class YGODialogUtil {
...
@@ -503,6 +614,9 @@ public class YGODialogUtil {
}
}
}
}
/**
* 根据et_input_deck_name的当前值,在allDeckList中搜索卡组
*/
private
void
searchDeck
()
{
private
void
searchDeck
()
{
resultList
.
clear
();
resultList
.
clear
();
et_input_deck_name
.
clearFocus
();
et_input_deck_name
.
clearFocus
();
...
@@ -526,6 +640,13 @@ public class YGODialogUtil {
...
@@ -526,6 +640,13 @@ public class YGODialogUtil {
return
types
;
return
types
;
}
}
/**
* 从deckList中检索包含keyword的卡组
*
* @param keyword
* @param deckList
* @return
*/
private
List
<
DeckFile
>
getResultList
(
String
keyword
,
List
<
DeckFile
>
deckList
)
{
private
List
<
DeckFile
>
getResultList
(
String
keyword
,
List
<
DeckFile
>
deckList
)
{
List
<
DeckFile
>
resultList
=
new
ArrayList
<>();
List
<
DeckFile
>
resultList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
deckList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
deckList
.
size
();
i
++)
{
...
@@ -557,6 +678,7 @@ public class YGODialogUtil {
...
@@ -557,6 +678,7 @@ public class YGODialogUtil {
return
moveTypeList
;
return
moveTypeList
;
}
}
//将界面上的iv_move、iv_del、iv_copy等图标颜色恢复,启用其点击事件
private
void
showAllDeckUtil
()
{
private
void
showAllDeckUtil
()
{
ImageUtil
.
reImageColor
(
IMAGE_MOVE
,
iv_move
);
//可用时用原图标色
ImageUtil
.
reImageColor
(
IMAGE_MOVE
,
iv_move
);
//可用时用原图标色
ImageUtil
.
reImageColor
(
IMAGE_DEL
,
iv_del
);
ImageUtil
.
reImageColor
(
IMAGE_DEL
,
iv_del
);
...
@@ -569,6 +691,7 @@ public class YGODialogUtil {
...
@@ -569,6 +691,7 @@ public class YGODialogUtil {
ll_move
.
setEnabled
(
true
);
ll_move
.
setEnabled
(
true
);
}
}
//将界面上的iv_move、iv_del、iv_copy等图标颜色改为灰色,禁用其点击事件
private
void
hideAllDeckUtil
()
{
private
void
hideAllDeckUtil
()
{
ImageUtil
.
setGrayImage
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
setGrayImage
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
setGrayImage
(
IMAGE_DEL
,
iv_del
);
ImageUtil
.
setGrayImage
(
IMAGE_DEL
,
iv_del
);
...
@@ -581,6 +704,7 @@ public class YGODialogUtil {
...
@@ -581,6 +704,7 @@ public class YGODialogUtil {
ll_move
.
setEnabled
(
false
);
ll_move
.
setEnabled
(
false
);
}
}
//将界面上的iv_copy图标颜色恢复,启用其点击事件
private
void
showCopyDeckUtil
()
{
private
void
showCopyDeckUtil
()
{
ImageUtil
.
setGrayImage
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
setGrayImage
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
setGrayImage
(
IMAGE_DEL
,
iv_del
);
ImageUtil
.
setGrayImage
(
IMAGE_DEL
,
iv_del
);
...
@@ -593,6 +717,7 @@ public class YGODialogUtil {
...
@@ -593,6 +717,7 @@ public class YGODialogUtil {
ll_move
.
setEnabled
(
false
);
ll_move
.
setEnabled
(
false
);
}
}
//清除选中卡组的记录,隐藏对卡组进行复制、移动、删除的控件
private
void
clearDeckSelect
()
{
private
void
clearDeckSelect
()
{
deckAdp
.
setManySelect
(
false
);
deckAdp
.
setManySelect
(
false
);
hideAllDeckUtil
();
hideAllDeckUtil
();
...
...
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,45 +78,46 @@
...
@@ -71,45 +78,46 @@
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"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<TextView
<TextView
android:id=
"@+id/TextExtra"
android:id=
"@+id/TextExtra"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"/"
android:text=
"/"
android:textColor=
"@android:color/holo_green_light"
android:textColor=
"@android:color/holo_green_light"
android:textSize=
"10sp"
/>
android:textSize=
"10sp"
/>
<TextView
<TextView
android:id=
"@+id/count_ex"
android:id=
"@+id/count_ex"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/holo_blue_bright"
android:textColor=
"@color/holo_blue_bright"
android:textSize=
"10sp"
android:textSize=
"10sp"
tools:text=
"15"
/>
tools:text=
"15"
/>
<TextView
<TextView
android:id=
"@+id/TextSide"
android:id=
"@+id/TextSide"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"/"
android:text=
"/"
android:textColor=
"@android:color/holo_green_light"
android:textColor=
"@android:color/holo_green_light"
android:textSize=
"10sp"
/>
android:textSize=
"10sp"
/>
<TextView
<TextView
android:id=
"@+id/count_side"
android:id=
"@+id/count_side"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxLines=
"1"
android:maxLines=
"1"
android:singleLine=
"true"
android:singleLine=
"true"
android:textColor=
"@color/holo_blue_bright"
android:textColor=
"@color/holo_blue_bright"
android:textSize=
"10sp"
android:textSize=
"10sp"
tools:text=
"15"
/>
tools:text=
"15"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</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