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
a58c013d
Commit
a58c013d
authored
Jul 24, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分享卡组时取消排序
分享卡组操作优化 卡组管理
parent
1cb1cf93
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
954 additions
and
163 deletions
+954
-163
mobile/build.gradle
mobile/build.gradle
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckType.java
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckType.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/bean/events/DeckFile.java
...c/main/java/cn/garymb/ygomobile/bean/events/DeckFile.java
+6
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/TextSelectAdapter.java
...va/cn/garymb/ygomobile/ui/adapters/TextSelectAdapter.java
+74
-44
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
...cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
+158
-66
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
...arymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/ImageUtil.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/util/ImageUtil.java
+33
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
...le/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
+49
-0
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
+0
-20
mobile/src/main/java/cn/garymb/ygomobile/utils/YGODialogUtil.java
...rc/main/java/cn/garymb/ygomobile/utils/YGODialogUtil.java
+344
-17
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
+4
-0
mobile/src/main/java/cn/garymb/ygomobile/utils/recyclerview/DeckTypeTouchHelperCallback.java
...obile/utils/recyclerview/DeckTypeTouchHelperCallback.java
+77
-0
mobile/src/main/res/drawable-xhdpi/ic_add.png
mobile/src/main/res/drawable-xhdpi/ic_add.png
+0
-0
mobile/src/main/res/drawable-xhdpi/ic_copy.png
mobile/src/main/res/drawable-xhdpi/ic_copy.png
+0
-0
mobile/src/main/res/drawable-xhdpi/ic_del.png
mobile/src/main/res/drawable-xhdpi/ic_del.png
+0
-0
mobile/src/main/res/drawable-xhdpi/ic_move.png
mobile/src/main/res/drawable-xhdpi/ic_move.png
+0
-0
mobile/src/main/res/layout/dialog_deck_select.xml
mobile/src/main/res/layout/dialog_deck_select.xml
+137
-8
mobile/src/main/res/layout/dialog_deck_share.xml
mobile/src/main/res/layout/dialog_deck_share.xml
+64
-0
mobile/src/main/res/layout/text_select_item.xml
mobile/src/main/res/layout/text_select_item.xml
+2
-1
No files found.
mobile/build.gradle
View file @
a58c013d
...
@@ -104,8 +104,8 @@ dependencies {
...
@@ -104,8 +104,8 @@ dependencies {
//
//
implementation
(
name:
'paysdk-release-1.2.4'
,
ext:
'aar'
)
implementation
(
name:
'paysdk-release-1.2.4'
,
ext:
'aar'
)
implementation
"com.pgyersdk:sdk:3.0.5"
implementation
"com.pgyersdk:sdk:3.0.5"
//dialog库
//dialog库
implementation
'com.github.feihuaduo:DialogUtils:1.8.9'
implementation
'com.github.feihuaduo:DialogUtils:1.8.9'
//recyclerview的adapter库
implementation
'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30'
}
}
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckType.java
View file @
a58c013d
...
@@ -8,7 +8,7 @@ public class DeckType extends TextSelect {
...
@@ -8,7 +8,7 @@ public class DeckType extends TextSelect {
this
.
name
=
name
;
this
.
name
=
name
;
this
.
path
=
path
;
this
.
path
=
path
;
super
.
setName
(
name
);
super
.
setName
(
name
);
s
uper
.
s
etObject
(
this
);
setObject
(
this
);
}
}
public
String
getName
()
{
public
String
getName
()
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/events/DeckFile.java
View file @
a58c013d
package
cn.garymb.ygomobile.bean.events
;
package
cn.garymb.ygomobile.bean.events
;
import
androidx.annotation.Nullable
;
import
java.io.File
;
import
java.io.File
;
import
cn.garymb.ygomobile.bean.TextSelect
;
import
cn.garymb.ygomobile.bean.TextSelect
;
...
@@ -14,13 +16,15 @@ public class DeckFile extends TextSelect {
...
@@ -14,13 +16,15 @@ public class DeckFile extends TextSelect {
name
=
new
File
(
path
).
getName
();
name
=
new
File
(
path
).
getName
();
name
=
name
.
substring
(
0
,
name
.
lastIndexOf
(
"."
));
name
=
name
.
substring
(
0
,
name
.
lastIndexOf
(
"."
));
super
.
setName
(
name
);
super
.
setName
(
name
);
s
uper
.
s
etObject
(
this
);
setObject
(
this
);
}
}
public
DeckFile
(
File
file
)
{
public
DeckFile
(
File
file
)
{
path
=
file
.
getAbsolutePath
();
path
=
file
.
getAbsolutePath
();
name
=
file
.
getName
();
name
=
file
.
getName
();
name
=
name
.
substring
(
0
,
name
.
lastIndexOf
(
"."
));
name
=
name
.
substring
(
0
,
name
.
lastIndexOf
(
"."
));
super
.
setName
(
name
);
setObject
(
this
);
}
}
public
String
getName
()
{
public
String
getName
()
{
...
@@ -38,4 +42,5 @@ public class DeckFile extends TextSelect {
...
@@ -38,4 +42,5 @@ public class DeckFile extends TextSelect {
public
void
setPath
(
String
path
)
{
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
this
.
path
=
path
;
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/TextSelectAdapter.java
View file @
a58c013d
package
cn.garymb.ygomobile.ui.adapters
;
package
cn.garymb.ygomobile.ui.adapters
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.chad.library.adapter.base.BaseViewHolder
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.bean.TextSelect
;
import
cn.garymb.ygomobile.bean.TextSelect
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
TextSelectAdapter
extends
RecyclerView
.
Adapter
<
TextSelectAdapter
.
ViewHolder
>
{
public
class
TextSelectAdapter
<
T
extends
TextSelect
>
extends
BaseQuickAdapter
<
T
,
Base
ViewHolder
>
{
private
OnItemSelectListener
onItemSelectListener
;
private
OnItemSelectListener
onItemSelectListener
;
private
List
<?
extends
TextSelect
>
data
;
private
int
selectPosition
;
private
int
selectPosition
;
private
boolean
isSelect
;
public
TextSelectAdapter
(
List
<?
extends
TextSelect
>
data
,
int
selectPosition
)
{
private
boolean
isManySelect
;
this
.
data
=
data
;
private
List
<
T
>
selectList
;
this
.
selectPosition
=
selectPosition
;
}
public
TextSelectAdapter
(
List
<
T
>
data
,
int
select
)
{
super
(
R
.
layout
.
text_select_item
,
data
);
@NonNull
this
.
selectPosition
=
select
;
@Override
if
(
select
>=
0
)
public
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
isSelect
=
true
;
View
view
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
text_select_item
,
parent
,
false
);
else
return
new
ViewHolder
(
view
);
isSelect
=
false
;
}
isManySelect
=
false
;
selectList
=
new
ArrayList
<>();
@Override
setOnItemClickListener
(
new
OnItemClickListener
()
{
public
void
onBindViewHolder
(
@NonNull
ViewHolder
holder
,
int
position
)
{
holder
.
tv_name
.
setText
(
data
.
get
(
position
).
getName
());
if
(
position
==
selectPosition
){
holder
.
view
.
setBackgroundColor
(
YGOUtil
.
c
(
R
.
color
.
gray
));
}
else
{
holder
.
view
.
setBackgroundColor
(
YGOUtil
.
c
(
R
.
color
.
white
));
}
holder
.
view
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
on
Click
(
View
v
)
{
public
void
on
ItemClick
(
BaseQuickAdapter
adapter
,
View
view
,
int
position
)
{
if
(
position
==
selectPosition
)
if
(
isSelect
&&
position
==
selectPosition
)
return
;
return
;
selectPosition
=
position
;
selectPosition
=
position
;
notifyDataSetChanged
();
notifyDataSetChanged
();
onItemSelectListener
.
onItemSelect
(
position
,
data
.
get
(
position
).
getObject
());
if
(
onItemSelectListener
!=
null
)
onItemSelectListener
.
onItemSelect
(
position
,
data
.
get
(
position
).
getObject
());
}
}
});
});
}
}
public
void
setOnItemSelectListener
(
OnItemSelectListener
onItemSelectListener
)
{
@Override
this
.
onItemSelectListener
=
onItemSelectListener
;
protected
void
convert
(
BaseViewHolder
helper
,
T
item
)
{
int
position
=
helper
.
getAdapterPosition
();
helper
.
setText
(
R
.
id
.
tv_name
,
item
.
getName
());
if
(
isManySelect
)
{
if
(
selectList
.
contains
(
item
))
helper
.
setBackgroundColor
(
R
.
id
.
ll_layout
,
YGOUtil
.
c
(
R
.
color
.
gray
));
else
helper
.
setBackgroundRes
(
R
.
id
.
ll_layout
,
R
.
drawable
.
click_background
);
}
else
if
(
isSelect
)
{
if
(
position
==
selectPosition
)
{
helper
.
setBackgroundColor
(
R
.
id
.
ll_layout
,
YGOUtil
.
c
(
R
.
color
.
gray
));
}
else
{
helper
.
setBackgroundRes
(
R
.
id
.
ll_layout
,
R
.
drawable
.
click_background
);
}
}
else
{
helper
.
setBackgroundRes
(
R
.
id
.
ll_layout
,
R
.
drawable
.
click_background
);
}
}
}
@Override
public
void
setSelectPosition
(
int
selectPosition
)
{
public
int
getItemCount
()
{
this
.
selectPosition
=
selectPosition
;
return
data
.
size
();
}
public
boolean
isSelect
()
{
return
isSelect
;
}
}
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
public
boolean
isManySelect
()
{
return
isManySelect
;
}
View
view
;
public
void
addManySelect
(
T
t
)
{
TextView
tv_name
;
if
(
selectList
.
contains
(
t
))
selectList
.
remove
(
t
);
else
selectList
.
add
(
t
);
}
public
ViewHolder
(
View
view
)
{
public
void
setManySelect
(
boolean
manySelect
)
{
super
(
view
);
isManySelect
=
manySelect
;
this
.
view
=
view
;
if
(!
isManySelect
)
{
this
.
tv_name
=
view
.
findViewById
(
R
.
id
.
tv_name
);
selectList
.
clear
();
notifyDataSetChanged
();
}
}
}
}
public
List
<
T
>
getSelectList
()
{
return
selectList
;
}
public
int
getSelectPosition
()
{
return
selectPosition
;
}
public
void
setOnItemSelectListener
(
OnItemSelectListener
onItemSelectListener
)
{
this
.
onItemSelectListener
=
onItemSelectListener
;
}
public
interface
OnItemSelectListener
<
T
>
{
public
interface
OnItemSelectListener
<
T
>
{
void
onItemSelect
(
int
position
,
T
item
);
void
onItemSelect
(
int
position
,
T
item
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
View file @
a58c013d
...
@@ -17,7 +17,9 @@ import android.view.MenuItem;
...
@@ -17,7 +17,9 @@ import android.view.MenuItem;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.Spinner
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -51,7 +53,9 @@ import cn.garymb.ygomobile.AppsSettings;
...
@@ -51,7 +53,9 @@ import cn.garymb.ygomobile.AppsSettings;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.Deck
;
import
cn.garymb.ygomobile.bean.Deck
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.events.CardInfoEvent
;
import
cn.garymb.ygomobile.bean.events.CardInfoEvent
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
...
@@ -61,6 +65,7 @@ import cn.garymb.ygomobile.ui.cards.deck.DeckItem;
...
@@ -61,6 +65,7 @@ import cn.garymb.ygomobile.ui.cards.deck.DeckItem;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemTouchHelper
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemTouchHelper
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemType
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemType
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckLayoutManager
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckLayoutManager
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.Util
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.Util
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener
;
import
cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener
;
...
@@ -79,7 +84,7 @@ import ocgcore.enums.LimitType;
...
@@ -79,7 +84,7 @@ import ocgcore.enums.LimitType;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
class
DeckManagerActivityImpl
extends
BaseCardsAcitivity
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
{
class
DeckManagerActivityImpl
extends
BaseCardsAcitivity
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
,
YGODialogUtil
.
OnDeckMenuListener
{
//region ui onCreate/onDestroy
//region ui onCreate/onDestroy
private
RecyclerView
mRecyclerView
;
private
RecyclerView
mRecyclerView
;
...
@@ -95,14 +100,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -95,14 +100,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
private
CardDetail
mCardDetail
;
private
CardDetail
mCardDetail
;
private
DialogPlus
mDialog
;
private
DialogPlus
mDialog
;
private
DialogPlus
builderShareLoading
;
private
DialogPlus
builderShareLoading
;
private
DialogUtils
du
;
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
du
=
DialogUtils
.
getdx
(
this
);
tv_deck
=
$
(
R
.
id
.
tv_deck
);
tv_deck
=
$
(
R
.
id
.
tv_deck
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
mDeckSpinner
.
setPopupBackgroundResource
(
R
.
color
.
colorNavy
);
mDeckSpinner
.
setPopupBackgroundResource
(
R
.
color
.
colorNavy
);
mLimitSpinner
=
$
(
R
.
id
.
sp_limit_list
);
mLimitSpinner
=
$
(
R
.
id
.
sp_limit_list
);
...
@@ -158,11 +161,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -158,11 +161,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
tv_deck
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
tv_deck
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
YGODialogUtil
.
dialogDeckSelect
(
DeckManagerActivityImpl
.
this
,
null
);
YGODialogUtil
.
dialogDeckSelect
(
DeckManagerActivityImpl
.
this
,
AppsSettings
.
get
().
getLastDeckPath
(),
DeckManagerActivityImpl
.
this
);
}
}
});
});
}
}
@Override
@Override
protected
void
onDestroy
()
{
protected
void
onDestroy
()
{
EventBus
.
getDefault
().
unregister
(
this
);
EventBus
.
getDefault
().
unregister
(
this
);
...
@@ -288,10 +292,11 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -288,10 +292,11 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
if
(
file
!=
null
&&
file
.
exists
())
{
if
(
file
!=
null
&&
file
.
exists
())
{
String
name
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
String
name
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
setActionBarSubTitle
(
name
);
setActionBarSubTitle
(
name
);
if
(
inDeckDir
(
file
))
{
// if (inDeckDir(file)) {
//deck文件夹里面的,则保存文件
//记住最后打开的卡组
mSettings
.
setLastDeckPath
(
file
.
getAbsolutePath
());
mSettings
.
setLastDeckPath
(
file
.
getAbsolutePath
());
}
tv_deck
.
setText
(
name
);
// }
}
else
{
}
else
{
setActionBarSubTitle
(
getString
(
R
.
string
.
noname
));
setActionBarSubTitle
(
getString
(
R
.
string
.
noname
));
}
}
...
@@ -604,10 +609,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -604,10 +609,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
case
R
.
id
.
action_save
:
case
R
.
id
.
action_save
:
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
==
mDeckAdapater
.
getYdkFile
())
{
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
==
mDeckAdapater
.
getYdkFile
())
{
//需要保存到deck文件夹
//需要保存到deck文件夹
inputDeckName
(
mPreLoadFile
,
true
);
inputDeckName
(
mPreLoadFile
,
null
,
true
);
}
else
{
}
else
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
inputDeckName
(
null
,
true
);
inputDeckName
(
null
,
null
,
true
);
}
else
{
}
else
{
save
(
mDeckAdapater
.
getYdkFile
());
save
(
mDeckAdapater
.
getYdkFile
());
}
}
...
@@ -621,32 +626,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -621,32 +626,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
// }
// }
// break;
// break;
case
R
.
id
.
action_rename
:
case
R
.
id
.
action_rename
:
inputDeckName
(
mDeckAdapater
.
getYdkFile
(),
false
);
inputDeckName
(
mDeckAdapater
.
getYdkFile
(),
null
,
false
);
break
;
case
R
.
id
.
action_deck_new
:
createDeck
(
null
);
break
;
break
;
case
R
.
id
.
action_deck_new
:
{
final
File
old
=
mDeckAdapater
.
getYdkFile
();
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_keep_cur_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
dlg
.
dismiss
();
//复制当前卡组
inputDeckName
(
old
,
true
);
});
builder
.
setRightButtonListener
((
dlg
,
rs
)
->
{
dlg
.
dismiss
();
setCurDeck
(
null
);
inputDeckName
(
null
,
true
);
});
builder
.
setOnCloseLinster
((
dlg
)
->
{
dlg
.
dismiss
();
setCurDeck
(
null
);
inputDeckName
(
null
,
true
);
});
builder
.
show
();
}
break
;
case
R
.
id
.
action_clear_deck
:
{
case
R
.
id
.
action_clear_deck
:
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setTitle
(
R
.
string
.
question
);
...
@@ -695,43 +680,67 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -695,43 +680,67 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
return
true
;
return
true
;
}
}
private
void
createDeck
(
String
savePath
)
{
final
File
old
=
mDeckAdapater
.
getYdkFile
();
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_keep_cur_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
dlg
.
dismiss
();
//复制当前卡组
inputDeckName
(
old
,
savePath
,
true
);
});
builder
.
setRightButtonListener
((
dlg
,
rs
)
->
{
dlg
.
dismiss
();
setCurDeck
(
null
);
inputDeckName
(
null
,
savePath
,
true
);
});
builder
.
setOnCloseLinster
((
dlg
)
->
{
dlg
.
dismiss
();
setCurDeck
(
null
);
inputDeckName
(
null
,
savePath
,
true
);
});
builder
.
show
();
}
private
File
getFirstYdk
()
{
private
File
getFirstYdk
()
{
List
<
File
>
files
=
getYdkFiles
();
List
<
File
>
files
=
getYdkFiles
();
return
files
==
null
||
files
.
size
()
==
0
?
null
:
files
.
get
(
0
);
return
files
==
null
||
files
.
size
()
==
0
?
null
:
files
.
get
(
0
);
}
}
private
void
shareDeck
(){
private
void
shareDeck
()
{
builderShareLoading
=
new
DialogPlus
(
this
);
builderShareLoading
=
new
DialogPlus
(
this
);
builderShareLoading
.
showProgressBar
();
builderShareLoading
.
showProgressBar
();
builderShareLoading
.
hideTitleBar
();
builderShareLoading
.
hideTitleBar
();
builderShareLoading
.
setMessage
(
R
.
string
.
Pre_share
);
builderShareLoading
.
setMessage
(
R
.
string
.
Pre_share
);
builderShareLoading
.
show
();
builderShareLoading
.
show
();
//先排序
//先排序
mDeckAdapater
.
sort
();
//
mDeckAdapater.sort();
//保存
//保存
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
==
mDeckAdapater
.
getYdkFile
())
{
//
if (mPreLoadFile != null && mPreLoadFile == mDeckAdapater.getYdkFile()) {
//需要保存到deck文件夹
//
//需要保存到deck文件夹
inputDeckName
(
mPreLoadFile
,
true
);
// inputDeckName(mPreLoadFile, null
, true);
}
else
{
//
} else {
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
//
if (mDeckAdapater.getYdkFile() == null) {
inputDeckName
(
null
,
true
);
// inputDeckName(null,
null, true);
}
else
{
//
} else {
save
(
mDeckAdapater
.
getYdkFile
());
//
save(mDeckAdapater.getYdkFile());
}
//
}
}
//
}
//保存成功后重新加载卡组
//
//保存成功后重新加载卡组
File
file
=
getSelectDeck
(
mDeckSpinner
);
//
File file = getSelectDeck(mDeckSpinner);
if
(
file
!=
null
)
{
//
if (file != null) {
loadDeckFromFile
(
file
);
//
loadDeckFromFile(file);
}
//
}
//延时
一秒,等排好序再分享
//延时
半秒,使整体看起来更流畅
new
Handler
().
postDelayed
(
new
Runnable
()
{
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
shareDeck1
();
shareDeck1
();
}
}
},
10
00
);
},
5
00
);
}
}
private
void
shareDeck1
()
{
private
void
shareDeck1
()
{
...
@@ -758,14 +767,42 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -758,14 +767,42 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
}
}
String
savePath
=
new
File
(
AppsSettings
.
get
().
getDeckSharePath
(),
deckName
+
".jpg"
).
getAbsolutePath
();
String
savePath
=
new
File
(
AppsSettings
.
get
().
getDeckSharePath
(),
deckName
+
".jpg"
).
getAbsolutePath
();
BitmapUtil
.
saveBitmap
(
bitmap
,
savePath
,
50
);
BitmapUtil
.
saveBitmap
(
bitmap
,
savePath
,
50
);
ShareUtil
.
shareImage
(
DeckManagerActivityImpl
.
this
,
"卡组分享"
,
savePath
,
null
);
//复制前关闭决斗助手
stopService
(
new
Intent
(
this
,
ServiceDuelAssistant
.
class
));
Util
.
fzMessage
(
this
,
mDeckAdapater
.
getDeckInfo
().
toDeck
().
toAppUri
().
toString
());
showToast
(
getString
(
R
.
string
.
deck_text_copyed
));
//复制完毕开启决斗助手
Util
.
startDuelService
(
this
);
builderShareLoading
.
dismiss
();
builderShareLoading
.
dismiss
();
DialogUtils
du
=
DialogUtils
.
getdx
(
DeckManagerActivityImpl
.
this
);
View
viewDialog
=
du
.
dialogBottomSheet
(
R
.
layout
.
dialog_deck_share
);
ImageView
iv_image
=
viewDialog
.
findViewById
(
R
.
id
.
iv_image
);
Button
bt_image_share
=
viewDialog
.
findViewById
(
R
.
id
.
bt_image_share
);
Button
bt_code_share
=
viewDialog
.
findViewById
(
R
.
id
.
bt_code_share
);
EditText
et_code
=
viewDialog
.
findViewById
(
R
.
id
.
et_code
);
et_code
.
setText
(
mDeckAdapater
.
getDeckInfo
().
toDeck
().
toAppUri
().
toString
());
ImageUtil
.
setImage
(
DeckManagerActivityImpl
.
this
,
savePath
,
iv_image
);
bt_code_share
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
du
.
dis
();
stopService
(
new
Intent
(
DeckManagerActivityImpl
.
this
,
ServiceDuelAssistant
.
class
));
Util
.
fzMessage
(
DeckManagerActivityImpl
.
this
,
et_code
.
getText
().
toString
().
trim
());
showToast
(
getString
(
R
.
string
.
deck_text_copyed
));
//复制完毕开启决斗助手
Util
.
startDuelService
(
DeckManagerActivityImpl
.
this
);
}
});
bt_image_share
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
du
.
dis
();
ShareUtil
.
shareImage
(
DeckManagerActivityImpl
.
this
,
"卡组分享"
,
savePath
,
null
);
}
});
//复制前关闭决斗助手
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
// final String uriString = deck.toAppUri().toString();
// final String uriString = deck.toAppUri().toString();
// final String httpUri = deck.toHttpUri().toString();
// final String httpUri = deck.toHttpUri().toString();
...
@@ -931,9 +968,8 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -931,9 +968,8 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
});
});
}
}
private
void
inputDeckName
(
File
oldYdk
,
boolean
keepOld
)
{
private
void
inputDeckName
(
File
oldYdk
,
String
savePath
,
boolean
keepOld
)
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
DialogPlus
builder
=
new
DialogPlus
(
this
);
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.
setTitle
(
R
.
string
.
intpu_name
);
builder
.
setTitle
(
R
.
string
.
intpu_name
);
EditText
editText
=
new
EditText
(
this
);
EditText
editText
=
new
EditText
(
this
);
editText
.
setGravity
(
Gravity
.
TOP
|
Gravity
.
LEFT
);
editText
.
setGravity
(
Gravity
.
TOP
|
Gravity
.
LEFT
);
...
@@ -953,7 +989,11 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -953,7 +989,11 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
if
(!
filename
.
endsWith
(
YDK_FILE_EX
))
{
if
(!
filename
.
endsWith
(
YDK_FILE_EX
))
{
filename
+=
YDK_FILE_EX
;
filename
+=
YDK_FILE_EX
;
}
}
File
ydk
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
filename
);
File
ydk
;
if
(
TextUtils
.
isEmpty
(
savePath
))
ydk
=
new
File
(
mSettings
.
getDeckDir
(),
filename
);
else
ydk
=
new
File
(
savePath
,
filename
);
if
(
ydk
.
exists
())
{
if
(
ydk
.
exists
())
{
showToast
(
R
.
string
.
file_exist
,
Toast
.
LENGTH_SHORT
);
showToast
(
R
.
string
.
file_exist
,
Toast
.
LENGTH_SHORT
);
return
;
return
;
...
@@ -1034,4 +1074,56 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
...
@@ -1034,4 +1074,56 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
menuButton
.
addBuilder
(
builder
);
menuButton
.
addBuilder
(
builder
);
mMenuIds
.
put
(
mMenuIds
.
size
(),
menuId
);
mMenuIds
.
put
(
mMenuIds
.
size
(),
menuId
);
}
}
@Override
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
loadDeckFromFile
(
new
File
(
deckFile
.
getPath
()));
}
@Override
public
void
onDeckDel
(
List
<
DeckFile
>
deckFileList
)
{
String
currentDeckPath
=
mDeckAdapater
.
getYdkFile
().
getAbsolutePath
();
for
(
DeckFile
deckFile
:
deckFileList
)
{
if
(
deckFile
.
getPath
().
equals
(
currentDeckPath
))
{
List
<
File
>
files
=
getYdkFiles
();
File
file
=
null
;
if
(
files
!=
null
&&
files
.
size
()
>
0
)
{
file
=
files
.
get
(
0
);
}
if
(
file
!=
null
)
{
loadDeckFromFile
(
file
);
}
else
{
setCurDeck
(
new
DeckInfo
());
}
return
;
}
}
}
@Override
public
void
onDeckMove
(
List
<
DeckFile
>
deckFileList
,
DeckType
toDeckType
)
{
String
currentDeckPath
=
mDeckAdapater
.
getYdkFile
().
getAbsolutePath
();
for
(
DeckFile
deckFile
:
deckFileList
)
{
if
(
deckFile
.
getPath
().
equals
(
currentDeckPath
))
{
loadDeckFromFile
(
new
File
(
toDeckType
.
getPath
(),
deckFile
.
getName
()
+
".ydk"
));
return
;
}
}
}
@Override
public
void
onDeckCopy
(
List
<
DeckFile
>
deckFileList
,
DeckType
toDeckType
)
{
String
currentDeckPath
=
mDeckAdapater
.
getYdkFile
().
getAbsolutePath
();
for
(
DeckFile
deckFile
:
deckFileList
)
{
if
(
deckFile
.
getPath
().
equals
(
currentDeckPath
))
{
loadDeckFromFile
(
new
File
(
toDeckType
.
getPath
(),
deckFile
.
getName
()
+
".ydk"
));
return
;
}
}
}
@Override
public
void
onDeckNew
(
DeckType
currentDeckType
)
{
createDeck
(
currentDeckType
.
getPath
());
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
View file @
a58c013d
...
@@ -66,7 +66,7 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
...
@@ -66,7 +66,7 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
vh
.
ic_name
.
setText
(
cm
.
getName
());
vh
.
ic_name
.
setText
(
cm
.
getName
());
//vh.ic_time.setText(cm.getTime());
//vh.ic_time.setText(cm.getTime());
vh
.
ic_message
.
setText
(
cm
.
getMessage
());
vh
.
ic_message
.
setText
(
cm
.
getMessage
());
ImageUtil
.
tuxian
(
context
,
cm
.
getAvatar
(),
vh
.
ic_avatar
);
ImageUtil
.
setAvatar
(
context
,
cm
.
getAvatar
(),
vh
.
ic_avatar
);
if
(
position
!=
0
)
{
if
(
position
!=
0
)
{
if
(
cm
.
getName
().
equals
(
data
.
get
(
position
-
1
).
getName
()))
{
if
(
cm
.
getName
().
equals
(
data
.
get
(
position
-
1
).
getName
()))
{
vh
.
ic_name
.
setVisibility
(
View
.
GONE
);
vh
.
ic_name
.
setVisibility
(
View
.
GONE
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/ImageUtil.java
View file @
a58c013d
package
cn.garymb.ygomobile.ui.mycard.mcchat.util
;
package
cn.garymb.ygomobile.ui.mycard.mcchat.util
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.ColorFilter
;
import
android.graphics.ColorMatrix
;
import
android.graphics.ColorMatrixColorFilter
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.util.Log
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
java.util.HashMap
;
import
java.util.Map
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
public
class
ImageUtil
{
public
class
ImageUtil
{
public
static
void
tuxian
(
Context
context
,
String
url
,
final
ImageView
im
)
{
public
static
void
setAvatar
(
Context
context
,
String
url
,
final
ImageView
im
)
{
if
(
url
!=
null
)
{
if
(
url
!=
null
)
{
Glide
.
with
(
context
)
Glide
.
with
(
context
)
.
load
(
Uri
.
parse
(
url
))
.
load
(
Uri
.
parse
(
url
))
...
@@ -21,4 +29,28 @@ public class ImageUtil {
...
@@ -21,4 +29,28 @@ public class ImageUtil {
}
}
}
}
public
static
void
setImage
(
Context
context
,
String
url
,
final
ImageView
im
)
{
if
(
url
!=
null
)
{
Glide
.
with
(
context
)
.
load
(
url
)
.
asBitmap
()
.
diskCacheStrategy
(
DiskCacheStrategy
.
SOURCE
)
.
placeholder
(
R
.
drawable
.
unknown
)
.
into
(
im
);
}
}
public
static
void
setGrayImage
(
int
key
,
ImageView
imageView
)
{
ColorMatrix
matrix
=
new
ColorMatrix
();
matrix
.
setSaturation
(
0
);
ColorMatrixColorFilter
filter
=
new
ColorMatrixColorFilter
(
matrix
);
imageView
.
setColorFilter
(
filter
);
}
public
static
void
reImageColor
(
int
key
,
ImageView
imageView
)
{
imageView
.
setColorFilter
(
null
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
a58c013d
...
@@ -40,6 +40,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
...
@@ -40,6 +40,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
import
cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant
;
import
cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
ocgcore.ConfigManager
;
import
ocgcore.ConfigManager
;
...
@@ -402,7 +403,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -402,7 +403,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
process
.
waitFor
();
process
.
waitFor
();
IOUtils
.
delete
(
soFile
);
IOUtils
.
delete
(
soFile
);
IO
Utils
.
copyFile
(
file
,
soFile
.
getAbsolutePath
(),
true
);
File
Utils
.
copyFile
(
file
,
soFile
.
getAbsolutePath
(),
true
);
me
.
what
=
COPY_SO_OK
;
me
.
what
=
COPY_SO_OK
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
a58c013d
...
@@ -3,6 +3,7 @@ package cn.garymb.ygomobile.utils;
...
@@ -3,6 +3,7 @@ package cn.garymb.ygomobile.utils;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
...
@@ -114,6 +115,54 @@ public class FileUtils {
...
@@ -114,6 +115,54 @@ public class FileUtils {
}
}
}
}
public
static
void
copyFile
(
String
oldPath
,
String
newPath
,
boolean
isName
)
throws
FileNotFoundException
,
IOException
{
//判断复制后的路径是否含有文件名,如果没有则加上
if
(!
isName
)
{
//由于newPath是路径加文件名,所以获取要复制的文件名与复制后的路径组成新的newPath
String
abb
[]=
oldPath
.
split
(
"/"
);
newPath
=
newPath
+
"/"
+
abb
[
abb
.
length
-
1
];
}
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
fis
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
}
fos
.
close
();
fis
.
close
();
}
public
static
void
moveFile
(
String
oldPath
,
String
newPath
,
boolean
isName
)
throws
FileNotFoundException
,
IOException
{
//判断复制后的路径是否含有文件名,如果没有则加上
if
(!
isName
)
{
//由于newPath是路径加文件名,所以获取要复制的文件名与复制后的路径组成新的newPath
String
abb
[]=
oldPath
.
split
(
"/"
);
newPath
=
newPath
+
"/"
+
abb
[
abb
.
length
-
1
];
}
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
fis
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
}
fos
.
close
();
fis
.
close
();
//删除文件
File
file
=
new
File
(
oldPath
);
if
(
file
.
exists
()
&&
file
.
isFile
())
{
file
.
delete
();
}
}
public
static
void
copy
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
public
static
void
copy
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
byte
[]
data
=
new
byte
[
1024
*
8
];
byte
[]
data
=
new
byte
[
1024
*
8
];
int
len
;
int
len
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
View file @
a58c013d
...
@@ -225,26 +225,6 @@ public class IOUtils {
...
@@ -225,26 +225,6 @@ public class IOUtils {
return
false
;
return
false
;
}
}
public
static
void
copyFile
(
String
oldPath
,
String
newPath
,
boolean
isname
)
throws
FileNotFoundException
,
IOException
{
//判断复制后的路径是否含有文件名,如果没有则加上
if
(!
isname
)
{
//由于newPath是路径加文件名,所以获取要复制的文件名与复制后的路径组成新的newPath
String
abb
[]=
oldPath
.
split
(
"/"
);
newPath
=
newPath
+
"/"
+
abb
[
abb
.
length
-
1
];
}
FileInputStream
fis
=
new
FileInputStream
(
oldPath
);
FileOutputStream
fos
=
new
FileOutputStream
(
newPath
);
byte
[]
buf
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
fis
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
}
fos
.
close
();
fis
.
close
();
}
public
static
File
asFile
(
InputStream
is
,
String
outPath
)
throws
IOException
{
public
static
File
asFile
(
InputStream
is
,
String
outPath
)
throws
IOException
{
OutputStream
os
=
null
;
OutputStream
os
=
null
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/YGODialogUtil.java
View file @
a58c013d
package
cn.garymb.ygomobile.utils
;
package
cn.garymb.ygomobile.utils
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.ItemTouchHelper
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
...
@@ -18,53 +32,80 @@ import cn.garymb.ygomobile.bean.DeckType;
...
@@ -18,53 +32,80 @@ import cn.garymb.ygomobile.bean.DeckType;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
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.plus.DialogPlus
;
import
cn.garymb.ygomobile.utils.recyclerview.DeckTypeTouchHelperCallback
;
public
class
YGODialogUtil
{
public
class
YGODialogUtil
{
public
static
void
dialogDeckSelect
(
Context
context
,
String
selectDeckPath
)
{
private
static
final
int
IMAGE_MOVE
=
0
;
View
viewDialog
=
DialogUtils
.
getdx
(
context
).
dialogBottomSheet
(
R
.
layout
.
dialog_deck_select
);
private
static
final
int
IMAGE_COPY
=
1
;
private
static
final
int
IMAGE_DEL
=
2
;
private
static
LinearLayout
ll_move
,
ll_copy
,
ll_del
,
ll_add
;
private
static
ImageView
iv_move
,
iv_copy
,
iv_del
;
private
static
TextView
tv_move
,
tv_copy
,
tv_del
;
private
static
TextSelectAdapter
typeAdp
,
deckAdp
;
private
static
Dialog
ygoDialog
;
public
static
void
dialogDeckSelect
(
Context
context
,
String
selectDeckPath
,
OnDeckMenuListener
onDeckMenuListener
)
{
DialogUtils
du
=
DialogUtils
.
getdx
(
context
);
View
viewDialog
=
du
.
dialogBottomSheet
(
R
.
layout
.
dialog_deck_select
);
RecyclerView
rv_type
,
rv_deck
;
RecyclerView
rv_type
,
rv_deck
;
rv_deck
=
viewDialog
.
findViewById
(
R
.
id
.
rv_deck
);
rv_deck
=
viewDialog
.
findViewById
(
R
.
id
.
rv_deck
);
rv_type
=
viewDialog
.
findViewById
(
R
.
id
.
rv_type
);
rv_type
=
viewDialog
.
findViewById
(
R
.
id
.
rv_type
);
ll_move
=
viewDialog
.
findViewById
(
R
.
id
.
ll_move
);
ll_copy
=
viewDialog
.
findViewById
(
R
.
id
.
ll_copy
);
ll_del
=
viewDialog
.
findViewById
(
R
.
id
.
ll_del
);
ll_add
=
viewDialog
.
findViewById
(
R
.
id
.
ll_add
);
iv_copy
=
viewDialog
.
findViewById
(
R
.
id
.
iv_copy
);
iv_move
=
viewDialog
.
findViewById
(
R
.
id
.
iv_move
);
iv_del
=
viewDialog
.
findViewById
(
R
.
id
.
iv_del
);
tv_move
=
viewDialog
.
findViewById
(
R
.
id
.
tv_move
);
tv_copy
=
viewDialog
.
findViewById
(
R
.
id
.
tv_copy
);
tv_del
=
viewDialog
.
findViewById
(
R
.
id
.
tv_del
);
hideAllDeckUtil
();
rv_deck
.
setLayoutManager
(
new
LinearLayoutManager
(
context
));
rv_deck
.
setLayoutManager
(
new
LinearLayoutManager
(
context
));
rv_type
.
setLayoutManager
(
new
LinearLayoutManager
(
context
));
rv_type
.
setLayoutManager
(
new
LinearLayoutManager
(
context
));
TextSelectAdapter
typeAdp
,
deckAdp
;
List
<
DeckType
>
typeList
=
DeckUtil
.
getDeckTypeList
(
context
);
List
<
DeckType
>
typeList
=
DeckUtil
.
getDeckTypeList
(
context
);
int
typeSelectPosition
=
2
;
int
typeSelectPosition
=
2
;
int
deckSelectPosition
=
-
1
;
int
deckSelectPosition
=
-
1
;
List
<
DeckFile
>
deckList
;
List
<
DeckFile
>
deckList
;
if
(
selectDeckPath
!=
null
)
{
if
(
selectDeckPath
!=
null
)
{
String
name
=
new
File
(
selectDeckPath
).
getParentFile
().
getName
();
String
name
=
new
File
(
selectDeckPath
).
getParentFile
().
getName
();
if
(
name
.
equals
(
"pack"
)
||
name
.
equals
(
"cacheDeck"
))
{
if
(
name
.
equals
(
"pack"
)
||
name
.
equals
(
"cacheDeck"
))
{
//卡包
//卡包
typeSelectPosition
=
0
;
typeSelectPosition
=
0
;
}
else
if
(
name
.
equals
(
"Decks"
))
{
}
else
if
(
name
.
equals
(
"Decks"
))
{
//ai卡组
//ai卡组
typeSelectPosition
=
1
;
typeSelectPosition
=
1
;
}
else
if
(
name
.
equals
(
"deck"
)
&&
new
File
(
selectDeckPath
).
getParentFile
().
getParentFile
().
getName
().
equals
(
Constants
.
PREF_DEF_GAME_DIR
))
{
}
else
if
(
name
.
equals
(
"deck"
)
&&
new
File
(
selectDeckPath
).
getParentFile
().
getParentFile
().
getName
().
equals
(
Constants
.
PREF_DEF_GAME_DIR
))
{
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
//如果是deck并且上一个目录是ygocore的话,保证不会把名字为deck的卡包识别为未分类
typeSelectPosition
=
2
;
typeSelectPosition
=
2
;
}
else
{
}
else
{
//其他卡包
//其他卡包
for
(
int
i
=
3
;
i
<
typeList
.
size
();
i
++)
{
for
(
int
i
=
3
;
i
<
typeList
.
size
();
i
++)
{
DeckType
deckType
=
typeList
.
get
(
i
);
DeckType
deckType
=
typeList
.
get
(
i
);
if
(
deckType
.
getName
().
equals
(
name
))
{
if
(
deckType
.
getName
().
equals
(
name
))
{
typeSelectPosition
=
i
;
typeSelectPosition
=
i
;
break
;
break
;
}
}
}
}
}
}
}
}
deckList
=
DeckUtil
.
getDeckList
(
typeList
.
get
(
typeSelectPosition
).
getPath
());
deckList
=
DeckUtil
.
getDeckList
(
typeList
.
get
(
typeSelectPosition
).
getPath
());
typeAdp
=
new
TextSelectAdapter
(
typeList
,
typeSelectPosition
);
typeAdp
=
new
TextSelectAdapter
<>
(
typeList
,
typeSelectPosition
);
deckAdp
=
new
TextSelectAdapter
(
deckList
,
deckSelectPosition
);
deckAdp
=
new
TextSelectAdapter
<>
(
deckList
,
deckSelectPosition
);
rv_type
.
setAdapter
(
typeAdp
);
rv_type
.
setAdapter
(
typeAdp
);
rv_deck
.
setAdapter
(
deckAdp
);
rv_deck
.
setAdapter
(
deckAdp
);
typeAdp
.
setOnItemSelectListener
(
new
TextSelectAdapter
.
OnItemSelectListener
<
DeckType
>()
{
typeAdp
.
setOnItemSelectListener
(
new
TextSelectAdapter
.
OnItemSelectListener
<
DeckType
>()
{
@Override
@Override
public
void
onItemSelect
(
int
position
,
DeckType
item
)
{
public
void
onItemSelect
(
int
position
,
DeckType
item
)
{
clearDeckSelect
();
deckList
.
clear
();
deckList
.
clear
();
deckList
.
addAll
(
DeckUtil
.
getDeckList
(
item
.
getPath
()));
deckList
.
addAll
(
DeckUtil
.
getDeckList
(
item
.
getPath
()));
if
(
position
==
0
)
{
if
(
position
==
0
)
{
...
@@ -82,13 +123,299 @@ public class YGODialogUtil {
...
@@ -82,13 +123,299 @@ public class YGODialogUtil {
deckAdp
.
setOnItemSelectListener
(
new
TextSelectAdapter
.
OnItemSelectListener
<
DeckFile
>()
{
deckAdp
.
setOnItemSelectListener
(
new
TextSelectAdapter
.
OnItemSelectListener
<
DeckFile
>()
{
@Override
@Override
public
void
onItemSelect
(
int
position
,
DeckFile
item
)
{
public
void
onItemSelect
(
int
position
,
DeckFile
item
)
{
DialogUtils
.
getdx
(
context
).
dis
();
if
(
deckAdp
.
isManySelect
())
{
deckAdp
.
addManySelect
(
item
);
deckAdp
.
notifyItemChanged
(
position
);
}
else
{
dis
();
onDeckMenuListener
.
onDeckSelect
(
item
);
}
}
}
});
});
// rv_deck.setAdapter();
deckAdp
.
setOnItemLongClickListener
(
new
BaseQuickAdapter
.
OnItemLongClickListener
()
{
@Override
public
boolean
onItemLongClick
(
BaseQuickAdapter
adapter
,
View
view
,
int
position
)
{
if
(
deckAdp
.
isSelect
()
||
typeAdp
.
getSelectPosition
()
==
0
)
return
true
;
deckAdp
.
setManySelect
(
true
);
if
(
typeAdp
.
getSelectPosition
()
==
1
)
{
showCopyDeckUtil
();
}
else
{
showAllDeckUtil
();
}
deckAdp
.
addManySelect
((
DeckFile
)
adapter
.
getItem
(
position
));
deckAdp
.
notifyItemChanged
(
position
);
return
true
;
}
});
ll_add
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
du
.
dialogl
(
"新建"
,
new
String
[]{
"分类"
,
"卡组"
}).
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
du
.
dis
();
switch
(
position
)
{
case
0
:
DialogPlus
builder
=
new
DialogPlus
(
context
);
builder
.
setTitle
(
"请输入分类名"
);
EditText
editText
=
new
EditText
(
context
);
editText
.
setGravity
(
Gravity
.
TOP
|
Gravity
.
LEFT
);
editText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_NO_SUGGESTIONS
);
editText
.
setSingleLine
();
builder
.
setContentView
(
editText
);
builder
.
setOnCloseLinster
((
dlg
)
->
{
dlg
.
dismiss
();
});
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
String
name
=
editText
.
getText
().
toString
().
trim
();
if
(
TextUtils
.
isEmpty
(
name
))
{
YGOUtil
.
show
(
"名称不能为空"
);
return
;
}
File
file
=
new
File
(
AppsSettings
.
get
().
getDeckDir
(),
name
);
IOUtils
.
createFolder
(
file
);
typeList
.
add
(
new
DeckType
(
name
,
file
.
getAbsolutePath
()));
typeAdp
.
notifyItemInserted
(
typeList
.
size
()
-
1
);
dlg
.
dismiss
();
});
builder
.
show
();
break
;
case
1
:
onDeckMenuListener
.
onDeckNew
(
typeList
.
get
(
typeAdp
.
getSelectPosition
()));
dis
();
break
;
}
}
});
}
});
ll_move
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
List
<
DeckType
>
otherType
=
getOtherTypeList
();
du
.
dialogl
(
"请选择要移动到的分类"
,
getStringType
(
otherType
)).
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
du
.
dis
();
DeckType
toType
=
otherType
.
get
(
position
);
List
<
DeckFile
>
deckFileList
=
deckAdp
.
getSelectList
();
for
(
DeckFile
deckFile
:
deckFileList
)
{
try
{
FileUtils
.
moveFile
(
deckFile
.
getPath
(),
toType
.
getPath
(),
false
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
deckList
.
remove
(
deckFile
);
}
YGOUtil
.
show
(
"移动完毕"
);
onDeckMenuListener
.
onDeckMove
(
deckAdp
.
getSelectList
(),
toType
);
clearDeckSelect
();
}
});
}
});
ll_copy
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
List
<
DeckType
>
otherType
=
getOtherTypeList
();
du
.
dialogl
(
"请选择要复制到的分类"
,
getStringType
(
otherType
)).
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
du
.
dis
();
DeckType
toType
=
otherType
.
get
(
position
);
List
<
DeckFile
>
deckFileList
=
deckAdp
.
getSelectList
();
for
(
DeckFile
deckFile
:
deckFileList
)
{
try
{
FileUtils
.
copyFile
(
deckFile
.
getPath
(),
toType
.
getPath
(),
false
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
deckList
.
remove
(
deckFile
);
}
YGOUtil
.
show
(
"复制完毕"
);
onDeckMenuListener
.
onDeckCopy
(
deckAdp
.
getSelectList
(),
toType
);
clearDeckSelect
();
}
});
}
});
ll_del
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
deckAdp
.
getSelectList
().
size
()
==
0
)
{
YGOUtil
.
show
(
"未选中卡组"
);
return
;
}
DialogPlus
dialogPlus
=
new
DialogPlus
(
context
);
dialogPlus
.
setMessage
(
"确定删除这些卡组吗?"
);
dialogPlus
.
setLeftButtonText
(
YGOUtil
.
s
(
R
.
string
.
delete
));
dialogPlus
.
setRightButtonText
(
"取消"
);
dialogPlus
.
setLeftButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
List
<
DeckFile
>
selectDeckList
=
deckAdp
.
getSelectList
();
for
(
DeckFile
deckFile
:
selectDeckList
)
{
new
File
(
deckFile
.
getPath
()).
delete
();
deckList
.
remove
(
deckFile
);
}
YGOUtil
.
show
(
"删除完毕"
);
dialogPlus
.
dismiss
();
onDeckMenuListener
.
onDeckDel
(
selectDeckList
);
clearDeckSelect
();
}
});
dialogPlus
.
setRightButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialogPlus
.
dismiss
();
}
});
dialogPlus
.
show
();
}
});
ygoDialog
=
du
.
getDialog
();
ygoDialog
.
setOnDismissListener
(
new
DialogInterface
.
OnDismissListener
()
{
@Override
public
void
onDismiss
(
DialogInterface
dialog
)
{
clearDeckSelect
();
}
});
ygoDialog
.
setOnKeyListener
(
new
DialogInterface
.
OnKeyListener
()
{
@Override
public
boolean
onKey
(
DialogInterface
dialog
,
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
if
(
deckAdp
.
isManySelect
())
{
clearDeckSelect
();
return
true
;
}
}
return
false
;
}
});
ItemTouchHelper
itemTouchHelper
=
new
ItemTouchHelper
(
new
DeckTypeTouchHelperCallback
(
new
OnDeckTypeListener
()
{
@Override
public
void
onDeckTypeListener
(
int
positon
)
{
File
file
=
new
File
(
typeList
.
get
(
positon
).
getPath
());
File
[]
files
=
file
.
listFiles
();
List
<
DeckFile
>
deckFileList
=
new
ArrayList
<>();
if
(
files
!=
null
)
{
for
(
File
file1
:
files
)
{
deckFileList
.
add
(
new
DeckFile
(
file1
));
}
}
IOUtils
.
delete
(
file
);
YGOUtil
.
show
(
"删除完毕"
);
onDeckMenuListener
.
onDeckDel
(
deckFileList
);
typeAdp
.
remove
(
positon
);
if
(
typeAdp
.
getSelectPosition
()
==
positon
)
{
typeAdp
.
setSelectPosition
(
2
);
typeAdp
.
notifyItemChanged
(
2
);
}
clearDeckSelect
();
deckList
.
clear
();
deckList
.
addAll
(
DeckUtil
.
getDeckList
(
typeList
.
get
(
2
).
getPath
()));
deckAdp
.
notifyDataSetChanged
();
}
}));
itemTouchHelper
.
attachToRecyclerView
(
rv_type
);
}
private
static
String
[]
getStringType
(
List
<
DeckType
>
deckTypeList
)
{
String
[]
types
=
new
String
[
deckTypeList
.
size
()];
for
(
int
i
=
0
;
i
<
types
.
length
;
i
++)
{
types
[
i
]
=
deckTypeList
.
get
(
i
).
getName
();
}
return
types
;
}
//获取可以移动的分类
private
static
List
<
DeckType
>
getOtherTypeList
()
{
List
<
DeckType
>
typeList
=
typeAdp
.
getData
();
List
<
DeckType
>
moveTypeList
=
new
ArrayList
<>();
DeckType
selectType
=
typeList
.
get
(
typeAdp
.
getSelectPosition
());
for
(
int
i
=
2
;
i
<
typeList
.
size
();
i
++)
{
DeckType
deckType
=
typeList
.
get
(
i
);
if
(!
deckType
.
getPath
().
equals
(
selectType
.
getPath
()))
{
moveTypeList
.
add
(
deckType
);
}
}
return
moveTypeList
;
}
public
interface
OnDeckMenuListener
{
void
onDeckSelect
(
DeckFile
deckFile
);
void
onDeckDel
(
List
<
DeckFile
>
deckFileList
);
void
onDeckMove
(
List
<
DeckFile
>
deckFileList
,
DeckType
toDeckType
);
void
onDeckCopy
(
List
<
DeckFile
>
deckFileList
,
DeckType
toDeckType
);
void
onDeckNew
(
DeckType
currentDeckType
);
}
private
static
void
showAllDeckUtil
()
{
ImageUtil
.
reImageColor
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
reImageColor
(
IMAGE_DEL
,
iv_del
);
ImageUtil
.
reImageColor
(
IMAGE_COPY
,
iv_copy
);
tv_del
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
black
));
tv_copy
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
black
));
tv_move
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
black
));
ll_del
.
setEnabled
(
true
);
ll_copy
.
setEnabled
(
true
);
ll_move
.
setEnabled
(
true
);
}
}
private
static
void
hideAllDeckUtil
()
{
ImageUtil
.
setGrayImage
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
setGrayImage
(
IMAGE_DEL
,
iv_del
);
ImageUtil
.
setGrayImage
(
IMAGE_COPY
,
iv_copy
);
tv_del
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
gray
));
tv_copy
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
gray
));
tv_move
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
gray
));
ll_del
.
setEnabled
(
false
);
ll_copy
.
setEnabled
(
false
);
ll_move
.
setEnabled
(
false
);
}
private
static
void
showCopyDeckUtil
()
{
ImageUtil
.
setGrayImage
(
IMAGE_MOVE
,
iv_move
);
ImageUtil
.
setGrayImage
(
IMAGE_DEL
,
iv_del
);
ImageUtil
.
reImageColor
(
IMAGE_COPY
,
iv_copy
);
tv_del
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
gray
));
tv_copy
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
black
));
tv_move
.
setTextColor
(
YGOUtil
.
c
(
R
.
color
.
gray
));
ll_del
.
setEnabled
(
false
);
ll_copy
.
setEnabled
(
true
);
ll_move
.
setEnabled
(
false
);
}
private
static
void
clearDeckSelect
()
{
deckAdp
.
setManySelect
(
false
);
hideAllDeckUtil
();
}
public
static
void
dis
()
{
if
(
ygoDialog
!=
null
)
ygoDialog
.
dismiss
();
}
public
interface
OnDeckTypeListener
{
void
onDeckTypeListener
(
int
position
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
View file @
a58c013d
...
@@ -5,6 +5,7 @@ import android.widget.Toast;
...
@@ -5,6 +5,7 @@ import android.widget.Toast;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.ContextCompat
;
import
cn.garymb.ygomobile.App
;
import
cn.garymb.ygomobile.App
;
import
cn.garymb.ygomobile.lite.R
;
public
class
YGOUtil
{
public
class
YGOUtil
{
...
@@ -16,4 +17,7 @@ public class YGOUtil {
...
@@ -16,4 +17,7 @@ public class YGOUtil {
public
static
int
c
(
int
colorId
){
public
static
int
c
(
int
colorId
){
return
ContextCompat
.
getColor
(
App
.
get
(),
colorId
);
return
ContextCompat
.
getColor
(
App
.
get
(),
colorId
);
}
}
public
static
String
s
(
int
stringId
){
return
App
.
get
().
getResources
().
getString
(
stringId
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/recyclerview/DeckTypeTouchHelperCallback.java
0 → 100644
View file @
a58c013d
package
cn.garymb.ygomobile.utils.recyclerview
;
import
android.content.DialogInterface
;
import
androidx.recyclerview.widget.ItemTouchHelper
;
import
androidx.recyclerview.widget.RecyclerView
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cn.garymb.ygomobile.bean.DeckType
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.ui.adapters.TextSelectAdapter
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
DeckTypeTouchHelperCallback
extends
ItemTouchHelper
.
Callback
{
private
int
dragFlags
;
private
int
swipeFlags
;
private
RecyclerView
recyclerView
;
private
YGODialogUtil
.
OnDeckTypeListener
onDeckTypeListener
;
public
DeckTypeTouchHelperCallback
(
YGODialogUtil
.
OnDeckTypeListener
onDeckTypeListener
)
{
this
.
onDeckTypeListener
=
onDeckTypeListener
;
}
@Override
public
int
getMovementFlags
(
RecyclerView
recyclerView
,
RecyclerView
.
ViewHolder
p2
)
{
dragFlags
=
0
;
swipeFlags
=
0
;
this
.
recyclerView
=
recyclerView
;
if
(
p2
.
getAdapterPosition
()
>
2
)
swipeFlags
=
ItemTouchHelper
.
START
|
ItemTouchHelper
.
END
;
return
makeMovementFlags
(
dragFlags
,
swipeFlags
);
}
@Override
public
boolean
onMove
(
RecyclerView
p1
,
RecyclerView
.
ViewHolder
p2
,
RecyclerView
.
ViewHolder
p3
)
{
return
false
;
}
@Override
public
void
onSwiped
(
RecyclerView
.
ViewHolder
vh
,
int
dire
)
{
int
positon
=
vh
.
getAdapterPosition
();
TextSelectAdapter
textSelectAdapter
=
((
TextSelectAdapter
)
recyclerView
.
getAdapter
());
DialogPlus
dialogPlus
=
new
DialogPlus
(
recyclerView
.
getContext
());
dialogPlus
.
setMessage
(
"确定删除该分类吗?分类下的卡组也将全部被删除"
);
dialogPlus
.
setLeftButtonText
(
"删除"
);
dialogPlus
.
setRightButtonText
(
"取消"
);
dialogPlus
.
setLeftButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialogPlus
.
dismiss
();
onDeckTypeListener
.
onDeckTypeListener
(
positon
);
}
});
dialogPlus
.
setRightButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
textSelectAdapter
.
notifyItemChanged
(
positon
);
dialog
.
dismiss
();
}
});
dialogPlus
.
show
();
}
}
mobile/src/main/res/drawable-xhdpi/ic_add.png
0 → 100644
View file @
a58c013d
2.37 KB
mobile/src/main/res/drawable-xhdpi/ic_copy.png
0 → 100644
View file @
a58c013d
1.22 KB
mobile/src/main/res/drawable-xhdpi/ic_del.png
0 → 100644
View file @
a58c013d
1.01 KB
mobile/src/main/res/drawable-xhdpi/ic_move.png
0 → 100644
View file @
a58c013d
1.41 KB
mobile/src/main/res/layout/dialog_deck_select.xml
View file @
a58c013d
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:gravity=
"center"
android:padding=
"10dp"
android:text=
"卡组管理"
android:textColor=
"@color/black"
android:textSize=
"15sp"
android:textStyle=
"bold"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"5dp"
android:orientation=
"horizontal"
>
<LinearLayout
android:id=
"@+id/ll_add"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@drawable/click_background"
android:gravity=
"center"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/iv_add"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
app:srcCompat=
"@drawable/ic_add"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_add"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"3dp"
android:text=
"新建"
android:textColor=
"@color/black"
android:textSize=
"12sp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_move"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@drawable/click_background"
android:gravity=
"center"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/iv_move"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
app:srcCompat=
"@drawable/ic_move"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_move"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"3dp"
android:text=
"移动"
android:textColor=
"@color/black"
android:textSize=
"12sp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_copy"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@drawable/click_background"
android:gravity=
"center"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/iv_copy"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
app:srcCompat=
"@drawable/ic_copy"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_copy"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"3dp"
android:text=
"复制"
android:textColor=
"@color/black"
android:textSize=
"12sp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_del"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@drawable/click_background"
android:gravity=
"center"
android:orientation=
"vertical"
>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/iv_del"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
app:srcCompat=
"@drawable/ic_del"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_del"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"3dp"
android:text=
"删除"
android:textColor=
"@color/black"
android:textSize=
"12sp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
...
@@ -13,17 +133,26 @@
...
@@ -13,17 +133,26 @@
android:id=
"@+id/rv_type"
android:id=
"@+id/rv_type"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
/>
android:layout_weight=
"1"
<View
android:nestedScrollingEnabled=
"false"
/>
android:background=
"@color/gray"
android:layout_width=
"1dp"
android:layout_height=
"match_parent"
/>
<androidx.recyclerview.widget.RecyclerView
<View
android:id=
"@+id/rv_deck"
android:layout_width=
"1dp"
android:layout_height=
"match_parent"
android:background=
"@color/gray"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"2"
/>
android:layout_weight=
"2"
android:orientation=
"vertical"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_deck"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:nestedScrollingEnabled=
"true"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
mobile/src/main/res/layout/dialog_deck_share.xml
0 → 100644
View file @
a58c013d
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<LinearLayout
android:background=
"@color/white"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:padding=
"20dp"
>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/share_deck"
android:textColor=
"@color/black"
android:textSize=
"23sp"
android:textStyle=
"bold"
/>
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/iv_image"
android:layout_width=
"140dp"
android:layout_height=
"280dp"
android:layout_marginTop=
"20dp"
android:scaleType=
"centerCrop"
/>
<Button
android:id=
"@+id/bt_image_share"
android:layout_marginTop=
"20dp"
android:textSize=
"15sp"
android:text=
"图片分享"
android:layout_width=
"140dp"
android:layout_height=
"50dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:layout_marginTop=
"20dp"
>
<androidx.appcompat.widget.AppCompatEditText
android:textColor=
"@color/black"
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"5dp"
android:id=
"@+id/et_code"
android:gravity=
"center"
android:textSize=
"16sp"
android:inputType=
"text"
android:background=
"@color/gray"
android:padding=
"10dp"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
/>
<Button
android:id=
"@+id/bt_code_share"
android:textSize=
"15sp"
android:text=
"卡组码分享"
android:layout_marginLeft=
"20dp"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
mobile/src/main/res/layout/text_select_item.xml
View file @
a58c013d
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/ll_layout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
match_par
ent"
android:layout_height=
"
wrap_cont
ent"
android:padding=
"10dp"
android:padding=
"10dp"
android:gravity=
"center"
android:gravity=
"center"
android:background=
"@drawable/click_background"
android:background=
"@drawable/click_background"
...
...
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