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
0474dbee
Commit
0474dbee
authored
Sep 03, 2021
by
qq247321453
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opt code
parent
43c0391b
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1396 additions
and
3439 deletions
+1396
-3439
.gitignore
.gitignore
+2
-0
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+1
-17
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+0
-4
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+0
-3
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+3
-9
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
.../java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
+66
-101
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
...rc/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchAcitivity.java
...ava/cn/garymb/ygomobile/ui/cards/CardSearchAcitivity.java
+0
-5
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivity.java
...java/cn/garymb/ygomobile/ui/cards/CardSearchActivity.java
+29
-51
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
.../main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
+110
-125
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
+1171
-5
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity2.java
...va/cn/garymb/ygomobile/ui/cards/DeckManagerActivity2.java
+0
-5
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity3.java
...va/cn/garymb/ygomobile/ui/cards/DeckManagerActivity3.java
+0
-158
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
...cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
+0
-1236
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl2.java
...n/garymb/ygomobile/ui/cards/DeckManagerActivityImpl2.java
+0
-727
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckAdapter.java
.../java/cn/garymb/ygomobile/ui/cards/deck2/DeckAdapter.java
+0
-410
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckHelperCallback.java
...n/garymb/ygomobile/ui/cards/deck2/DeckHelperCallback.java
+0
-44
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckItemDecoration.java
...n/garymb/ygomobile/ui/cards/deck2/DeckItemDecoration.java
+0
-60
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckLayoutManager.java
...cn/garymb/ygomobile/ui/cards/deck2/DeckLayoutManager.java
+0
-36
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckViewHolder.java
...va/cn/garymb/ygomobile/ui/cards/deck2/DeckViewHolder.java
+0
-131
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/IDeckLayout.java
.../java/cn/garymb/ygomobile/ui/cards/deck2/IDeckLayout.java
+0
-41
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+7
-11
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+0
-2
mobile/src/main/java/com/ourygo/assistant/service/DuelAssistantService.java
...va/com/ourygo/assistant/service/DuelAssistantService.java
+5
-11
mobile/src/main/res/layout/activity_deck_cards2.xml
mobile/src/main/res/layout/activity_deck_cards2.xml
+0
-137
mobile/src/main/res/layout/activity_deck_cards3.xml
mobile/src/main/res/layout/activity_deck_cards3.xml
+0
-108
No files found.
.gitignore
View file @
0474dbee
...
@@ -58,3 +58,5 @@ output.json
...
@@ -58,3 +58,5 @@ output.json
/libcore/.cxx
/libcore/.cxx
/libygo/.cxx
/libygo/.cxx
/mobile/assets/data/single
/mobile/assets/data/pack
mobile/src/main/AndroidManifest.xml
View file @
0474dbee
...
@@ -133,7 +133,7 @@
...
@@ -133,7 +133,7 @@
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
/>
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
/>
<activity
<activity
android:name=
"cn.garymb.ygomobile.ui.cards.CardSearchAc
i
tivity"
android:name=
"cn.garymb.ygomobile.ui.cards.CardSearchActivity"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:label=
"@string/card_search"
android:label=
"@string/card_search"
android:launchMode=
"singleTop"
android:launchMode=
"singleTop"
...
@@ -148,22 +148,6 @@
...
@@ -148,22 +148,6 @@
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustPan"
/>
android:windowSoftInputMode=
"stateAlwaysHidden|adjustPan"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.cards.DeckManagerActivity2"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:label=
"@string/deck_manager"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
android:theme=
"@style/AppTheme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustPan"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.cards.DeckManagerActivity3"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:label=
"@string/deck_manager"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
android:theme=
"@style/AppTheme"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustPan"
/>
<activity
<activity
android:name=
"cn.garymb.ygomobile.ui.file.FileActivity"
android:name=
"cn.garymb.ygomobile.ui.file.FileActivity"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
android:configChanges=
"orientation|keyboardHidden|navigation|screenSize"
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
0474dbee
...
@@ -130,10 +130,6 @@ public class AppsSettings {
...
@@ -130,10 +130,6 @@ public class AppsSettings {
return
mSharedPreferences
.
getBoolean
(
PREF_READ_EX
,
DEF_PREF_READ_EX
);
return
mSharedPreferences
.
getBoolean
(
PREF_READ_EX
,
DEF_PREF_READ_EX
);
}
}
public
boolean
isUseDeckManagerV2
()
{
return
false
;
//mSharedPreferences.getBoolean(PREF_DECK_MANAGER_V2, DEF_PREF_DECK_MANAGER_V2);
}
public
float
getXScale
(
int
w
,
int
h
)
{
public
float
getXScale
(
int
w
,
int
h
)
{
if
(
isKeepScale
())
{
if
(
isKeepScale
())
{
float
sx
=
getScreenHeight
()
/
w
;
float
sx
=
getScreenHeight
()
/
w
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
0474dbee
...
@@ -114,9 +114,6 @@ public interface Constants {
...
@@ -114,9 +114,6 @@ public interface Constants {
String
PREF_READ_EX
=
"pref_settings_read_ex"
;
String
PREF_READ_EX
=
"pref_settings_read_ex"
;
boolean
DEF_PREF_READ_EX
=
false
;
boolean
DEF_PREF_READ_EX
=
false
;
String
PREF_DECK_MANAGER_V2
=
"pref_settings_deck_manager_v2"
;
boolean
DEF_PREF_DECK_MANAGER_V2
=
false
;
String
PREF_KEEP_SCALE
=
"pref_settings_keep_scale"
;
String
PREF_KEEP_SCALE
=
"pref_settings_keep_scale"
;
boolean
DEF_PREF_KEEP_SCALE
=
false
;
boolean
DEF_PREF_KEEP_SCALE
=
false
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
0474dbee
...
@@ -215,9 +215,7 @@ public class GameUriManager {
...
@@ -215,9 +215,7 @@ public class GameUriManager {
boolean
isLua
=
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".lua"
);
boolean
isLua
=
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".lua"
);
Log
.
i
(
Constants
.
TAG
,
"open file:"
+
uri
+
"->"
+
file
.
getAbsolutePath
());
Log
.
i
(
Constants
.
TAG
,
"open file:"
+
uri
+
"->"
+
file
.
getAbsolutePath
());
if
(
isYdk
)
{
if
(
isYdk
)
{
Intent
intent
=
new
Intent
(
getActivity
(),
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
intent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
activity
.
startActivity
(
intent
);
}
else
if
(
isYpk
)
{
}
else
if
(
isYpk
)
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
activity
.
startActivity
(
startSeting
);
activity
.
startActivity
(
startSeting
);
...
@@ -253,9 +251,7 @@ public class GameUriManager {
...
@@ -253,9 +251,7 @@ public class GameUriManager {
}
else
{
}
else
{
Deck
deckInfo
=
new
Deck
(
uri
);
Deck
deckInfo
=
new
Deck
(
uri
);
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
Intent
startdeck
=
new
Intent
(
getActivity
(),
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
activity
.
startActivity
(
startdeck
);
}
}
}
}
// else if (PATH_ROOM.equals(path)) {
// else if (PATH_ROOM.equals(path)) {
...
@@ -283,9 +279,7 @@ public class GameUriManager {
...
@@ -283,9 +279,7 @@ public class GameUriManager {
}
}
}
}
if
(
deck
!=
null
&&
deck
.
exists
())
{
if
(
deck
!=
null
&&
deck
.
exists
())
{
Intent
startdeck
=
new
Intent
(
getActivity
(),
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
activity
,
deck
.
getAbsolutePath
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
deck
.
getAbsolutePath
());
activity
.
startActivity
(
startdeck
);
}
else
{
}
else
{
Log
.
w
(
"kk"
,
"no find "
+
name
);
Log
.
w
(
"kk"
,
"no find "
+
name
);
activity
.
finish
();
activity
.
finish
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsAc
i
tivity.java
→
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
View file @
0474dbee
package
cn.garymb.ygomobile.ui.cards
;
package
cn.garymb.ygomobile.ui.cards
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.graphics.DashPathEffect
;
import
android.graphics.DashPathEffect
;
import
android.graphics.Paint
;
import
android.graphics.Paint
;
...
@@ -12,6 +11,7 @@ import android.view.animation.Animation;
...
@@ -12,6 +11,7 @@ import android.view.animation.Animation;
import
android.view.animation.AnimationUtils
;
import
android.view.animation.AnimationUtils
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
androidx.drawerlayout.widget.DrawerLayout
;
...
@@ -19,9 +19,6 @@ import androidx.recyclerview.widget.FastScrollLinearLayoutManager;
...
@@ -19,9 +19,6 @@ import androidx.recyclerview.widget.FastScrollLinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.app.hubert.guide.NewbieGuide
;
import
com.app.hubert.guide.NewbieGuide
;
import
com.app.hubert.guide.core.Controller
;
import
com.app.hubert.guide.listener.OnHighlightDrewListener
;
import
com.app.hubert.guide.listener.OnLayoutInflatedListener
;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.app.hubert.guide.model.HighlightOptions
;
...
@@ -41,11 +38,11 @@ import ocgcore.LimitManager;
...
@@ -41,11 +38,11 @@ import ocgcore.LimitManager;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
public
abstract
class
BaseCardsAc
i
tivity
extends
BaseActivity
implements
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
public
abstract
class
BaseCardsActivity
extends
BaseActivity
implements
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
protected
DrawerLayout
mDrawer
l
ayout
;
protected
DrawerLayout
mDrawer
L
ayout
;
protected
RecyclerView
mListView
;
protected
RecyclerView
mListView
;
protected
CardSearcher
mCardSelector
;
protected
CardSearcher
mCardSelector
;
protected
CardListAdapter
mCardListAdap
a
ter
;
protected
CardListAdapter
mCardListAdapter
;
protected
CardLoader
mCardLoader
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
boolean
isLoad
=
false
;
private
ImageLoader
mImageLoader
;
private
ImageLoader
mImageLoader
;
...
@@ -59,13 +56,13 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -59,13 +56,13 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
setContentView
(
R
.
layout
.
activity_deck_cards
);
setContentView
(
R
.
layout
.
activity_deck_cards
);
AnimationShake2
();
AnimationShake2
();
mImageLoader
=
ImageLoader
.
get
(
this
);
mImageLoader
=
ImageLoader
.
get
(
this
);
mDrawer
l
ayout
=
$
(
R
.
id
.
drawer_layout
);
mDrawer
L
ayout
=
$
(
R
.
id
.
drawer_layout
);
screenWidth
=
getResources
().
getDisplayMetrics
().
widthPixels
;
screenWidth
=
getResources
().
getDisplayMetrics
().
widthPixels
;
mListView
=
$
(
R
.
id
.
list_cards
);
mListView
=
$
(
R
.
id
.
list_cards
);
mCardListAdap
a
ter
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdapter
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdap
a
ter
.
setEnableSwipe
(
true
);
mCardListAdapter
.
setEnableSwipe
(
true
);
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setAdapter
(
mCardListAdap
a
ter
);
mListView
.
setAdapter
(
mCardListAdapter
);
setListeners
();
setListeners
();
mCardLoader
=
new
CardLoader
(
this
);
mCardLoader
=
new
CardLoader
(
this
);
...
@@ -78,28 +75,22 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -78,28 +75,22 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
//https://www.jianshu.com/p/99649af3b191
//https://www.jianshu.com/p/99649af3b191
public
void
showNewbieGuide
(
String
scene
)
{
public
void
showNewbieGuide
(
String
scene
)
{
HighlightOptions
options
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线圈
HighlightOptions
options
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线圈
.
setOnHighlightDrewListener
(
new
OnHighlightDrewListener
()
{
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
@Override
Paint
paint
=
new
Paint
();
public
void
onHighlightDrew
(
Canvas
canvas
,
RectF
rectF
)
{
paint
.
setColor
(
Color
.
WHITE
);
Paint
paint
=
new
Paint
();
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
paint
.
setStrokeWidth
(
20
);
canvas
.
drawCircle
(
rectF
.
centerX
(),
rectF
.
centerY
(),
rectF
.
width
()
/
2
+
10
,
paint
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawCircle
(
rectF
.
centerX
(),
rectF
.
centerY
(),
rectF
.
width
()
/
2
+
10
,
paint
);
}
}).
build
();
}).
build
();
HighlightOptions
options2
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线矩形
HighlightOptions
options2
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线矩形
.
setOnHighlightDrewListener
(
new
OnHighlightDrewListener
()
{
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
@Override
Paint
paint
=
new
Paint
();
public
void
onHighlightDrew
(
Canvas
canvas
,
RectF
rectF
)
{
paint
.
setColor
(
Color
.
WHITE
);
Paint
paint
=
new
Paint
();
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
paint
.
setStrokeWidth
(
20
);
canvas
.
drawRect
(
rectF
,
paint
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawRect
(
rectF
,
paint
);
}
}).
build
();
}).
build
();
if
(
scene
.
equals
(
"deckmain"
))
{
if
(
scene
.
equals
(
"deckmain"
))
{
NewbieGuide
.
with
(
this
)
//with方法可以传入Activity或者Fragment,获取引导页的依附者
NewbieGuide
.
with
(
this
)
//with方法可以传入Activity或者Fragment,获取引导页的依附者
...
@@ -109,13 +100,9 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -109,13 +100,9 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
deck_menu
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
deck_menu
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
//可只创建一个引导layout并把相关内容都放在其中并GONE,获得ID并初始化相应为显示
@Override
view
.
findViewById
(
R
.
id
.
view_abt_bmb
).
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
//可只创建一个引导layout并把相关内容都放在其中并GONE,获得ID并初始化相应为显示
view
.
findViewById
(
R
.
id
.
view_abt_bmb
).
setVisibility
(
View
.
VISIBLE
);
}
})
})
)
)
...
@@ -124,14 +111,10 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -124,14 +111,10 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_search
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_search
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
@Override
tv
.
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
tv
.
setText
(
R
.
string
.
guide_button_search
);
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search
);
}
})
})
)
)
.
addGuidePage
(
.
addGuidePage
(
...
@@ -139,14 +122,10 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -139,14 +122,10 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_list
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_list
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
@Override
tv
.
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
tv
.
setText
(
R
.
string
.
guide_button_search_result
);
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search_result
);
}
})
})
)
)
.
addGuidePage
(
.
addGuidePage
(
...
@@ -154,30 +133,22 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -154,30 +133,22 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
tv_deckmanger
),
HighLight
.
Shape
.
CIRCLE
,
options2
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
tv_deckmanger
),
HighLight
.
Shape
.
CIRCLE
,
options2
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
@Override
tv
.
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
tv
.
setText
(
R
.
string
.
guide_view_deck_manager
);
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_view_deck_manager
);
}
})
})
)
)
.
addGuidePage
(
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
new
RectF
(
screenWidth
/
10
,
screenWidth
/
20
,
screenWidth
/
5
,
screenWidth
/
20
+
screenWidth
/
10
*
254
/
177
),
HighLight
.
Shape
.
RECTANGLE
,
options2
)
.
addHighLightWithOptions
(
new
RectF
(
screenWidth
/
10
.0f
,
screenWidth
/
20.0f
,
screenWidth
/
5.0f
,
screenWidth
/
20.0f
+
screenWidth
/
10.0f
*
254.0f
/
177.0f
),
HighLight
.
Shape
.
RECTANGLE
,
options2
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_abt_mid
);
@Override
tv
.
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
tv
.
setText
(
R
.
string
.
guide_view_move_card
);
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_abt_mid
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_view_move_card
);
}
})
})
)
)
//.alwaysShow(true)//总是显示,调试时可以打开
//.alwaysShow(true)//总是显示,调试时可以打开
...
@@ -186,20 +157,16 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -186,20 +157,16 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
}
}
}
}
protected
int
getDimen
(
int
id
)
{
return
(
int
)
getResources
().
getDimension
(
id
);
}
protected
void
setListeners
()
{
protected
void
setListeners
()
{
mListView
.
addOnItemTouchListener
(
new
RecyclerViewItemListener
(
mListView
,
new
RecyclerViewItemListener
.
OnItemListener
()
{
mListView
.
addOnItemTouchListener
(
new
RecyclerViewItemListener
(
mListView
,
new
RecyclerViewItemListener
.
OnItemListener
()
{
@Override
@Override
public
void
onItemClick
(
View
view
,
int
pos
)
{
public
void
onItemClick
(
View
view
,
int
pos
)
{
onCardClick
(
view
,
mCardListAdap
a
ter
.
getItem
(
pos
),
pos
);
onCardClick
(
view
,
mCardListAdapter
.
getItem
(
pos
),
pos
);
}
}
@Override
@Override
public
void
onItemLongClick
(
View
view
,
int
pos
)
{
public
void
onItemLongClick
(
View
view
,
int
pos
)
{
onCardLongClick
(
view
,
mCardListAdap
a
ter
.
getItem
(
pos
),
pos
);
onCardLongClick
(
view
,
mCardListAdapter
.
getItem
(
pos
),
pos
);
}
}
@Override
@Override
...
@@ -209,18 +176,16 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -209,18 +176,16 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
}));
}));
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
@Override
@Override
public
void
onScrollStateChanged
(
RecyclerView
recyclerView
,
int
newState
)
{
public
void
onScrollStateChanged
(
@NonNull
RecyclerView
recyclerView
,
int
newState
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
switch
(
newState
)
{
switch
(
newState
)
{
case
RecyclerView
.
SCROLL_STATE_IDLE
:
case
RecyclerView
.
SCROLL_STATE_IDLE
:
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
Glide
.
with
(
getContext
()).
resumeRequests
();
Glide
.
with
(
getContext
()).
resumeRequests
();
break
;
break
;
case
RecyclerView
.
SCROLL_STATE_DRAGGING
:
case
RecyclerView
.
SCROLL_STATE_DRAGGING
:
Glide
.
with
(
getContext
()).
pauseRequests
();
Glide
.
with
(
getContext
()).
pauseRequests
();
break
;
break
;
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
Glide
.
with
(
getContext
()).
resumeRequests
();
break
;
}
}
}
}
});
});
...
@@ -232,12 +197,12 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -232,12 +197,12 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
@Override
@Override
protected
void
onBackHome
()
{
protected
void
onBackHome
()
{
if
(
mDrawer
l
ayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
if
(
mDrawer
L
ayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawer
l
ayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
mDrawer
L
ayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
return
;
return
;
}
}
if
(
mDrawer
l
ayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
if
(
mDrawer
L
ayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawer
l
ayout
.
closeDrawer
(
Gravity
.
LEFT
);
mDrawer
L
ayout
.
closeDrawer
(
Gravity
.
LEFT
);
return
;
return
;
}
}
finish
();
finish
();
...
@@ -245,8 +210,8 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -245,8 +210,8 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
// Log.d("kk", "find " + (cardInfos == null ? -1 : cardInfos.size()));
// Log.d("kk", "find " + (cardInfos == null ? -1 : cardInfos.size()));
mCardListAdap
a
ter
.
set
(
cardInfos
);
mCardListAdapter
.
set
(
cardInfos
);
mCardListAdap
a
ter
.
notifyDataSetChanged
();
mCardListAdapter
.
notifyDataSetChanged
();
if
(
cardInfos
!=
null
&&
cardInfos
.
size
()
>
0
)
{
if
(
cardInfos
!=
null
&&
cardInfos
.
size
()
>
0
)
{
mListView
.
smoothScrollToPosition
(
0
);
mListView
.
smoothScrollToPosition
(
0
);
}
}
...
@@ -274,11 +239,11 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -274,11 +239,11 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
}
}
protected
void
hideDrawers
()
{
protected
void
hideDrawers
()
{
if
(
mDrawer
l
ayout
.
isDrawerOpen
(
Gravity
.
RIGHT
))
{
if
(
mDrawer
L
ayout
.
isDrawerOpen
(
Gravity
.
RIGHT
))
{
mDrawer
l
ayout
.
closeDrawer
(
Gravity
.
RIGHT
);
mDrawer
L
ayout
.
closeDrawer
(
Gravity
.
RIGHT
);
}
}
if
(
mDrawer
l
ayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
if
(
mDrawer
L
ayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawer
l
ayout
.
closeDrawer
(
Gravity
.
LEFT
);
mDrawer
L
ayout
.
closeDrawer
(
Gravity
.
LEFT
);
}
}
}
}
...
@@ -287,25 +252,25 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
...
@@ -287,25 +252,25 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
protected
abstract
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
);
protected
abstract
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
);
protected
void
showSearch
(
boolean
autoClose
)
{
protected
void
showSearch
(
boolean
autoClose
)
{
if
(
mDrawer
l
ayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
if
(
mDrawer
L
ayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawer
l
ayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
mDrawer
L
ayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
}
if
(
autoClose
&&
mDrawer
l
ayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
if
(
autoClose
&&
mDrawer
L
ayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawer
l
ayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
mDrawer
L
ayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
else
if
(
isLoad
)
{
}
else
if
(
isLoad
)
{
mDrawer
l
ayout
.
openDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
mDrawer
L
ayout
.
openDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
}
}
}
protected
void
showResult
(
boolean
autoClose
)
{
protected
void
showResult
(
boolean
autoClose
)
{
if
(
mDrawer
l
ayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
if
(
mDrawer
L
ayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawer
l
ayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
mDrawer
L
ayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
}
if
(
autoClose
&&
mDrawer
l
ayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
if
(
autoClose
&&
mDrawer
L
ayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawer
l
ayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
mDrawer
L
ayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
showNewbieGuide
(
"searchResult"
);
showNewbieGuide
(
"searchResult"
);
}
else
if
(
isLoad
)
{
}
else
if
(
isLoad
)
{
mDrawer
l
ayout
.
openDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
mDrawer
L
ayout
.
openDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
}
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
View file @
0474dbee
...
@@ -48,7 +48,7 @@ import ocgcore.data.Card;
...
@@ -48,7 +48,7 @@ import ocgcore.data.Card;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.CardType
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
cards
.
DeckManagerActivity
Impl
.
Favorite
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
cards
.
DeckManagerActivity
.
Favorite
;
/***
/***
* 卡片详情
* 卡片详情
...
@@ -224,7 +224,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
...
@@ -224,7 +224,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
favConf
.
save
(
"#Favorite"
);
favConf
.
save
(
"#Favorite"
);
favConf
.
read
();
favConf
.
read
();
Favorite
.
clear
();
Favorite
.
clear
();
if
(!
DeckManagerActivity
Impl
.
isSearchResult
)
{
if
(!
DeckManagerActivity
.
isSearchResult
)
{
SparseArray
<
Card
>
id
=
mCardLoader
.
readCards
(
ConfigManager
.
mLines
,
false
);
SparseArray
<
Card
>
id
=
mCardLoader
.
readCards
(
ConfigManager
.
mLines
,
false
);
if
(
id
!=
null
)
{
if
(
id
!=
null
)
{
for
(
int
i
=
0
;
i
<
id
.
size
();
i
++)
for
(
int
i
=
0
;
i
<
id
.
size
();
i
++)
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchAcitivity.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards
;
public
class
CardSearchAcitivity
extends
CardSearchActivityImpl
{
public
static
final
String
SEARCH_MESSAGE
=
"searchMessage"
;
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivity
Impl
.java
→
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchActivity.java
View file @
0474dbee
package
cn.garymb.ygomobile.ui.cards
;
package
cn.garymb.ygomobile.ui.cards
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.graphics.DashPathEffect
;
import
android.graphics.DashPathEffect
;
import
android.graphics.Paint
;
import
android.graphics.Paint
;
import
android.graphics.RectF
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.Gravity
;
...
@@ -15,6 +13,7 @@ import android.view.View;
...
@@ -15,6 +13,7 @@ import android.view.View;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
androidx.drawerlayout.widget.DrawerLayout
;
...
@@ -22,9 +21,6 @@ import androidx.recyclerview.widget.FastScrollLinearLayoutManager;
...
@@ -22,9 +21,6 @@ import androidx.recyclerview.widget.FastScrollLinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.app.hubert.guide.NewbieGuide
;
import
com.app.hubert.guide.NewbieGuide
;
import
com.app.hubert.guide.core.Controller
;
import
com.app.hubert.guide.listener.OnHighlightDrewListener
;
import
com.app.hubert.guide.listener.OnLayoutInflatedListener
;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.app.hubert.guide.model.HighlightOptions
;
...
@@ -50,8 +46,8 @@ import ocgcore.StringManager;
...
@@ -50,8 +46,8 @@ import ocgcore.StringManager;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
class
CardSearchActivityImpl
extends
BaseActivity
implements
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
public
class
CardSearchActivity
extends
BaseActivity
implements
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
public
static
final
String
SEARCH_MESSAGE
=
"searchMessage"
;
protected
DrawerLayout
mDrawerlayout
;
protected
DrawerLayout
mDrawerlayout
;
protected
CardSearcher
mCardSelector
;
protected
CardSearcher
mCardSelector
;
protected
CardListAdapter
mCardListAdapater
;
protected
CardListAdapter
mCardListAdapater
;
...
@@ -68,7 +64,6 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -68,7 +64,6 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
private
DuelAssistantManagement
duelAssistantManagement
;
private
DuelAssistantManagement
duelAssistantManagement
;
private
CardDetail
mCardDetail
;
private
CardDetail
mCardDetail
;
private
DialogPlus
mDialog
;
private
DialogPlus
mDialog
;
private
Button
btn_search
;
private
TextView
mResult_count
;
private
TextView
mResult_count
;
@Override
@Override
...
@@ -77,7 +72,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -77,7 +72,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
setContentView
(
R
.
layout
.
activity_search
);
setContentView
(
R
.
layout
.
activity_search
);
mResult_count
=
findViewById
(
R
.
id
.
search_result_count
);
mResult_count
=
findViewById
(
R
.
id
.
search_result_count
);
duelAssistantManagement
=
DuelAssistantManagement
.
getInstance
();
duelAssistantManagement
=
DuelAssistantManagement
.
getInstance
();
intentSearchMessage
=
getIntent
().
getStringExtra
(
CardSearchAc
i
tivity
.
SEARCH_MESSAGE
);
intentSearchMessage
=
getIntent
().
getStringExtra
(
CardSearchActivity
.
SEARCH_MESSAGE
);
// Toolbar toolbar = $(R.id.toolbar);
// Toolbar toolbar = $(R.id.toolbar);
// setSupportActionBar(toolbar);
// setSupportActionBar(toolbar);
enableBackHome
();
enableBackHome
();
...
@@ -88,10 +83,8 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -88,10 +83,8 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
mCardListAdapater
.
setItemBg
(
true
);
mCardListAdapater
.
setItemBg
(
true
);
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setAdapter
(
mCardListAdapater
);
mListView
.
setAdapter
(
mCardListAdapater
);
btn_search
=
$
(
R
.
id
.
btn_search
);
Button
btn_search
=
$
(
R
.
id
.
btn_search
);
btn_search
.
setOnClickListener
((
v
)
->
{
btn_search
.
setOnClickListener
((
v
)
->
showSearch
(
true
));
showSearch
(
true
);
});
/*
/*
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, mDrawerlayout, toolbar, R.string.search_open, R.string.search_close);
this, mDrawerlayout, toolbar, R.string.search_open, R.string.search_close);
...
@@ -166,7 +159,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -166,7 +159,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
}));
}));
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
@Override
@Override
public
void
onScrollStateChanged
(
RecyclerView
recyclerView
,
int
newState
)
{
public
void
onScrollStateChanged
(
@NonNull
RecyclerView
recyclerView
,
int
newState
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
switch
(
newState
)
{
switch
(
newState
)
{
case
RecyclerView
.
SCROLL_STATE_IDLE
:
case
RecyclerView
.
SCROLL_STATE_IDLE
:
...
@@ -187,17 +180,16 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -187,17 +180,16 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
});
});
}
}
private
boolean
onBack
()
{
private
void
onBack
()
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerlayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
mDrawerlayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
return
true
;
return
;
}
}
if
(
mDrawerlayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerlayout
.
closeDrawer
(
Gravity
.
LEFT
);
mDrawerlayout
.
closeDrawer
(
Gravity
.
LEFT
);
return
true
;
return
;
}
}
finish
();
finish
();
return
true
;
}
}
@Override
@Override
...
@@ -217,7 +209,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -217,7 +209,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
mCardListAdapater
.
set
(
cardInfos
);
mCardListAdapater
.
set
(
cardInfos
);
mResult_count
.
setText
(
String
.
valueOf
(
cardInfos
.
size
()));
mResult_count
.
setText
(
String
.
valueOf
(
cardInfos
.
size
()));
mCardListAdapater
.
notifyDataSetChanged
();
mCardListAdapater
.
notifyDataSetChanged
();
if
(
cardInfos
!=
null
&&
cardInfos
.
size
()
>
0
)
{
if
(
cardInfos
.
size
()
>
0
)
{
mListView
.
smoothScrollToPosition
(
0
);
mListView
.
smoothScrollToPosition
(
0
);
}
}
}
}
...
@@ -255,11 +247,8 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -255,11 +247,8 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
@Override
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
if
(
item
.
getItemId
()
==
R
.
id
.
action_search
)
{
//弹条件对话框
case
R
.
id
.
action_search
:
showSearch
(
true
);
//弹条件对话框
showSearch
(
true
);
break
;
}
}
return
super
.
onOptionsItemSelected
(
item
);
return
super
.
onOptionsItemSelected
(
item
);
}
}
...
@@ -320,7 +309,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -320,7 +309,7 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
@Override
@Override
public
void
onSearchResult
(
List
<
Card
>
Cards
,
boolean
isHide
)
{
public
void
onSearchResult
(
List
<
Card
>
Cards
,
boolean
isHide
)
{
CardSearchActivity
Impl
.
this
.
onSearchResult
(
Cards
,
isHide
);
CardSearchActivity
.
this
.
onSearchResult
(
Cards
,
isHide
);
}
}
});
});
}
}
...
@@ -361,16 +350,13 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -361,16 +350,13 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
//https://www.jianshu.com/p/99649af3b191
//https://www.jianshu.com/p/99649af3b191
public
void
showNewbieGuide
()
{
public
void
showNewbieGuide
()
{
HighlightOptions
options
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线圈
HighlightOptions
options
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线圈
.
setOnHighlightDrewListener
(
new
OnHighlightDrewListener
()
{
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
@Override
Paint
paint
=
new
Paint
();
public
void
onHighlightDrew
(
Canvas
canvas
,
RectF
rectF
)
{
paint
.
setColor
(
Color
.
WHITE
);
Paint
paint
=
new
Paint
();
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
paint
.
setStrokeWidth
(
20
);
canvas
.
drawCircle
(
rectF
.
centerX
(),
rectF
.
centerY
(),
rectF
.
width
()
/
2
+
10
,
paint
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawCircle
(
rectF
.
centerX
(),
rectF
.
centerY
(),
rectF
.
width
()
/
2
+
10
,
paint
);
}
}).
build
();
}).
build
();
NewbieGuide
.
with
(
this
)
//with方法可以传入Activity或者Fragment,获取引导页的依附者
NewbieGuide
.
with
(
this
)
//with方法可以传入Activity或者Fragment,获取引导页的依附者
.
setLabel
(
"searchCardGuide"
)
.
setLabel
(
"searchCardGuide"
)
...
@@ -379,14 +365,10 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -379,14 +365,10 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
btn_search
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
btn_search
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
@Override
tv
.
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
tv
.
setText
(
R
.
string
.
guide_button_search
);
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search
);
}
})
})
)
)
...
@@ -395,14 +377,10 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
...
@@ -395,14 +377,10 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
.
setBackgroundColor
(
0xbc000000
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
search_result_count
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
search_result_count
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
(
new
OnLayoutInflatedListener
()
{
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
@Override
tv
.
setVisibility
(
View
.
VISIBLE
);
public
void
onLayoutInflated
(
View
view
,
Controller
controller
)
{
tv
.
setText
(
R
.
string
.
guide_search_result_count
);
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_search_result_count
);
}
})
})
)
)
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearcher.java
View file @
0474dbee
...
@@ -5,19 +5,17 @@ import android.content.Context;
...
@@ -5,19 +5,17 @@ import android.content.Context;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.SparseArray
;
import
android.util.SparseArray
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.inputmethod.EditorInfo
;
import
android.view.inputmethod.EditorInfo
;
import
android.view.inputmethod.InputMethodManager
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.Spinner
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView.OnEditorActionListener
;
import
android.widget.TextView.OnEditorActionListener
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
...
@@ -41,7 +39,7 @@ import ocgcore.enums.CardRace;
...
@@ -41,7 +39,7 @@ import ocgcore.enums.CardRace;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.LimitType
;
import
ocgcore.enums.LimitType
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
cards
.
DeckManagerActivity
Impl
.
Favorite
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
cards
.
DeckManagerActivity
.
Favorite
;
public
class
CardSearcher
implements
View
.
OnClickListener
{
public
class
CardSearcher
implements
View
.
OnClickListener
{
...
@@ -50,32 +48,31 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -50,32 +48,31 @@ public class CardSearcher implements View.OnClickListener {
protected
LimitManager
mLimitManager
;
protected
LimitManager
mLimitManager
;
protected
AppsSettings
mSettings
;
protected
AppsSettings
mSettings
;
int
lineKey
;
int
lineKey
;
private
EditText
prefixWord
;
private
final
EditText
prefixWord
;
private
EditText
suffixWord
;
private
final
EditText
suffixWord
;
private
Spinner
otSpinner
;
private
final
Spinner
otSpinner
;
private
Spinner
limitSpinner
;
private
final
Spinner
limitSpinner
;
private
Spinner
limitListSpinner
;
private
final
Spinner
limitListSpinner
;
private
Spinner
typeSpinner
;
private
final
Spinner
typeSpinner
;
private
Spinner
typeMonsterSpinner
;
private
final
Spinner
typeMonsterSpinner
;
private
Spinner
typeMonsterSpinner2
;
private
final
Spinner
typeMonsterSpinner2
;
private
Spinner
typeSpellSpinner
;
private
final
Spinner
typeSpellSpinner
;
private
Spinner
typeTrapSpinner
;
private
final
Spinner
typeTrapSpinner
;
private
Spinner
setcodeSpinner
;
private
final
Spinner
setCodeSpinner
;
private
Spinner
categorySpinner
;
private
final
Spinner
categorySpinner
;
private
Spinner
raceSpinner
;
private
final
Spinner
raceSpinner
;
private
Spinner
levelSpinner
;
private
final
Spinner
levelSpinner
;
private
Spinner
attributeSpinner
;
private
final
Spinner
attributeSpinner
;
private
EditText
atkText
;
private
final
EditText
atkText
;
private
EditText
defText
;
private
final
EditText
defText
;
private
Spinner
pScale
;
private
final
Spinner
pScale
;
private
Button
MyFavButton
;
private
final
Button
LinkMarkerButton
;
private
Button
LinkMarkerButton
;
private
final
Button
searchButton
;
private
Button
searchButton
;
private
final
Button
resetButton
;
private
Button
resetButton
;
private
final
View
view
;
private
View
view
;
private
final
View
layout_monster
;
private
View
layout_monster
;
private
final
ICardLoader
dataLoader
;
private
ICardLoader
dataLoader
;
private
final
Context
mContext
;
private
Context
mContext
;
private
CallBack
mCallBack
;
private
CallBack
mCallBack
;
CardLoader
mCardLoader
;
CardLoader
mCardLoader
;
...
@@ -106,7 +103,7 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -106,7 +103,7 @@ public class CardSearcher implements View.OnClickListener {
typeMonsterSpinner2
=
findViewById
(
R
.
id
.
sp_type_monster2
);
typeMonsterSpinner2
=
findViewById
(
R
.
id
.
sp_type_monster2
);
typeSpellSpinner
=
findViewById
(
R
.
id
.
sp_type_spell
);
typeSpellSpinner
=
findViewById
(
R
.
id
.
sp_type_spell
);
typeTrapSpinner
=
findViewById
(
R
.
id
.
sp_type_trap
);
typeTrapSpinner
=
findViewById
(
R
.
id
.
sp_type_trap
);
set
c
odeSpinner
=
findViewById
(
R
.
id
.
sp_setcode
);
set
C
odeSpinner
=
findViewById
(
R
.
id
.
sp_setcode
);
categorySpinner
=
findViewById
(
R
.
id
.
sp_category
);
categorySpinner
=
findViewById
(
R
.
id
.
sp_category
);
raceSpinner
=
findViewById
(
R
.
id
.
sp_race
);
raceSpinner
=
findViewById
(
R
.
id
.
sp_race
);
levelSpinner
=
findViewById
(
R
.
id
.
sp_level
);
levelSpinner
=
findViewById
(
R
.
id
.
sp_level
);
...
@@ -114,117 +111,105 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -114,117 +111,105 @@ public class CardSearcher implements View.OnClickListener {
atkText
=
findViewById
(
R
.
id
.
edt_atk
);
atkText
=
findViewById
(
R
.
id
.
edt_atk
);
defText
=
findViewById
(
R
.
id
.
edt_def
);
defText
=
findViewById
(
R
.
id
.
edt_def
);
LinkMarkerButton
=
findViewById
(
R
.
id
.
btn_linkmarker
);
LinkMarkerButton
=
findViewById
(
R
.
id
.
btn_linkmarker
);
M
yFavButton
=
findViewById
(
R
.
id
.
btn_my_fav
);
Button
m
yFavButton
=
findViewById
(
R
.
id
.
btn_my_fav
);
searchButton
=
findViewById
(
R
.
id
.
btn_search
);
searchButton
=
findViewById
(
R
.
id
.
btn_search
);
resetButton
=
findViewById
(
R
.
id
.
btn_reset
);
resetButton
=
findViewById
(
R
.
id
.
btn_reset
);
layout_monster
=
findViewById
(
R
.
id
.
layout_monster
);
layout_monster
=
findViewById
(
R
.
id
.
layout_monster
);
pScale
=
findViewById
(
R
.
id
.
sp_scale
);
pScale
=
findViewById
(
R
.
id
.
sp_scale
);
M
yFavButton
.
setOnClickListener
(
this
);
m
yFavButton
.
setOnClickListener
(
this
);
LinkMarkerButton
.
setOnClickListener
(
this
);
LinkMarkerButton
.
setOnClickListener
(
this
);
searchButton
.
setOnClickListener
(
this
);
searchButton
.
setOnClickListener
(
this
);
resetButton
.
setOnClickListener
(
this
);
resetButton
.
setOnClickListener
(
this
);
mCardLoader
=
new
CardLoader
(
mContext
);
mCardLoader
=
new
CardLoader
(
mContext
);
OnEditorActionListener
searchListener
=
new
OnEditorActionListener
()
{
OnEditorActionListener
searchListener
=
(
v
,
actionId
,
event
)
->
{
@Override
if
(
actionId
==
EditorInfo
.
IME_ACTION_SEARCH
)
{
public
boolean
onEditorAction
(
TextView
v
,
int
actionId
,
KeyEvent
event
)
{
InputMethodManager
imm
=
(
InputMethodManager
)
mContext
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
if
(
actionId
==
EditorInfo
.
IME_ACTION_SEARCH
)
{
imm
.
hideSoftInputFromWindow
(
view
.
getWindowToken
(),
0
);
InputMethodManager
imm
=
(
InputMethodManager
)
mContext
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
search
();
imm
.
hideSoftInputFromWindow
(
view
.
getWindowToken
(),
0
);
return
true
;
search
();
return
true
;
}
return
false
;
}
}
return
false
;
};
};
prefixWord
.
setOnEditorActionListener
(
searchListener
);
prefixWord
.
setOnEditorActionListener
(
searchListener
);
suffixWord
.
setOnEditorActionListener
(
searchListener
);
suffixWord
.
setOnEditorActionListener
(
searchListener
);
MyFavButton
.
setOnClickListener
(
new
OnClickListener
()
{
myFavButton
.
setOnClickListener
(
v
->
{
@Override
SparseArray
<
Card
>
id
=
mCardLoader
.
readCards
(
ConfigManager
.
mLines
,
false
);
public
void
onClick
(
View
v
)
{
Favorite
.
clear
();
SparseArray
<
Card
>
id
=
mCardLoader
.
readCards
(
ConfigManager
.
mLines
,
false
);
if
(
id
!=
null
)
{
Favorite
.
clear
();
for
(
int
i
=
0
;
i
<
id
.
size
();
i
++)
if
(
id
!=
null
)
{
Favorite
.
add
(
id
.
valueAt
(
i
));
for
(
int
i
=
0
;
i
<
id
.
size
();
i
++)
}
Favorite
.
add
(
id
.
valueAt
(
i
));
if
(
mCallBack
!=
null
)
{
}
mCallBack
.
onSearchStart
();
if
(
mCallBack
!=
null
)
{
mCallBack
.
onSearchResult
(
Favorite
,
false
);
mCallBack
.
onSearchStart
();
mCallBack
.
onSearchResult
(
Favorite
,
false
);
}
DeckManagerActivityImpl
.
isSearchResult
=
false
;
}
}
DeckManagerActivity
.
isSearchResult
=
false
;
});
});
LinkMarkerButton
.
setOnClickListener
(
new
OnClickListener
()
{
LinkMarkerButton
.
setOnClickListener
(
v
->
{
@Override
Arrays
.
fill
(
BtnVals
,
"0"
);
public
void
onClick
(
View
v
)
{
DialogPlus
viewDialog
=
new
DialogPlus
(
mContext
);
for
(
int
i
=
0
;
i
<
BtnVals
.
length
;
i
++)
{
viewDialog
.
setContentView
(
R
.
layout
.
item_linkmarker
);
BtnVals
[
i
]
=
"0"
;
viewDialog
.
setTitle
(
R
.
string
.
ClickLinkArrows
)
;
}
viewDialog
.
show
();
DialogPlus
viewDialog
=
new
DialogPlus
(
mContext
);
int
[]
ids
=
new
int
[]{
viewDialog
.
setContentView
(
R
.
layout
.
item_linkmarker
);
R
.
id
.
button_1
,
viewDialog
.
setTitle
(
R
.
string
.
ClickLinkArrows
);
R
.
id
.
button_2
,
viewDialog
.
show
();
R
.
id
.
button_3
,
int
[]
ids
=
new
int
[]{
R
.
id
.
button_4
,
R
.
id
.
button_1
,
R
.
id
.
button_5
,
R
.
id
.
button_2
,
R
.
id
.
button_6
,
R
.
id
.
button_3
,
R
.
id
.
button_7
,
R
.
id
.
button_4
,
R
.
id
.
button_8
,
R
.
id
.
button_5
,
R
.
id
.
button_9
,
R
.
id
.
button_6
,
};
R
.
id
.
button_7
,
int
[]
enImgs
=
new
int
[]{
R
.
id
.
button_8
,
R
.
drawable
.
left_bottom_1
,
R
.
id
.
button_9
,
R
.
drawable
.
bottom_1
,
};
R
.
drawable
.
right_bottom_1
,
int
[]
enImgs
=
new
int
[]{
R
.
drawable
.
left_1
,
R
.
drawable
.
left_bottom_1
,
0
,
R
.
drawable
.
bottom
_1
,
R
.
drawable
.
right
_1
,
R
.
drawable
.
right_bottom
_1
,
R
.
drawable
.
left_top
_1
,
R
.
drawable
.
left
_1
,
R
.
drawable
.
top
_1
,
0
,
R
.
drawable
.
right_top_1
,
R
.
drawable
.
right_1
,
};
R
.
drawable
.
left_top_1
,
int
[]
disImgs
=
new
int
[]{
R
.
drawable
.
top_1
,
R
.
drawable
.
left_bottom_0
,
R
.
drawable
.
right_top_1
,
R
.
drawable
.
bottom_0
,
};
R
.
drawable
.
right_bottom_0
,
int
[]
disImgs
=
new
int
[]{
R
.
drawable
.
left_0
,
R
.
drawable
.
left_bottom_
0
,
0
,
R
.
drawable
.
bottom
_0
,
R
.
drawable
.
right
_0
,
R
.
drawable
.
right_bottom
_0
,
R
.
drawable
.
left_top
_0
,
R
.
drawable
.
left
_0
,
R
.
drawable
.
top
_0
,
0
,
R
.
drawable
.
right_top_
0
,
R
.
drawable
.
right_0
,
};
R
.
drawable
.
left_top_0
,
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
R
.
drawable
.
top_0
,
final
int
index
=
i
;
R
.
drawable
.
right_top_0
,
viewDialog
.
findViewById
(
ids
[
index
]).
setOnClickListener
((
btn
)
->
{
};
if
(
index
==
4
)
{
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
String
mLinkStr
=
BtnVals
[
8
]
+
BtnVals
[
7
]
+
BtnVals
[
6
]
+
BtnVals
[
5
]
+
"0"
final
int
index
=
i
;
+
BtnVals
[
3
]
+
BtnVals
[
2
]
+
BtnVals
[
1
]
+
BtnVals
[
0
]
;
viewDialog
.
findViewById
(
ids
[
index
]).
setOnClickListener
((
btn
)
->
{
lineKey
=
Integer
.
parseInt
(
mLinkStr
,
2
);
if
(
index
==
4
)
{
if
(
viewDialog
.
isShowing
()
)
{
String
mLinkStr
=
BtnVals
[
8
]
+
BtnVals
[
7
]
+
BtnVals
[
6
]
+
BtnVals
[
5
]
+
"0"
viewDialog
.
dismiss
();
+
BtnVals
[
3
]
+
BtnVals
[
2
]
+
BtnVals
[
1
]
+
BtnVals
[
0
];
}
lineKey
=
Integer
.
parseInt
(
mLinkStr
,
2
);
}
else
{
if
(
viewDialog
.
isShowing
(
))
{
if
(
"0"
.
equals
(
BtnVals
[
index
]
))
{
viewDialog
.
dismiss
(
);
btn
.
setBackgroundResource
(
enImgs
[
index
]
);
}
BtnVals
[
index
]
=
"1"
;
}
else
{
}
else
{
if
(
"0"
.
equals
(
BtnVals
[
index
]))
{
btn
.
setBackgroundResource
(
disImgs
[
index
]);
btn
.
setBackgroundResource
(
enImgs
[
index
]);
BtnVals
[
index
]
=
"0"
;
BtnVals
[
index
]
=
"1"
;
}
else
{
btn
.
setBackgroundResource
(
disImgs
[
index
]);
BtnVals
[
index
]
=
"0"
;
}
}
}
}
);
}
}
}
);
}
}
});
});
...
@@ -317,7 +302,7 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -317,7 +302,7 @@ public class CardSearcher implements View.OnClickListener {
initPscaleSpinners
(
pScale
);
initPscaleSpinners
(
pScale
);
initAttributes
(
attributeSpinner
);
initAttributes
(
attributeSpinner
);
initRaceSpinners
(
raceSpinner
);
initRaceSpinners
(
raceSpinner
);
initSetNameSpinners
(
set
c
odeSpinner
);
initSetNameSpinners
(
set
C
odeSpinner
);
initCategorySpinners
(
categorySpinner
);
initCategorySpinners
(
categorySpinner
);
}
}
...
@@ -564,12 +549,12 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -564,12 +549,12 @@ public class CardSearcher implements View.OnClickListener {
,
getSelect
(
levelSpinner
),
getSelect
(
raceSpinner
),
getSelectText
(
limitListSpinner
),
getSelect
(
limitSpinner
),
,
getSelect
(
levelSpinner
),
getSelect
(
raceSpinner
),
getSelectText
(
limitListSpinner
),
getSelect
(
limitSpinner
),
text
(
atkText
),
text
(
defText
),
text
(
atkText
),
text
(
defText
),
getSelect
(
pScale
),
getSelect
(
pScale
),
getSelect
(
set
c
odeSpinner
)
getSelect
(
set
C
odeSpinner
)
,
getSelect
(
categorySpinner
),
getSelect
(
otSpinner
),
lineKey
,
getSelect
(
typeSpinner
),
getSelect
(
typeMonsterSpinner
),
getSelect
(
typeSpellSpinner
),
getSelect
(
typeTrapSpinner
)
,
getSelect
(
categorySpinner
),
getSelect
(
otSpinner
),
lineKey
,
getSelect
(
typeSpinner
),
getSelect
(
typeMonsterSpinner
),
getSelect
(
typeSpellSpinner
),
getSelect
(
typeTrapSpinner
)
,
getSelect
(
typeMonsterSpinner2
));
,
getSelect
(
typeMonsterSpinner2
));
lineKey
=
0
;
lineKey
=
0
;
}
}
DeckManagerActivity
Impl
.
isSearchResult
=
true
;
DeckManagerActivity
.
isSearchResult
=
true
;
}
}
private
void
resetAll
()
{
private
void
resetAll
()
{
...
@@ -588,7 +573,7 @@ public class CardSearcher implements View.OnClickListener {
...
@@ -588,7 +573,7 @@ public class CardSearcher implements View.OnClickListener {
reset
(
typeSpinner
);
reset
(
typeSpinner
);
reset
(
typeSpellSpinner
);
reset
(
typeSpellSpinner
);
reset
(
typeTrapSpinner
);
reset
(
typeTrapSpinner
);
reset
(
set
c
odeSpinner
);
reset
(
set
C
odeSpinner
);
reset
(
categorySpinner
);
reset
(
categorySpinner
);
resetMonster
();
resetMonster
();
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
View file @
0474dbee
package
cn.garymb.ygomobile.ui.cards
;
package
cn.garymb.ygomobile.ui.cards
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.SparseArray
;
import
android.view.Gravity
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.AppCompatSpinner
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.recyclerview.widget.ItemTouchHelperPlus
;
import
androidx.recyclerview.widget.OnItemDragListener
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
com.nightonke.boommenu.BoomButtons.BoomButton
;
import
com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton
;
import
com.nightonke.boommenu.BoomMenuButton
;
import
com.ourygo.assistant.service.DuelAssistantService
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.Deck
;
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.DeckFile
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckAdapater
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItem
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemTouchHelper
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemType
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckLayoutManager
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.BitmapUtil
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.ConfigManager
;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.LimitType
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
@SuppressWarnings
({
"unused"
,
"deprecated"
})
public
class
DeckManagerActivity
extends
BaseCardsActivity
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
,
YGODialogUtil
.
OnDeckMenuListener
{
public
static
void
start
(
Context
context
,
String
path
)
{
Intent
starter
=
new
Intent
(
context
,
DeckManagerActivity
.
class
);
starter
.
putExtra
(
Intent
.
EXTRA_TEXT
,
path
);
if
(!(
context
instanceof
Activity
))
{
starter
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
}
context
.
startActivity
(
starter
);
}
//region ui onCreate/onDestroy
private
RecyclerView
mRecyclerView
;
private
DeckAdapater
mDeckAdapater
;
private
final
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
File
mPreLoadFile
;
private
DeckItemTouchHelper
mDeckItemTouchHelper
;
private
AppCompatSpinner
mDeckSpinner
;
private
TextView
tv_deck
;
private
TextView
tv_result_count
;
private
AppCompatSpinner
mLimitSpinner
;
private
CardDetail
mCardDetail
;
private
DialogPlus
mDialog
;
private
DialogPlus
builderShareLoading
;
private
boolean
isExit
=
false
;
public
static
boolean
isSearchResult
;
public
static
List
<
Card
>
Favorite
=
new
ArrayList
<>();
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
tv_deck
=
$
(
R
.
id
.
tv_deck
);
tv_result_count
=
$
(
R
.
id
.
result_count
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
mDeckSpinner
.
setPopupBackgroundResource
(
R
.
color
.
colorNavy
);
mLimitSpinner
=
$
(
R
.
id
.
sp_limit_list
);
mLimitSpinner
.
setPopupBackgroundResource
(
R
.
color
.
colorNavy
);
mRecyclerView
=
$
(
R
.
id
.
grid_cards
);
mRecyclerView
.
setPadding
(
mRecyclerView
.
getPaddingLeft
(),
0
,
mRecyclerView
.
getPaddingRight
(),
mRecyclerView
.
getPaddingBottom
());
mRecyclerView
.
setAdapter
((
mDeckAdapater
=
new
DeckAdapater
(
this
,
mRecyclerView
,
getImageLoader
())));
mRecyclerView
.
setLayoutManager
(
new
DeckLayoutManager
(
this
,
Constants
.
DECK_WIDTH_COUNT
));
mDeckItemTouchHelper
=
new
DeckItemTouchHelper
(
mDeckAdapater
);
ItemTouchHelperPlus
touchHelper
=
new
ItemTouchHelperPlus
(
this
,
mDeckItemTouchHelper
);
touchHelper
.
setItemDragListener
(
this
);
touchHelper
.
setEnableClickDrag
(
Constants
.
DECK_SINGLE_PRESS_DRAG
);
touchHelper
.
attachToRecyclerView
(
mRecyclerView
);
mRecyclerView
.
addOnItemTouchListener
(
new
RecyclerViewItemListener
(
mRecyclerView
,
this
));
mDeckSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
adapterView
,
View
view
,
int
i
,
long
l
)
{
File
file
=
getSelectDeck
(
mDeckSpinner
);
if
(
file
!=
null
)
{
loadDeckFromFile
(
file
);
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
adapterView
)
{
}
});
String
preLoadFile
=
getIntent
().
getStringExtra
(
Intent
.
EXTRA_TEXT
);
initBoomMenuButton
(
$
(
R
.
id
.
bmb
));
$
(
R
.
id
.
btn_nav_search
).
setOnClickListener
((
v
)
->
doMenu
(
R
.
id
.
action_search
));
$
(
R
.
id
.
btn_nav_list
).
setOnClickListener
((
v
)
->
doMenu
(
R
.
id
.
action_card_list
));
//
final
File
_file
;
//打开指定卡组
if
(!
TextUtils
.
isEmpty
(
preLoadFile
)
&&
(
mPreLoadFile
=
new
File
(
preLoadFile
)).
exists
())
{
//外面卡组
_file
=
mPreLoadFile
;
}
else
{
mPreLoadFile
=
null
;
//最后卡组
_file
=
new
File
(
mSettings
.
getLastDeckPath
());
}
Favorite
.
clear
();
init
(
_file
);
EventBus
.
getDefault
().
register
(
this
);
tv_deck
.
setOnClickListener
(
v
->
YGODialogUtil
.
dialogDeckSelect
(
getActivity
(),
AppsSettings
.
get
().
getLastDeckPath
(),
this
));
}
//endregion
@Override
protected
void
onDestroy
()
{
EventBus
.
getDefault
().
unregister
(
this
);
super
.
onDestroy
();
}
//region card edit
@Override
public
void
onLimitListChanged
(
LimitList
limitList
)
{
}
@Override
public
void
onDragStart
()
{
}
@Override
public
void
onDragLongPress
(
int
pos
)
{
if
(
pos
<
0
)
return
;
if
(
Constants
.
DEBUG
)
Log
.
d
(
"kk"
,
"delete "
+
pos
);
if
(
mSettings
.
isDialogDelete
())
{
DeckItem
deckItem
=
mDeckAdapater
.
getItem
(
pos
);
if
(
deckItem
==
null
||
deckItem
.
getCardInfo
()
==
null
)
{
return
;
}
DialogPlus
dialogPlus
=
new
DialogPlus
(
this
);
dialogPlus
.
setTitle
(
R
.
string
.
question
);
dialogPlus
.
setMessage
(
getString
(
R
.
string
.
delete_card
,
deckItem
.
getCardInfo
().
Name
));
dialogPlus
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
dialogPlus
.
setLeftButtonListener
((
dlg
,
v
)
->
{
dlg
.
dismiss
();
mDeckItemTouchHelper
.
remove
(
pos
);
});
dialogPlus
.
show
();
}
else
{
mDeckAdapater
.
showHeadView
();
}
}
@Override
public
void
onDragLongPressEnd
()
{
mDeckAdapater
.
hideHeadView
();
}
//endregion
@Override
public
void
onDragEnd
()
{
}
//endregion
//region load deck
private
void
loadDeckFromFile
(
File
file
)
{
if
(!
mCardLoader
.
isOpen
()
||
file
==
null
||
!
file
.
exists
())
{
setCurDeck
(
new
DeckInfo
());
return
;
}
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
mDeckAdapater
.
read
(
mCardLoader
,
file
,
mCardLoader
.
getLimitList
());
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
setCurDeck
(
rs
);
});
}
//endregion
//region init
private
void
init
(
File
ydk
)
{
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
DataManager
.
get
().
load
(
false
);
//默认第一个卡表
if
(
mLimitManager
.
getCount
()
>
0
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
}
File
file
=
ydk
;
if
(!
file
.
exists
())
{
//当默认卡组不存在的时候
List
<
File
>
files
=
getYdkFiles
();
if
(
files
!=
null
&&
files
.
size
()
>
0
)
{
file
=
files
.
get
(
0
);
}
}
//EXTRA_DECK
if
(
file
==
null
)
{
return
new
DeckInfo
();
}
Log
.
i
(
"kk"
,
"load ydk "
+
file
);
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
mDeckAdapater
.
read
(
mCardLoader
,
file
,
mCardLoader
.
getLimitList
());
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
isLoad
=
true
;
dlg
.
dismiss
();
mCardSelector
.
initItems
();
initLimitListSpinners
(
mLimitSpinner
,
mCardLoader
.
getLimitList
());
initDecksListSpinners
(
mDeckSpinner
,
rs
.
source
);
//设置当前卡组
setCurDeck
(
rs
);
//设置收藏夹
SparseArray
<
Card
>
id
=
mCardLoader
.
readCards
(
ConfigManager
.
mLines
,
false
);
if
(
id
!=
null
)
{
for
(
int
i
=
0
;
i
<
id
.
size
();
i
++)
Favorite
.
add
(
id
.
valueAt
(
i
));
}
onSearchResult
(
Favorite
,
true
);
isSearchResult
=
false
;
});
}
/**
* 设置当前卡组
*/
private
void
setCurDeck
(
DeckInfo
deckInfo
)
{
if
(
deckInfo
==
null
)
{
deckInfo
=
new
DeckInfo
();
}
File
file
=
deckInfo
.
source
;
if
(
file
!=
null
&&
file
.
exists
())
{
String
name
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
setActionBarSubTitle
(
name
);
// if (inDeckDir(file)) {
//记住最后打开的卡组
mSettings
.
setLastDeckPath
(
file
.
getAbsolutePath
());
tv_deck
.
setText
(
name
);
// }
}
else
{
setActionBarSubTitle
(
getString
(
R
.
string
.
noname
));
}
mDeckAdapater
.
setDeck
(
deckInfo
);
mDeckAdapater
.
notifyDataSetChanged
();
}
private
boolean
inDeckDir
(
File
file
)
{
String
deck
=
new
File
(
AppsSettings
.
get
().
getDeckDir
()).
getAbsolutePath
();
return
TextUtils
.
equals
(
deck
,
file
.
getParent
());
}
@Override
public
void
onSearchStart
()
{
hideDrawers
();
}
@Override
protected
void
onCardClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
if
(
mCardListAdapter
.
isShowMenu
(
view
))
{
return
;
}
if
(
cardInfo
!=
null
)
{
showCardDialog
(
mCardListAdapter
,
cardInfo
,
pos
);
}
}
@Override
protected
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
// mCardListAdapater.showMenu(view);
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
onCardInfoEvent
(
CardInfoEvent
event
)
{
int
pos
=
event
.
position
;
Card
cardInfo
=
mCardListAdapter
.
getItem
(
pos
);
if
(
cardInfo
==
null
)
{
mCardListAdapter
.
hideMenu
(
null
);
}
else
if
(
event
.
toMain
)
{
if
(!
addMainCard
(
cardInfo
))
{
// || !checkLimit(cardInfo, false)) {
mCardListAdapter
.
hideMenu
(
null
);
}
}
else
{
if
(!
addSideCard
(
cardInfo
))
{
// || !checkLimit(cardInfo, false)) {
mCardListAdapter
.
hideMenu
(
null
);
}
}
}
@Override
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
super
.
onSearchResult
(
cardInfos
,
isHide
);
tv_result_count
.
setText
(
String
.
valueOf
(
cardInfos
.
size
()));
if
(!
isHide
)
showResult
(
false
);
}
@Override
public
void
onItemClick
(
View
view
,
int
pos
)
{
if
(
isShowDrawer
())
{
return
;
}
showDeckCard
(
view
,
pos
);
}
@Override
public
void
onItemLongClick
(
View
view
,
int
pos
)
{
}
@Override
public
void
onItemDoubleClick
(
View
view
,
int
pos
)
{
//拖拽中,就不显示
if
(
isShowDrawer
())
{
return
;
}
if
(
Constants
.
DECK_SINGLE_PRESS_DRAG
)
{
showDeckCard
(
view
,
pos
);
}
}
private
void
showDeckCard
(
View
view
,
int
pos
)
{
DeckItem
deckItem
=
mDeckAdapater
.
getItem
(
pos
);
if
(
deckItem
!=
null
&&
deckItem
.
getCardInfo
()
!=
null
)
{
showCardDialog
(
mDeckAdapater
,
deckItem
.
getCardInfo
(),
mDeckAdapater
.
getCardPosByView
(
pos
));
}
}
private
boolean
isShowDrawer
()
{
return
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
)
||
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
private
boolean
isShowCard
()
{
return
mDialog
!=
null
&&
mDialog
.
isShowing
();
}
protected
void
showCardDialog
(
CardListProvider
provider
,
Card
cardInfo
,
int
pos
)
{
if
(
cardInfo
!=
null
)
{
if
(
isShowCard
())
return
;
if
(
mCardDetail
==
null
)
{
mCardDetail
=
new
CardDetail
(
this
,
getImageLoader
(),
mStringManager
);
mCardDetail
.
setOnCardClickListener
(
new
CardDetail
.
OnCardClickListener
()
{
@Override
public
void
onOpenUrl
(
Card
cardInfo
)
{
String
uri
;
int
t
=
cardInfo
.
Alias
-
cardInfo
.
Code
;
if
(
t
>
10
||
t
<
-
10
)
{
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
Code
);
}
else
{
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
Alias
);
}
WebActivity
.
open
(
getContext
(),
cardInfo
.
Name
,
uri
);
}
@Override
public
void
onClose
()
{
mDialog
.
dismiss
();
}
@Override
public
void
onAddSideCard
(
Card
cardInfo
)
{
addSideCard
(
cardInfo
);
}
@Override
public
void
onAddMainCard
(
Card
cardInfo
)
{
addMainCard
(
cardInfo
);
}
});
mCardDetail
.
setCallBack
(
new
CardDetail
.
CallBack
()
{
@Override
public
void
onSearchStart
()
{
}
@Override
public
void
onSearchResult
(
List
<
Card
>
Cards
,
boolean
isHide
)
{
DeckManagerActivity
.
this
.
onSearchResult
(
Cards
,
isHide
);
}
});
}
mCardDetail
.
showAdd
();
if
(
mDialog
==
null
)
{
mDialog
=
new
DialogPlus
(
this
);
mDialog
.
setView
(
mCardDetail
.
getView
());
mDialog
.
hideButton
();
mDialog
.
hideTitleBar
();
mDialog
.
setOnGestureListener
(
new
AOnGestureListener
()
{
@Override
public
boolean
onFling
(
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
)
{
if
(
isLeftFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
mCardDetail
.
onNextCard
();
return
true
;
}
else
if
(
isRightFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
mCardDetail
.
onPreCard
();
return
true
;
}
return
super
.
onFling
(
e1
,
e2
,
velocityX
,
velocityY
);
}
});
}
if
(!
mDialog
.
isShowing
())
{
mDialog
.
show
();
}
mCardDetail
.
bind
(
cardInfo
,
pos
,
provider
);
}
}
private
boolean
addSideCard
(
Card
cardInfo
)
{
if
(
checkLimit
(
cardInfo
))
{
boolean
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
SideCard
);
if
(
rs
)
{
showToast
(
R
.
string
.
add_card_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
add_card_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
return
rs
;
}
return
false
;
}
private
boolean
addMainCard
(
Card
cardInfo
)
{
if
(
checkLimit
(
cardInfo
))
{
boolean
rs
;
if
(
cardInfo
.
isExtraCard
())
{
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
ExtraCard
);
}
else
{
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
MainCard
);
}
if
(
rs
)
{
showToast
(
R
.
string
.
add_card_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
add_card_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
return
rs
;
}
return
false
;
}
@Override
protected
void
onBackHome
()
{
if
(
mDeckAdapater
.
isChanged
())
{
File
ydk
=
mDeckAdapater
.
getYdkFile
();
if
(
ydk
!=
null
&&
ydk
.
exists
())
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
quit_deck_tip
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setRightButtonText
(
getString
(
R
.
string
.
save_quit
));
builder
.
setLeftButtonText
(
getString
(
R
.
string
.
quit
));
builder
.
setRightButtonListener
((
dlg
,
s
)
->
{
doMenu
(
R
.
id
.
action_save
);
dlg
.
dismiss
();
isExit
=
true
;
finish
();
});
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dlg
.
dismiss
();
isExit
=
true
;
finish
();
});
builder
.
show
();
}
}
else
{
super
.
onBackHome
();
}
}
@Override
public
void
onBackPressed
()
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
else
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
else
if
(!
isExit
)
{
if
(
mDeckAdapater
.
isChanged
())
{
File
ydk
=
mDeckAdapater
.
getYdkFile
();
if
(
ydk
!=
null
&&
ydk
.
exists
())
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
quit_deck_tip
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dlg
.
dismiss
();
isExit
=
true
;
finish
();
});
builder
.
show
();
}
}
else
{
super
.
onBackPressed
();
}
}
else
{
super
.
onBackPressed
();
}
}
private
boolean
checkLimit
(
Card
cardInfo
)
{
SparseArray
<
Integer
>
mCount
=
mDeckAdapater
.
getCardCount
();
LimitList
limitList
=
mDeckAdapater
.
getLimitList
();
int
id
=
cardInfo
.
Alias
>
0
?
cardInfo
.
Alias
:
cardInfo
.
Code
;
Integer
count
=
mCount
.
get
(
id
);
if
(
limitList
==
null
)
{
return
count
!=
null
&&
count
<=
3
;
}
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Forbidden
))
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
0
),
Toast
.
LENGTH_SHORT
);
return
false
;
}
if
(
count
!=
null
)
{
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Limit
))
{
if
(
count
>=
1
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
1
),
Toast
.
LENGTH_SHORT
);
return
false
;
}
}
else
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
SemiLimit
))
{
if
(
count
>=
2
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
2
),
Toast
.
LENGTH_SHORT
);
return
false
;
}
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
3
),
Toast
.
LENGTH_SHORT
);
return
false
;
}
}
return
true
;
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
if
(
doMenu
(
item
.
getItemId
()))
{
return
true
;
}
return
super
.
onOptionsItemSelected
(
item
);
}
public
boolean
doMenu
(
int
menuId
)
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
switch
(
menuId
)
{
case
R
.
id
.
action_deck_backup_n_restore
:
startPermissionsActivity
();
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
deck_explain
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonText
(
R
.
string
.
deck_restore
);
builder
.
setRightButtonText
(
R
.
string
.
deck_back_up
);
builder
.
setRightButtonListener
((
dialog
,
which
)
->
{
dialog
.
dismiss
();
doBackUpDeck
();
});
builder
.
setLeftButtonListener
((
dialog
,
which
)
->
{
dialog
.
dismiss
();
doRestoreDeck
();
});
builder
.
show
();
break
;
// case R.id.action_refresh:
// mDeckAdapater.notifyDataSetChanged();
// break;
case
R
.
id
.
action_search
:
//弹条件对话框
showSearch
(
true
);
break
;
case
R
.
id
.
action_card_list
:
showResult
(
true
);
break
;
case
R
.
id
.
action_share_deck
:
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
this
,
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
shareDeck
();
break
;
case
R
.
id
.
action_save
:
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
==
mDeckAdapater
.
getYdkFile
())
{
//需要保存到deck文件夹
inputDeckName
(
mPreLoadFile
,
null
,
true
);
}
else
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
inputDeckName
(
null
,
null
,
true
);
}
else
{
if
(
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getAiDeckDir
()))
{
Toast
.
makeText
(
this
,
R
.
string
.
donot_editor_bot_Deck
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
save
(
mDeckAdapater
.
getYdkFile
());
}
}
}
break
;
case
R
.
id
.
action_rename
:
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
this
,
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
if
(
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getAiDeckDir
()))
{
Toast
.
makeText
(
this
,
R
.
string
.
donot_editor_bot_Deck
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
inputDeckName
(
mDeckAdapater
.
getYdkFile
(),
mDeckAdapater
.
getYdkFile
().
getParent
(),
false
);
}
break
;
case
R
.
id
.
action_deck_new
:
createDeck
(
null
);
break
;
case
R
.
id
.
action_clear_deck
:
{
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_clear_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
mDeckAdapater
.
setDeck
(
new
DeckInfo
());
mDeckAdapater
.
notifyDataSetChanged
();
dlg
.
dismiss
();
});
builder
.
show
();
}
break
;
case
R
.
id
.
action_delete_deck
:
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
this
,
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
if
(
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getAiDeckDir
()))
{
Toast
.
makeText
(
this
,
R
.
string
.
donot_editor_bot_Deck
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_delete_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
if
(
mDeckAdapater
.
getYdkFile
()
!=
null
)
{
FileUtils
.
deleteFile
(
mDeckAdapater
.
getYdkFile
());
dlg
.
dismiss
();
File
file
=
getFirstYdk
();
initDecksListSpinners
(
mDeckSpinner
,
file
);
loadDeckFromFile
(
file
);
}
});
builder
.
show
();
}
}
break
;
case
R
.
id
.
action_unsort
:
//打乱
mDeckAdapater
.
unSort
();
break
;
case
R
.
id
.
action_sort
:
mDeckAdapater
.
sort
();
break
;
default
:
return
false
;
}
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
()
{
List
<
File
>
files
=
getYdkFiles
();
return
files
==
null
||
files
.
size
()
==
0
?
null
:
files
.
get
(
0
);
}
private
void
shareDeck
()
{
builderShareLoading
=
new
DialogPlus
(
this
);
builderShareLoading
.
showProgressBar
();
builderShareLoading
.
hideTitleBar
();
builderShareLoading
.
setMessage
(
R
.
string
.
Pre_share
);
builderShareLoading
.
show
();
//先排序
// mDeckAdapater.sort();
//保存
// if (mPreLoadFile != null && mPreLoadFile == mDeckAdapater.getYdkFile()) {
// //需要保存到deck文件夹
// inputDeckName(mPreLoadFile, null, true);
// } else {
// if (mDeckAdapater.getYdkFile() == null) {
// inputDeckName(null, null, true);
// } else {
// save(mDeckAdapater.getYdkFile());
// }
// }
// //保存成功后重新加载卡组
// File file = getSelectDeck(mDeckSpinner);
// if (file != null) {
// loadDeckFromFile(file);
// }
//延时半秒,使整体看起来更流畅
new
Handler
().
postDelayed
(
this
::
shareDeck1
,
500
);
}
private
void
shareDeck1
()
{
//开启绘图缓存
mRecyclerView
.
setDrawingCacheEnabled
(
true
);
//这个方法可调可不调,因为在getDrawingCache()里会自动判断有没有缓存有没有准备好,
//如果没有,会自动调用buildDrawingCache()
mRecyclerView
.
buildDrawingCache
();
//获取绘图缓存 这里直接创建了一个新的bitmap
//因为我们在最后需要释放缓存资源,会释放掉缓存中创建的bitmap对象
Bitmap
bitmap
=
BitmapUtil
.
drawBg4Bitmap
(
Color
.
parseColor
(
"#e6f3fd"
),
Bitmap
.
createBitmap
(
mRecyclerView
.
getDrawingCache
(),
0
,
0
,
mRecyclerView
.
getMeasuredWidth
(),
mRecyclerView
.
getMeasuredHeight
()));
//清理绘图缓存,释放资源
mRecyclerView
.
destroyDrawingCache
();
// shotRecyclerView(mRecyclerView)
Deck
deck
=
mDeckAdapater
.
toDeck
(
mDeckAdapater
.
getYdkFile
());
String
deckName
=
deck
.
getName
();
int
end
=
deckName
.
lastIndexOf
(
"."
);
if
(
end
!=
-
1
)
{
deckName
=
deckName
.
substring
(
0
,
end
);
}
String
savePath
=
new
File
(
AppsSettings
.
get
().
getDeckSharePath
(),
deckName
+
".jpg"
).
getAbsolutePath
();
BitmapUtil
.
saveBitmap
(
bitmap
,
savePath
,
50
);
builderShareLoading
.
dismiss
();
DialogUtils
du
=
DialogUtils
.
getdx
(
this
);
View
viewDialog
=
du
.
dialogBottomSheet
(
R
.
layout
.
dialog_deck_share
,
0
);
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
(
this
,
savePath
,
iv_image
);
bt_code_share
.
setOnClickListener
(
v
->
{
du
.
dis
();
stopService
(
new
Intent
(
this
,
DuelAssistantService
.
class
));
YGOUtil
.
copyMessage
(
this
,
et_code
.
getText
().
toString
().
trim
());
showToast
(
getString
(
R
.
string
.
deck_text_copyed
));
//复制完毕开启决斗助手
YGOUtil
.
startDuelService
(
this
);
});
bt_image_share
.
setOnClickListener
(
v
->
{
du
.
dis
();
String
category
=
mDeckAdapater
.
getYdkFile
().
getParent
();
String
fname
=
deck
.
getName
();
Intent
intent
=
new
Intent
(
ACTION_SHARE_FILE
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
,
"ydk"
);
if
(
TextUtils
.
equals
(
category
,
mSettings
.
getDeckDir
()))
{
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
fname
);
}
else
{
String
cname
=
DeckUtil
.
getDeckTypeName
(
mDeckAdapater
.
getYdkFile
().
getAbsolutePath
());
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
cname
+
"/"
+
fname
);
}
intent
.
setPackage
(
getPackageName
());
try
{
startActivity
(
intent
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
"dev error:not found activity."
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
//复制前关闭决斗助手
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
// final String uriString = deck.toAppUri().toString();
// final String httpUri = deck.toHttpUri().toString();
// shareUrl(uriString, label);
}
private
void
shareUrl
(
String
uri
,
String
label
)
{
String
url
=
getString
(
R
.
string
.
deck_share_head
)
+
" "
+
uri
;
ShareUtil
.
shareText
(
this
,
getString
(
R
.
string
.
share_deck
),
url
,
null
);
ClipboardManager
clipboardManager
=
(
ClipboardManager
)
getSystemService
(
CLIPBOARD_SERVICE
);
if
(
Build
.
VERSION
.
SDK_INT
>
19
)
{
clipboardManager
.
setPrimaryClip
(
ClipData
.
newPlainText
(
label
,
uri
));
}
else
{
clipboardManager
.
setText
(
uri
);
}
showToast
(
R
.
string
.
copy_to_clipbroad
,
Toast
.
LENGTH_SHORT
);
}
private
File
getSelectDeck
(
Spinner
spinner
)
{
Object
o
=
SimpleSpinnerAdapter
.
getSelectTag
(
spinner
);
if
(
o
instanceof
File
)
{
return
(
File
)
o
;
}
return
null
;
}
private
List
<
File
>
getYdkFiles
()
{
File
dir
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
);
File
[]
files
=
dir
.
listFiles
((
file
,
s
)
->
s
.
toLowerCase
(
Locale
.
US
).
endsWith
(
Constants
.
YDK_FILE_EX
));
if
(
files
!=
null
)
{
List
<
File
>
list
=
new
ArrayList
<>(
Arrays
.
asList
(
files
));
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
.
exists
())
{
boolean
hasCur
=
false
;
for
(
File
f
:
list
)
{
if
(
TextUtils
.
equals
(
f
.
getAbsolutePath
(),
mPreLoadFile
.
getAbsolutePath
()))
{
hasCur
=
true
;
break
;
}
}
if
(!
hasCur
)
{
list
.
add
(
mPreLoadFile
);
}
}
return
list
;
}
return
null
;
}
public
class
DeckManagerActivity
extends
DeckManagerActivityImpl
{
private
void
initDecksListSpinners
(
Spinner
spinner
,
File
curYdk
)
{
List
<
File
>
files
=
getYdkFiles
();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
String
name
=
curYdk
!=
null
?
curYdk
.
getName
()
:
null
;
int
index
=
-
1
;
if
(
files
!=
null
)
{
Collections
.
sort
(
files
,
(
ydk1
,
ydk2
)
->
{
if
(
ydk1
.
isDirectory
()
&&
ydk2
.
isFile
())
return
-
1
;
if
(
ydk1
.
isFile
()
&&
ydk2
.
isDirectory
())
return
1
;
return
ydk1
.
getName
().
compareTo
(
ydk2
.
getName
());
});
int
i
=
0
;
for
(
File
file
:
files
)
{
if
(
name
!=
null
&&
TextUtils
.
equals
(
name
,
file
.
getName
()))
{
index
=
i
;
}
String
filename
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
items
.
add
(
new
SimpleSpinnerItem
(
i
++,
filename
).
setTag
(
file
));
}
}
SimpleSpinnerAdapter
simpleSpinnerAdapter
=
new
SimpleSpinnerAdapter
(
this
);
simpleSpinnerAdapter
.
set
(
items
);
simpleSpinnerAdapter
.
setColor
(
Color
.
WHITE
);
simpleSpinnerAdapter
.
setSingleLine
(
true
);
spinner
.
setAdapter
(
simpleSpinnerAdapter
);
if
(
index
>=
0
)
{
spinner
.
setSelection
(
index
);
}
}
// private void initLimitListSpinners(Spinner spinner) {
// List<SimpleSpinnerItem> items = new ArrayList<>();
// List<Integer> ids = mLimitManager.getLists();
// int index = -1;
// int i = 0;
// for (Integer id : ids) {
// LimitList list = mLimitManager.getLimitFromIndex(id);
// if (list == mLimitList) {
// index = i;
// }
// items.add(new SimpleSpinnerItem(id, list.getName()));
// i++;
// }
// SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(this);
// adapter.set(items);
// spinner.setAdapter(adapter);
// if (index >= 0) {
// spinner.setSelection(index);
// }
private
void
initLimitListSpinners
(
Spinner
spinner
,
LimitList
cur
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
String
>
limitLists
=
mLimitManager
.
getLimitNames
();
int
index
=
-
1
;
int
count
=
mLimitManager
.
getCount
();
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_limitlist
)));
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
int
j
=
i
+
1
;
String
name
=
limitLists
.
get
(
i
);
items
.
add
(
new
SimpleSpinnerItem
(
j
,
name
));
if
(
cur
!=
null
&&
TextUtils
.
equals
(
cur
.
getName
(),
name
))
{
index
=
j
;
}
}
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
adapter
.
setColor
(
Color
.
WHITE
);
adapter
.
set
(
items
);
spinner
.
setAdapter
(
adapter
);
if
(
index
>=
0
)
{
spinner
.
setSelection
(
index
);
}
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
setLimitList
(
mLimitManager
.
getLimit
(
SimpleSpinnerAdapter
.
getSelectText
(
spinner
)));
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
}
private
void
setLimitList
(
LimitList
limitList
)
{
if
(
limitList
==
null
)
return
;
LimitList
last
=
mDeckAdapater
.
getLimitList
();
boolean
nochanged
=
last
!=
null
&&
TextUtils
.
equals
(
last
.
getName
(),
limitList
.
getName
());
if
(!
nochanged
)
{
mDeckAdapater
.
setLimitList
(
limitList
);
runOnUiThread
(()
->
{
mDeckAdapater
.
notifyItemRangeChanged
(
DeckItem
.
MainStart
,
DeckItem
.
MainEnd
);
mDeckAdapater
.
notifyItemRangeChanged
(
DeckItem
.
ExtraStart
,
DeckItem
.
ExtraEnd
);
mDeckAdapater
.
notifyItemRangeChanged
(
DeckItem
.
SideStart
,
DeckItem
.
SideEnd
);
});
}
mCardListAdapter
.
setLimitList
(
limitList
);
runOnUiThread
(()
->
mCardListAdapter
.
notifyDataSetChanged
());
}
public
static
Class
<?
extends
Activity
>
getDeckManager
()
{
private
void
inputDeckName
(
File
oldYdk
,
String
savePath
,
boolean
keepOld
)
{
if
(
AppsSettings
.
get
().
isUseDeckManagerV2
())
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
return
DeckManagerActivity3
.
class
;
builder
.
setTitle
(
R
.
string
.
intpu_name
);
EditText
editText
=
new
EditText
(
this
);
editText
.
setGravity
(
Gravity
.
TOP
|
Gravity
.
LEFT
);
editText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_NO_SUGGESTIONS
);
editText
.
setSingleLine
();
if
(
oldYdk
!=
null
)
{
editText
.
setText
(
oldYdk
.
getName
());
}
}
return
DeckManagerActivity
.
class
;
builder
.
setContentView
(
editText
);
builder
.
setOnCloseLinster
(
DialogInterface:
:
dismiss
);
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
CharSequence
name
=
editText
.
getText
();
if
(!
TextUtils
.
isEmpty
(
name
))
{
String
filename
=
String
.
valueOf
(
name
);
if
(!
filename
.
endsWith
(
YDK_FILE_EX
))
{
filename
+=
YDK_FILE_EX
;
}
File
ydk
;
if
(
TextUtils
.
isEmpty
(
savePath
))
ydk
=
new
File
(
mSettings
.
getDeckDir
(),
filename
);
else
ydk
=
new
File
(
savePath
,
filename
);
if
(
ydk
.
exists
())
{
showToast
(
R
.
string
.
file_exist
,
Toast
.
LENGTH_SHORT
);
return
;
}
if
(!
keepOld
&&
oldYdk
!=
null
&&
oldYdk
.
exists
())
{
if
(
oldYdk
.
renameTo
(
ydk
))
{
initDecksListSpinners
(
mDeckSpinner
,
ydk
);
dlg
.
dismiss
();
loadDeckFromFile
(
ydk
);
}
}
else
{
if
(
oldYdk
==
mPreLoadFile
)
{
mPreLoadFile
=
null
;
}
dlg
.
dismiss
();
try
{
boolean
ret
=
ydk
.
createNewFile
();
}
catch
(
Throwable
ignore
)
{
}
initDecksListSpinners
(
mDeckSpinner
,
ydk
);
save
(
ydk
);
loadDeckFromFile
(
ydk
);
}
}
else
{
dlg
.
dismiss
();
}
});
builder
.
show
();
}
private
void
save
(
File
ydk
)
{
if
(
mDeckAdapater
.
save
(
ydk
))
{
showToast
(
R
.
string
.
save_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
save_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
}
private
void
initBoomMenuButton
(
BoomMenuButton
menu
)
{
final
SparseArray
<
Integer
>
mMenuIds
=
new
SparseArray
<>();
// addMenuButton(mMenuIds, menu, R.id.action_card_search, R.string.deck_list, R.drawable.listicon);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_share_deck
,
R
.
string
.
share_deck
,
R
.
drawable
.
shareicon
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_save
,
R
.
string
.
save_deck
,
R
.
drawable
.
save
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_clear_deck
,
R
.
string
.
clear_deck
,
R
.
drawable
.
clear_deck
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_deck_new
,
R
.
string
.
new_deck
,
R
.
drawable
.
addsever
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_rename
,
R
.
string
.
rename_deck
,
R
.
drawable
.
rename
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_delete_deck
,
R
.
string
.
delete_deck
,
R
.
drawable
.
delete
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_unsort
,
R
.
string
.
unsort
,
R
.
drawable
.
unsort
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_sort
,
R
.
string
.
sort
,
R
.
drawable
.
sort
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_deck_backup_n_restore
,
R
.
string
.
deck_backup_n_restore
,
R
.
drawable
.
downloadimages
);
//设置展开或隐藏的延时。 默认值为 800ms。
menu
.
setDuration
(
150
);
//设置每两个子按钮之间动画的延时(ms为单位)。 比如,如果延时设为0,那么所有子按钮都会同时展开或隐藏,默认值为100ms。
menu
.
setDelay
(
10
);
menu
.
setOnBoomListener
(
new
DefaultOnBoomListener
()
{
@Override
public
void
onClicked
(
int
index
,
BoomButton
boomButton
)
{
doMenu
(
mMenuIds
.
get
(
index
));
}
});
}
private
void
addMenuButton
(
SparseArray
<
Integer
>
mMenuIds
,
BoomMenuButton
menuButton
,
int
menuId
,
int
stringId
,
int
image
)
{
addMenuButton
(
mMenuIds
,
menuButton
,
menuId
,
getString
(
stringId
),
image
);
}
private
void
addMenuButton
(
SparseArray
<
Integer
>
mMenuIds
,
BoomMenuButton
menuButton
,
int
menuId
,
String
str
,
int
image
)
{
TextOutsideCircleButton
.
Builder
builder
=
new
TextOutsideCircleButton
.
Builder
()
.
shadowColor
(
Color
.
TRANSPARENT
)
.
normalColor
(
Color
.
TRANSPARENT
)
.
normalImageRes
(
image
)
.
normalText
(
str
);
menuButton
.
addBuilder
(
builder
);
mMenuIds
.
put
(
mMenuIds
.
size
(),
menuId
);
}
private
void
doBackUpDeck
()
{
try
{
FileUtils
.
copyDir
(
mSettings
.
getDeckDir
(),
ORI_DECK
,
true
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
();
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
();
}
private
void
doRestoreDeck
()
{
try
{
FileUtils
.
copyDir
(
ORI_DECK
,
mSettings
.
getDeckDir
(),
false
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
();
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
loadDeckFromFile
(
new
File
(
deckFile
.
getPath
()));
}
@Override
public
void
onDeckDel
(
List
<
DeckFile
>
deckFileList
)
{
File
deck
=
mDeckAdapater
.
getYdkFile
();
if
(
deck
==
null
)
return
;
String
currentDeckPath
=
deck
.
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/cards/DeckManagerActivity2.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards
;
public
class
DeckManagerActivity2
extends
DeckManagerActivityImpl2
{
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity3.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards
;
import
android.content.Intent
;
import
android.content.res.Configuration
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.widget.Toast
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.recyclerview.widget.OnItemDragListener
;
import
androidx.recyclerview.widget.RecyclerView
;
import
java.io.File
;
import
java.util.List
;
import
java.util.Locale
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.CardLoader
;
import
cn.garymb.ygomobile.loader.DeckLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.cards.deck2.DeckAdapter
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
public
class
DeckManagerActivity3
extends
BaseActivity
implements
OnItemDragListener
,
CardLoader
.
CallBack
{
private
RecyclerView
mRecyclerView
;
private
DeckAdapter
mDeckAdapter
;
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
CardLoader
mCardLoader
;
private
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
String
mPreLoad
;
private
File
mYdkFile
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_deck_cards3
);
Toolbar
toolbar
=
$
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
enableBackHome
();
mRecyclerView
=
(
RecyclerView
)
findViewById
(
R
.
id
.
recyclerview
);
mDeckAdapter
=
new
DeckAdapter
(
this
,
mRecyclerView
,
this
);
mRecyclerView
.
setAdapter
(
mDeckAdapter
);
findViewById
(
R
.
id
.
refresh
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
mDeckAdapter
.
notifyDataSetChanged
();
}
});
mCardLoader
=
new
CardLoader
(
this
);
mCardLoader
.
setCallBack
(
this
);
if
(
getIntent
().
hasExtra
(
Intent
.
EXTRA_TEXT
))
{
String
path
=
getIntent
().
getStringExtra
(
Intent
.
EXTRA_TEXT
);
if
(!
TextUtils
.
isEmpty
(
path
))
{
mPreLoad
=
path
;
}
}
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
File
file
=
new
File
(
mSettings
.
getLastDeckPath
());
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
file
=
new
File
(
mPreLoad
);
mPreLoad
=
null
;
}
if
(!
file
.
exists
())
{
//当默认卡组不存在的时候
File
[]
files
=
getYdkFiles
();
if
(
files
!=
null
&&
files
.
length
>
0
)
{
file
=
files
[
0
];
}
}
//EXTRA_DECK
if
(
file
==
null
)
{
return
new
DeckInfo
();
}
mYdkFile
=
file
;
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
DeckLoader
.
readDeck
(
mCardLoader
,
file
,
mCardLoader
.
getLimitList
());
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
mDeckAdapter
.
setDeckInfo
(
rs
);
mDeckAdapter
.
notifyDataSetChanged
();
});
}
private
File
[]
getYdkFiles
()
{
File
dir
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
);
File
[]
files
=
dir
.
listFiles
((
file
,
s
)
->
{
return
s
.
toLowerCase
(
Locale
.
US
).
endsWith
(
Constants
.
YDK_FILE_EX
);
});
return
files
;
}
@Override
public
void
onDragStart
()
{
}
@Override
public
void
onDragLongPress
(
int
pos
)
{
Toast
.
makeText
(
this
,
"on long press :"
+
pos
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onConfigurationChanged
(
Configuration
newConfig
)
{
if
(
getRequestedOrientation
()
!=
newConfig
.
orientation
)
{
mDeckAdapter
.
notifyDataSetChanged
();
}
super
.
onConfigurationChanged
(
newConfig
);
}
@Override
public
void
onDragLongPressEnd
()
{
}
@Override
public
void
onDragEnd
()
{
}
@Override
public
void
onSearchStart
()
{
}
@Override
public
void
onLimitListChanged
(
LimitList
limitList
)
{
}
@Override
public
void
onSearchResult
(
List
<
Card
>
Cards
,
boolean
isHide
)
{
}
@Override
public
void
onResetSearch
()
{
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.SparseArray
;
import
android.view.Gravity
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.AppCompatSpinner
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.recyclerview.widget.ItemTouchHelperPlus
;
import
androidx.recyclerview.widget.OnItemDragListener
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
com.nightonke.boommenu.BoomButtons.BoomButton
;
import
com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton
;
import
com.nightonke.boommenu.BoomMenuButton
;
import
com.ourygo.assistant.service.DuelAssistantService
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Locale
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.Deck
;
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.DeckFile
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckAdapater
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItem
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemTouchHelper
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemType
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckLayoutManager
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.BitmapUtil
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.ConfigManager
;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.LimitType
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
import
static
cn
.
garymb
.
ygomobile
.
core
.
IrrlichtBridge
.
ACTION_SHARE_FILE
;
class
DeckManagerActivityImpl
extends
BaseCardsAcitivity
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
,
YGODialogUtil
.
OnDeckMenuListener
{
//region ui onCreate/onDestroy
private
RecyclerView
mRecyclerView
;
private
DeckAdapater
mDeckAdapater
;
private
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
File
mPreLoadFile
;
private
DeckItemTouchHelper
mDeckItemTouchHelper
;
private
AppCompatSpinner
mDeckSpinner
;
private
TextView
tv_deck
;
private
TextView
tv_result_count
;
private
SimpleSpinnerAdapter
mSimpleSpinnerAdapter
;
private
AppCompatSpinner
mLimitSpinner
;
private
CardDetail
mCardDetail
;
private
DialogPlus
mDialog
;
private
DialogPlus
builderShareLoading
;
private
boolean
isExit
=
false
;
public
static
boolean
isSearchResult
;
public
static
List
<
Card
>
Favorite
=
new
ArrayList
<
Card
>();
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
tv_deck
=
$
(
R
.
id
.
tv_deck
);
tv_result_count
=
$
(
R
.
id
.
result_count
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
mDeckSpinner
.
setPopupBackgroundResource
(
R
.
color
.
colorNavy
);
mLimitSpinner
=
$
(
R
.
id
.
sp_limit_list
);
mLimitSpinner
.
setPopupBackgroundResource
(
R
.
color
.
colorNavy
);
mRecyclerView
=
$
(
R
.
id
.
grid_cards
);
mRecyclerView
.
setPadding
(
mRecyclerView
.
getPaddingLeft
(),
0
,
mRecyclerView
.
getPaddingRight
(),
mRecyclerView
.
getPaddingBottom
());
mRecyclerView
.
setAdapter
((
mDeckAdapater
=
new
DeckAdapater
(
this
,
mRecyclerView
,
getImageLoader
())));
mRecyclerView
.
setLayoutManager
(
new
DeckLayoutManager
(
this
,
Constants
.
DECK_WIDTH_COUNT
));
mDeckItemTouchHelper
=
new
DeckItemTouchHelper
(
mDeckAdapater
);
ItemTouchHelperPlus
touchHelper
=
new
ItemTouchHelperPlus
(
this
,
mDeckItemTouchHelper
);
touchHelper
.
setItemDragListener
(
this
);
touchHelper
.
setEnableClickDrag
(
Constants
.
DECK_SINGLE_PRESS_DRAG
);
touchHelper
.
attachToRecyclerView
(
mRecyclerView
);
mRecyclerView
.
addOnItemTouchListener
(
new
RecyclerViewItemListener
(
mRecyclerView
,
this
));
mDeckSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
adapterView
,
View
view
,
int
i
,
long
l
)
{
File
file
=
getSelectDeck
(
mDeckSpinner
);
if
(
file
!=
null
)
{
loadDeckFromFile
(
file
);
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
adapterView
)
{
}
});
String
preLoadFile
=
null
;
if
(
getIntent
().
hasExtra
(
Intent
.
EXTRA_TEXT
))
{
preLoadFile
=
getIntent
().
getStringExtra
(
Intent
.
EXTRA_TEXT
);
}
initBoomMenuButton
(
$
(
R
.
id
.
bmb
));
$
(
R
.
id
.
btn_nav_search
).
setOnClickListener
((
v
)
->
{
doMenu
(
R
.
id
.
action_search
);
});
$
(
R
.
id
.
btn_nav_list
).
setOnClickListener
((
v
)
->
{
doMenu
(
R
.
id
.
action_card_list
);
});
//
final
File
_file
;
//打开指定卡组
if
(!
TextUtils
.
isEmpty
(
preLoadFile
)
&&
(
mPreLoadFile
=
new
File
(
preLoadFile
)).
exists
())
{
//外面卡组
_file
=
mPreLoadFile
;
}
else
{
mPreLoadFile
=
null
;
//最后卡组
_file
=
new
File
(
mSettings
.
getLastDeckPath
());
}
Favorite
.
clear
();
init
(
_file
);
EventBus
.
getDefault
().
register
(
this
);
tv_deck
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
YGODialogUtil
.
dialogDeckSelect
(
DeckManagerActivityImpl
.
this
,
AppsSettings
.
get
().
getLastDeckPath
(),
DeckManagerActivityImpl
.
this
);
}
});
}
//endregion
@Override
protected
void
onDestroy
()
{
EventBus
.
getDefault
().
unregister
(
this
);
super
.
onDestroy
();
}
//region card edit
@Override
public
void
onLimitListChanged
(
LimitList
limitList
)
{
}
@Override
public
void
onDragStart
()
{
}
@Override
public
void
onDragLongPress
(
int
pos
)
{
if
(
pos
<
0
)
return
;
if
(
Constants
.
DEBUG
)
Log
.
d
(
"kk"
,
"delete "
+
pos
);
if
(
mSettings
.
isDialogDelete
())
{
DeckItem
deckItem
=
mDeckAdapater
.
getItem
(
pos
);
if
(
deckItem
==
null
||
deckItem
.
getCardInfo
()
==
null
)
{
return
;
}
DialogPlus
dialogPlus
=
new
DialogPlus
(
this
);
dialogPlus
.
setTitle
(
R
.
string
.
question
);
dialogPlus
.
setMessage
(
getString
(
R
.
string
.
delete_card
,
deckItem
.
getCardInfo
().
Name
));
dialogPlus
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
dialogPlus
.
setLeftButtonListener
((
dlg
,
v
)
->
{
dlg
.
dismiss
();
mDeckItemTouchHelper
.
remove
(
pos
);
});
dialogPlus
.
show
();
}
else
{
mDeckAdapater
.
showHeadView
();
}
}
@Override
public
void
onDragLongPressEnd
()
{
mDeckAdapater
.
hideHeadView
();
}
//endregion
@Override
public
void
onDragEnd
()
{
}
//endregion
//region load deck
private
void
loadDeckFromFile
(
File
file
)
{
if
(!
mCardLoader
.
isOpen
()
||
file
==
null
||
!
file
.
exists
())
{
setCurDeck
(
new
DeckInfo
());
return
;
}
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
mDeckAdapater
.
read
(
mCardLoader
,
file
,
mCardLoader
.
getLimitList
());
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
setCurDeck
(
rs
);
});
}
//endregion
//region init
private
void
init
(
File
ydk
)
{
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
DataManager
.
get
().
load
(
false
);
//默认第一个卡表
if
(
mLimitManager
.
getCount
()
>
0
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
}
File
file
=
ydk
;
if
(!
file
.
exists
())
{
//当默认卡组不存在的时候
List
<
File
>
files
=
getYdkFiles
();
if
(
files
!=
null
&&
files
.
size
()
>
0
)
{
file
=
files
.
get
(
0
);
}
}
//EXTRA_DECK
if
(
file
==
null
)
{
return
new
DeckInfo
();
}
Log
.
i
(
"kk"
,
"load ydk "
+
file
);
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
mDeckAdapater
.
read
(
mCardLoader
,
file
,
mCardLoader
.
getLimitList
());
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
isLoad
=
true
;
dlg
.
dismiss
();
mCardSelector
.
initItems
();
initLimitListSpinners
(
mLimitSpinner
,
mCardLoader
.
getLimitList
());
initDecksListSpinners
(
mDeckSpinner
,
rs
.
source
);
//设置当前卡组
setCurDeck
(
rs
);
//设置收藏夹
SparseArray
<
Card
>
id
=
mCardLoader
.
readCards
(
ConfigManager
.
mLines
,
false
);
if
(
id
!=
null
)
{
for
(
int
i
=
0
;
i
<
id
.
size
();
i
++)
Favorite
.
add
(
id
.
valueAt
(
i
));
}
onSearchResult
(
Favorite
,
true
);
isSearchResult
=
false
;
});
}
/**
* 设置当前卡组
*
* @param deckInfo
*/
private
void
setCurDeck
(
DeckInfo
deckInfo
)
{
if
(
deckInfo
==
null
)
{
deckInfo
=
new
DeckInfo
();
}
File
file
=
deckInfo
.
source
;
if
(
file
!=
null
&&
file
.
exists
())
{
String
name
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
setActionBarSubTitle
(
name
);
// if (inDeckDir(file)) {
//记住最后打开的卡组
mSettings
.
setLastDeckPath
(
file
.
getAbsolutePath
());
tv_deck
.
setText
(
name
);
// }
}
else
{
setActionBarSubTitle
(
getString
(
R
.
string
.
noname
));
}
mDeckAdapater
.
setDeck
(
deckInfo
);
mDeckAdapater
.
notifyDataSetChanged
();
}
private
boolean
inDeckDir
(
File
file
)
{
String
deck
=
new
File
(
AppsSettings
.
get
().
getDeckDir
()).
getAbsolutePath
();
return
TextUtils
.
equals
(
deck
,
file
.
getParentFile
().
getAbsolutePath
());
}
@Override
public
void
onSearchStart
()
{
hideDrawers
();
}
@Override
protected
void
onCardClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
if
(
mCardListAdapater
.
isShowMenu
(
view
))
{
return
;
}
if
(
cardInfo
!=
null
)
{
showCardDialog
(
mCardListAdapater
,
cardInfo
,
pos
);
}
}
@Override
protected
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
// mCardListAdapater.showMenu(view);
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
onCardInfoEvent
(
CardInfoEvent
event
)
{
int
pos
=
event
.
position
;
Card
cardInfo
=
mCardListAdapater
.
getItem
(
pos
);
if
(
cardInfo
==
null
)
{
mCardListAdapater
.
hideMenu
(
null
);
}
else
if
(
event
.
toMain
)
{
if
(!
addMainCard
(
cardInfo
))
{
// || !checkLimit(cardInfo, false)) {
mCardListAdapater
.
hideMenu
(
null
);
}
}
else
{
if
(!
addSideCard
(
cardInfo
))
{
// || !checkLimit(cardInfo, false)) {
mCardListAdapater
.
hideMenu
(
null
);
}
}
}
@Override
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
super
.
onSearchResult
(
cardInfos
,
isHide
);
tv_result_count
.
setText
(
String
.
valueOf
(
cardInfos
.
size
()));
if
(!
isHide
)
showResult
(
false
);
}
@Override
public
void
onItemClick
(
View
view
,
int
pos
)
{
if
(
isShowDrawer
())
{
return
;
}
showDeckCard
(
view
,
pos
);
}
@Override
public
void
onItemLongClick
(
View
view
,
int
pos
)
{
if
(
isShowDrawer
())
{
return
;
}
}
@Override
public
void
onItemDoubleClick
(
View
view
,
int
pos
)
{
//拖拽中,就不显示
if
(
isShowDrawer
())
{
return
;
}
if
(
Constants
.
DECK_SINGLE_PRESS_DRAG
)
{
showDeckCard
(
view
,
pos
);
}
}
private
void
showDeckCard
(
View
view
,
int
pos
)
{
DeckItem
deckItem
=
mDeckAdapater
.
getItem
(
pos
);
if
(
deckItem
!=
null
&&
deckItem
.
getCardInfo
()
!=
null
)
{
showCardDialog
(
mDeckAdapater
,
deckItem
.
getCardInfo
(),
mDeckAdapater
.
getCardPosByView
(
pos
));
}
}
private
boolean
isShowDrawer
()
{
return
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
)
||
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
private
boolean
isShowCard
()
{
return
mDialog
!=
null
&&
mDialog
.
isShowing
();
}
protected
void
showCardDialog
(
CardListProvider
provider
,
Card
cardInfo
,
int
pos
)
{
if
(
cardInfo
!=
null
)
{
if
(
isShowCard
())
return
;
if
(
mCardDetail
==
null
)
{
mCardDetail
=
new
CardDetail
(
this
,
getImageLoader
(),
mStringManager
);
mCardDetail
.
setOnCardClickListener
(
new
CardDetail
.
OnCardClickListener
()
{
@Override
public
void
onOpenUrl
(
Card
cardInfo
)
{
String
uri
;
int
t
=
cardInfo
.
Alias
-
cardInfo
.
Code
;
if
(
t
>
10
||
t
<
-
10
)
{
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
Code
);
}
else
{
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
Alias
);
}
WebActivity
.
open
(
getContext
(),
cardInfo
.
Name
,
uri
);
}
@Override
public
void
onClose
()
{
mDialog
.
dismiss
();
}
@Override
public
void
onAddSideCard
(
Card
cardInfo
)
{
addSideCard
(
cardInfo
);
}
@Override
public
void
onAddMainCard
(
Card
cardInfo
)
{
addMainCard
(
cardInfo
);
}
});
mCardDetail
.
setCallBack
(
new
CardDetail
.
CallBack
()
{
@Override
public
void
onSearchStart
()
{
}
@Override
public
void
onSearchResult
(
List
<
Card
>
Cards
,
boolean
isHide
)
{
DeckManagerActivityImpl
.
this
.
onSearchResult
(
Cards
,
isHide
);
}
});
}
mCardDetail
.
showAdd
();
if
(
mDialog
==
null
)
{
mDialog
=
new
DialogPlus
(
this
);
mDialog
.
setView
(
mCardDetail
.
getView
());
mDialog
.
hideButton
();
mDialog
.
hideTitleBar
();
mDialog
.
setOnGestureListener
(
new
AOnGestureListener
()
{
@Override
public
boolean
onFling
(
MotionEvent
e1
,
MotionEvent
e2
,
float
velocityX
,
float
velocityY
)
{
if
(
isLeftFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
mCardDetail
.
onNextCard
();
return
true
;
}
else
if
(
isRightFling
(
e1
,
e2
,
velocityX
,
velocityY
))
{
mCardDetail
.
onPreCard
();
return
true
;
}
return
super
.
onFling
(
e1
,
e2
,
velocityX
,
velocityY
);
}
});
}
if
(!
mDialog
.
isShowing
())
{
mDialog
.
show
();
}
mCardDetail
.
bind
(
cardInfo
,
pos
,
provider
);
}
}
private
boolean
addSideCard
(
Card
cardInfo
)
{
if
(
checkLimit
(
cardInfo
,
true
))
{
boolean
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
SideCard
);
if
(
rs
)
{
showToast
(
R
.
string
.
add_card_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
add_card_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
return
rs
;
}
return
false
;
}
private
boolean
addMainCard
(
Card
cardInfo
)
{
if
(
checkLimit
(
cardInfo
,
true
))
{
boolean
rs
;
if
(
cardInfo
.
isExtraCard
())
{
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
ExtraCard
);
}
else
{
rs
=
mDeckAdapater
.
AddCard
(
cardInfo
,
DeckItemType
.
MainCard
);
}
if
(
rs
)
{
showToast
(
R
.
string
.
add_card_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
add_card_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
return
rs
;
}
return
false
;
}
@Override
protected
void
onBackHome
()
{
if
(
mDeckAdapater
.
isChanged
())
{
File
ydk
=
mDeckAdapater
.
getYdkFile
();
if
(
ydk
!=
null
&&
ydk
.
exists
())
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
quit_deck_tip
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setRightButtonText
(
getString
(
R
.
string
.
save_quit
));
builder
.
setLeftButtonText
(
getString
(
R
.
string
.
quit
));
builder
.
setRightButtonListener
((
dlg
,
s
)
->
{
doMenu
(
R
.
id
.
action_save
);
dlg
.
dismiss
();
isExit
=
true
;
finish
();
});
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dlg
.
dismiss
();
isExit
=
true
;
finish
();
});
builder
.
show
();
}
}
else
{
super
.
onBackHome
();
}
}
@Override
public
void
onBackPressed
()
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawerlayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
else
if
(
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerlayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
else
if
(!
isExit
)
{
if
(
mDeckAdapater
.
isChanged
())
{
File
ydk
=
mDeckAdapater
.
getYdkFile
();
if
(
ydk
!=
null
&&
ydk
.
exists
())
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
quit_deck_tip
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dlg
.
dismiss
();
isExit
=
true
;
finish
();
});
builder
.
show
();
}
}
else
{
super
.
onBackPressed
();
}
}
else
{
super
.
onBackPressed
();
}
}
private
boolean
checkLimit
(
Card
cardInfo
,
boolean
tip
)
{
SparseArray
<
Integer
>
mCount
=
mDeckAdapater
.
getCardCount
();
LimitList
limitList
=
mDeckAdapater
.
getLimitList
();
Integer
id
=
cardInfo
.
Alias
>
0
?
cardInfo
.
Alias
:
cardInfo
.
Code
;
Integer
count
=
mCount
.
get
(
id
);
if
(
limitList
==
null
)
{
return
count
!=
null
&&
count
<=
3
;
}
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Forbidden
))
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
0
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
if
(
count
!=
null
)
{
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Limit
))
{
if
(
count
>=
1
)
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
1
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
}
else
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
SemiLimit
))
{
if
(
count
>=
2
)
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
2
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
3
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
}
return
true
;
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
if
(
doMenu
(
item
.
getItemId
()))
{
return
true
;
}
return
super
.
onOptionsItemSelected
(
item
);
}
public
boolean
doMenu
(
int
menuId
)
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
switch
(
menuId
)
{
case
R
.
id
.
action_deck_backup_n_restore
:
startPermissionsActivity
();
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
deck_explain
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonText
(
R
.
string
.
deck_restore
);
builder
.
setRightButtonText
(
R
.
string
.
deck_back_up
);
builder
.
setRightButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
doBackUpDeck
();
}
});
builder
.
setLeftButtonListener
(
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
doRestoreDeck
();
}
});
builder
.
show
();
break
;
// case R.id.action_refresh:
// mDeckAdapater.notifyDataSetChanged();
// break;
case
R
.
id
.
action_search
:
//弹条件对话框
showSearch
(
true
);
break
;
case
R
.
id
.
action_card_list
:
showResult
(
true
);
break
;
case
R
.
id
.
action_share_deck
:
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
this
,
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
shareDeck
();
break
;
case
R
.
id
.
action_save
:
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
==
mDeckAdapater
.
getYdkFile
())
{
//需要保存到deck文件夹
inputDeckName
(
mPreLoadFile
,
null
,
true
);
}
else
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
inputDeckName
(
null
,
null
,
true
);
}
else
{
if
(
mDeckAdapater
.
getYdkFile
().
getParent
().
equals
(
mSettings
.
getAiDeckDir
()))
{
Toast
.
makeText
(
this
,
R
.
string
.
donot_editor_bot_Deck
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
save
(
mDeckAdapater
.
getYdkFile
());
}
}
}
break
;
case
R
.
id
.
action_rename
:
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
this
,
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
if
(
mDeckAdapater
.
getYdkFile
().
getParent
().
equals
(
mSettings
.
getAiDeckDir
()))
{
Toast
.
makeText
(
this
,
R
.
string
.
donot_editor_bot_Deck
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
inputDeckName
(
mDeckAdapater
.
getYdkFile
(),
mDeckAdapater
.
getYdkFile
().
getParent
(),
false
);
}
break
;
case
R
.
id
.
action_deck_new
:
createDeck
(
null
);
break
;
case
R
.
id
.
action_clear_deck
:
{
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_clear_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
mDeckAdapater
.
setDeck
(
new
DeckInfo
());
mDeckAdapater
.
notifyDataSetChanged
();
dlg
.
dismiss
();
});
builder
.
show
();
}
break
;
case
R
.
id
.
action_delete_deck
:
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
this
,
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
if
(
mDeckAdapater
.
getYdkFile
().
getParent
().
equals
(
mSettings
.
getAiDeckDir
()))
{
Toast
.
makeText
(
this
,
R
.
string
.
donot_editor_bot_Deck
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_delete_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
if
(
mDeckAdapater
.
getYdkFile
()
!=
null
)
{
FileUtils
.
deleteFile
(
mDeckAdapater
.
getYdkFile
());
dlg
.
dismiss
();
File
file
=
getFirstYdk
();
initDecksListSpinners
(
mDeckSpinner
,
file
);
loadDeckFromFile
(
file
);
}
else
{
return
;
}
});
builder
.
show
();
}
}
break
;
case
R
.
id
.
action_unsort
:
//打乱
mDeckAdapater
.
unSort
();
break
;
case
R
.
id
.
action_sort
:
mDeckAdapater
.
sort
();
break
;
default
:
return
false
;
}
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
()
{
List
<
File
>
files
=
getYdkFiles
();
return
files
==
null
||
files
.
size
()
==
0
?
null
:
files
.
get
(
0
);
}
private
void
shareDeck
()
{
builderShareLoading
=
new
DialogPlus
(
this
);
builderShareLoading
.
showProgressBar
();
builderShareLoading
.
hideTitleBar
();
builderShareLoading
.
setMessage
(
R
.
string
.
Pre_share
);
builderShareLoading
.
show
();
//先排序
// mDeckAdapater.sort();
//保存
// if (mPreLoadFile != null && mPreLoadFile == mDeckAdapater.getYdkFile()) {
// //需要保存到deck文件夹
// inputDeckName(mPreLoadFile, null, true);
// } else {
// if (mDeckAdapater.getYdkFile() == null) {
// inputDeckName(null, null, true);
// } else {
// save(mDeckAdapater.getYdkFile());
// }
// }
// //保存成功后重新加载卡组
// File file = getSelectDeck(mDeckSpinner);
// if (file != null) {
// loadDeckFromFile(file);
// }
//延时半秒,使整体看起来更流畅
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
shareDeck1
();
}
},
500
);
}
private
void
shareDeck1
()
{
//开启绘图缓存
mRecyclerView
.
setDrawingCacheEnabled
(
true
);
//这个方法可调可不调,因为在getDrawingCache()里会自动判断有没有缓存有没有准备好,
//如果没有,会自动调用buildDrawingCache()
mRecyclerView
.
buildDrawingCache
();
//获取绘图缓存 这里直接创建了一个新的bitmap
//因为我们在最后需要释放缓存资源,会释放掉缓存中创建的bitmap对象
Bitmap
bitmap
=
BitmapUtil
.
drawBg4Bitmap
(
Color
.
parseColor
(
"#e6f3fd"
),
Bitmap
.
createBitmap
(
mRecyclerView
.
getDrawingCache
(),
0
,
0
,
mRecyclerView
.
getMeasuredWidth
(),
mRecyclerView
.
getMeasuredHeight
()));
//清理绘图缓存,释放资源
mRecyclerView
.
destroyDrawingCache
();
// shotRecyclerView(mRecyclerView)
Deck
deck
=
mDeckAdapater
.
toDeck
(
mDeckAdapater
.
getYdkFile
());
String
deckName
=
deck
.
getName
();
int
end
=
deckName
.
lastIndexOf
(
"."
);
if
(
end
!=
-
1
)
{
deckName
=
deckName
.
substring
(
0
,
end
);
}
String
savePath
=
new
File
(
AppsSettings
.
get
().
getDeckSharePath
(),
deckName
+
".jpg"
).
getAbsolutePath
();
BitmapUtil
.
saveBitmap
(
bitmap
,
savePath
,
50
);
builderShareLoading
.
dismiss
();
DialogUtils
du
=
DialogUtils
.
getdx
(
DeckManagerActivityImpl
.
this
);
View
viewDialog
=
du
.
dialogBottomSheet
(
R
.
layout
.
dialog_deck_share
,
0
);
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
,
DuelAssistantService
.
class
));
YGOUtil
.
copyMessage
(
DeckManagerActivityImpl
.
this
,
et_code
.
getText
().
toString
().
trim
());
showToast
(
getString
(
R
.
string
.
deck_text_copyed
));
//复制完毕开启决斗助手
YGOUtil
.
startDuelService
(
DeckManagerActivityImpl
.
this
);
}
});
bt_image_share
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
du
.
dis
();
//ShareUtil.shareImage(DeckManagerActivityImpl.this, getContext().getString(R.string.screenshoot), savePath, null);
String
category
=
mDeckAdapater
.
getYdkFile
().
getParent
();
String
fname
=
deck
.
getName
();
Intent
intent
=
new
Intent
(
ACTION_SHARE_FILE
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_TYPE
,
"ydk"
);
if
(
category
.
equals
(
mSettings
.
getDeckDir
()))
{
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
fname
);
}
else
{
String
cname
=
DeckUtil
.
getDeckTypeName
(
mDeckAdapater
.
getYdkFile
().
getAbsolutePath
());
intent
.
putExtra
(
IrrlichtBridge
.
EXTRA_SHARE_FILE
,
cname
+
"/"
+
fname
);
}
intent
.
setPackage
(
getPackageName
());
try
{
startActivity
(
intent
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
"dev error:not found activity."
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
});
//复制前关闭决斗助手
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
// final String uriString = deck.toAppUri().toString();
// final String httpUri = deck.toHttpUri().toString();
// shareUrl(uriString, label);
}
private
void
shareUrl
(
String
uri
,
String
label
)
{
String
url
=
getString
(
R
.
string
.
deck_share_head
)
+
" "
+
uri
;
ShareUtil
.
shareText
(
this
,
getString
(
R
.
string
.
share_deck
),
url
,
null
);
ClipboardManager
clipboardManager
=
(
ClipboardManager
)
getSystemService
(
CLIPBOARD_SERVICE
);
if
(
Build
.
VERSION
.
SDK_INT
>
19
)
{
clipboardManager
.
setPrimaryClip
(
ClipData
.
newPlainText
(
label
,
uri
));
}
else
{
clipboardManager
.
setText
(
uri
);
}
showToast
(
R
.
string
.
copy_to_clipbroad
,
Toast
.
LENGTH_SHORT
);
}
private
File
getSelectDeck
(
Spinner
spinner
)
{
Object
o
=
SimpleSpinnerAdapter
.
getSelectTag
(
spinner
);
if
(
o
!=
null
&&
o
instanceof
File
)
{
return
(
File
)
o
;
}
return
null
;
}
// private LimitList getSelectLimitList(Spinner spinner) {
// int val = (int) SimpleSpinnerAdapter.getSelect(spinner);
// if (val > 0) {
// return mLimitManager.getLimit(val);
// }
// return null;
// }
private
List
<
File
>
getYdkFiles
()
{
File
dir
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
);
File
[]
files
=
dir
.
listFiles
((
file
,
s
)
->
{
return
s
.
toLowerCase
(
Locale
.
US
).
endsWith
(
Constants
.
YDK_FILE_EX
);
});
if
(
files
!=
null
)
{
List
<
File
>
list
=
new
ArrayList
<>(
Arrays
.
asList
(
files
));
if
(
mPreLoadFile
!=
null
&&
mPreLoadFile
.
exists
())
{
boolean
hasCur
=
false
;
for
(
File
f
:
list
)
{
if
(
TextUtils
.
equals
(
f
.
getAbsolutePath
(),
mPreLoadFile
.
getAbsolutePath
()))
{
hasCur
=
true
;
break
;
}
}
if
(!
hasCur
)
{
list
.
add
(
mPreLoadFile
);
}
}
return
list
;
}
return
null
;
}
private
void
initDecksListSpinners
(
Spinner
spinner
,
File
curYdk
)
{
List
<
File
>
files
=
getYdkFiles
();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
String
name
=
curYdk
!=
null
?
curYdk
.
getName
()
:
null
;
int
index
=
-
1
;
if
(
files
!=
null
)
{
Collections
.
sort
(
files
,
new
Comparator
<
File
>()
{
@Override
public
int
compare
(
File
ydk1
,
File
ydk2
)
{
if
(
ydk1
.
isDirectory
()
&&
ydk2
.
isFile
())
return
-
1
;
if
(
ydk1
.
isFile
()
&&
ydk2
.
isDirectory
())
return
1
;
return
ydk1
.
getName
().
compareTo
(
ydk2
.
getName
());
}
});
int
i
=
0
;
for
(
File
file
:
files
)
{
if
(
name
!=
null
&&
TextUtils
.
equals
(
name
,
file
.
getName
()))
{
index
=
i
;
}
String
filename
=
IOUtils
.
tirmName
(
file
.
getName
(),
Constants
.
YDK_FILE_EX
);
items
.
add
(
new
SimpleSpinnerItem
(
i
++,
filename
).
setTag
(
file
));
}
}
mSimpleSpinnerAdapter
=
new
SimpleSpinnerAdapter
(
this
);
mSimpleSpinnerAdapter
.
set
(
items
);
mSimpleSpinnerAdapter
.
setColor
(
Color
.
WHITE
);
mSimpleSpinnerAdapter
.
setSingleLine
(
true
);
spinner
.
setAdapter
(
mSimpleSpinnerAdapter
);
if
(
index
>=
0
)
{
spinner
.
setSelection
(
index
);
}
}
// private void initLimitListSpinners(Spinner spinner) {
// List<SimpleSpinnerItem> items = new ArrayList<>();
// List<Integer> ids = mLimitManager.getLists();
// int index = -1;
// int i = 0;
// for (Integer id : ids) {
// LimitList list = mLimitManager.getLimitFromIndex(id);
// if (list == mLimitList) {
// index = i;
// }
// items.add(new SimpleSpinnerItem(id, list.getName()));
// i++;
// }
// SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(this);
// adapter.set(items);
// spinner.setAdapter(adapter);
// if (index >= 0) {
// spinner.setSelection(index);
// }
private
void
initLimitListSpinners
(
Spinner
spinner
,
LimitList
cur
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
String
>
limitLists
=
mLimitManager
.
getLimitNames
();
int
index
=
-
1
;
int
count
=
mLimitManager
.
getCount
();
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_limitlist
)));
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
int
j
=
i
+
1
;
String
name
=
limitLists
.
get
(
i
);
items
.
add
(
new
SimpleSpinnerItem
(
j
,
name
));
if
(
cur
!=
null
&&
TextUtils
.
equals
(
cur
.
getName
(),
name
))
{
index
=
j
;
}
}
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
adapter
.
setColor
(
Color
.
WHITE
);
adapter
.
set
(
items
);
spinner
.
setAdapter
(
adapter
);
if
(
index
>=
0
)
{
spinner
.
setSelection
(
index
);
}
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
setLimitList
(
mLimitManager
.
getLimit
(
SimpleSpinnerAdapter
.
getSelectText
(
spinner
)));
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
}
private
void
setLimitList
(
LimitList
limitList
)
{
if
(
limitList
==
null
)
return
;
LimitList
last
=
mDeckAdapater
.
getLimitList
();
boolean
nochanged
=
last
!=
null
&&
TextUtils
.
equals
(
last
.
getName
(),
limitList
.
getName
());
if
(!
nochanged
)
{
mDeckAdapater
.
setLimitList
(
limitList
);
runOnUiThread
(()
->
{
mDeckAdapater
.
notifyItemRangeChanged
(
DeckItem
.
MainStart
,
DeckItem
.
MainEnd
);
mDeckAdapater
.
notifyItemRangeChanged
(
DeckItem
.
ExtraStart
,
DeckItem
.
ExtraEnd
);
mDeckAdapater
.
notifyItemRangeChanged
(
DeckItem
.
SideStart
,
DeckItem
.
SideEnd
);
});
}
mCardListAdapater
.
setLimitList
(
limitList
);
runOnUiThread
(()
->
{
mCardListAdapater
.
notifyDataSetChanged
();
});
}
private
void
inputDeckName
(
File
oldYdk
,
String
savePath
,
boolean
keepOld
)
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
intpu_name
);
EditText
editText
=
new
EditText
(
this
);
editText
.
setGravity
(
Gravity
.
TOP
|
Gravity
.
LEFT
);
editText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_NO_SUGGESTIONS
);
editText
.
setSingleLine
();
if
(
oldYdk
!=
null
)
{
editText
.
setText
(
oldYdk
.
getName
());
}
builder
.
setContentView
(
editText
);
builder
.
setOnCloseLinster
((
dlg
)
->
{
dlg
.
dismiss
();
});
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
CharSequence
name
=
editText
.
getText
();
if
(!
TextUtils
.
isEmpty
(
name
))
{
String
filename
=
String
.
valueOf
(
name
);
if
(!
filename
.
endsWith
(
YDK_FILE_EX
))
{
filename
+=
YDK_FILE_EX
;
}
File
ydk
;
if
(
TextUtils
.
isEmpty
(
savePath
))
ydk
=
new
File
(
mSettings
.
getDeckDir
(),
filename
);
else
ydk
=
new
File
(
savePath
,
filename
);
if
(
ydk
.
exists
())
{
showToast
(
R
.
string
.
file_exist
,
Toast
.
LENGTH_SHORT
);
return
;
}
if
(!
keepOld
&&
oldYdk
!=
null
&&
oldYdk
.
exists
())
{
if
(
oldYdk
.
renameTo
(
ydk
))
{
initDecksListSpinners
(
mDeckSpinner
,
ydk
);
dlg
.
dismiss
();
loadDeckFromFile
(
ydk
);
}
}
else
{
if
(
oldYdk
==
mPreLoadFile
)
{
mPreLoadFile
=
null
;
}
dlg
.
dismiss
();
try
{
ydk
.
createNewFile
();
}
catch
(
IOException
e
)
{
}
initDecksListSpinners
(
mDeckSpinner
,
ydk
);
save
(
ydk
);
loadDeckFromFile
(
ydk
);
}
}
else
{
dlg
.
dismiss
();
}
});
builder
.
show
();
}
private
void
save
(
File
ydk
)
{
if
(
mDeckAdapater
.
save
(
ydk
))
{
showToast
(
R
.
string
.
save_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
save_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
}
private
void
initBoomMenuButton
(
BoomMenuButton
menu
)
{
final
SparseArray
<
Integer
>
mMenuIds
=
new
SparseArray
<>();
// addMenuButton(mMenuIds, menu, R.id.action_card_search, R.string.deck_list, R.drawable.listicon);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_share_deck
,
R
.
string
.
share_deck
,
R
.
drawable
.
shareicon
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_save
,
R
.
string
.
save_deck
,
R
.
drawable
.
save
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_clear_deck
,
R
.
string
.
clear_deck
,
R
.
drawable
.
clear_deck
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_deck_new
,
R
.
string
.
new_deck
,
R
.
drawable
.
addsever
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_rename
,
R
.
string
.
rename_deck
,
R
.
drawable
.
rename
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_delete_deck
,
R
.
string
.
delete_deck
,
R
.
drawable
.
delete
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_unsort
,
R
.
string
.
unsort
,
R
.
drawable
.
unsort
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_sort
,
R
.
string
.
sort
,
R
.
drawable
.
sort
);
addMenuButton
(
mMenuIds
,
menu
,
R
.
id
.
action_deck_backup_n_restore
,
R
.
string
.
deck_backup_n_restore
,
R
.
drawable
.
downloadimages
);
//设置展开或隐藏的延时。 默认值为 800ms。
menu
.
setDuration
(
150
);
//设置每两个子按钮之间动画的延时(ms为单位)。 比如,如果延时设为0,那么所有子按钮都会同时展开或隐藏,默认值为100ms。
menu
.
setDelay
(
10
);
menu
.
setOnBoomListener
(
new
DefaultOnBoomListener
()
{
@Override
public
void
onClicked
(
int
index
,
BoomButton
boomButton
)
{
doMenu
(
mMenuIds
.
get
(
index
));
}
});
}
private
void
addMenuButton
(
SparseArray
<
Integer
>
mMenuIds
,
BoomMenuButton
menuButton
,
int
menuId
,
int
stringId
,
int
image
)
{
addMenuButton
(
mMenuIds
,
menuButton
,
menuId
,
getString
(
stringId
),
image
);
}
private
void
addMenuButton
(
SparseArray
<
Integer
>
mMenuIds
,
BoomMenuButton
menuButton
,
int
menuId
,
String
str
,
int
image
)
{
TextOutsideCircleButton
.
Builder
builder
=
new
TextOutsideCircleButton
.
Builder
()
.
shadowColor
(
Color
.
TRANSPARENT
)
.
normalColor
(
Color
.
TRANSPARENT
)
.
normalImageRes
(
image
)
.
normalText
(
str
);
menuButton
.
addBuilder
(
builder
);
mMenuIds
.
put
(
mMenuIds
.
size
(),
menuId
);
}
private
void
doBackUpDeck
()
{
try
{
FileUtils
.
copyDir
(
mSettings
.
getDeckDir
(),
ORI_DECK
,
true
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
();
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
();
}
private
void
doRestoreDeck
()
{
try
{
FileUtils
.
copyDir
(
ORI_DECK
,
mSettings
.
getDeckDir
(),
false
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
();
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onDeckSelect
(
DeckFile
deckFile
)
{
loadDeckFromFile
(
new
File
(
deckFile
.
getPath
()));
}
@Override
public
void
onDeckDel
(
List
<
DeckFile
>
deckFileList
)
{
File
deck
=
mDeckAdapater
.
getYdkFile
();
if
(
deck
==
null
)
return
;
String
currentDeckPath
=
deck
.
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
();
if
(
currentDeckPath
!=
null
)
{
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/cards/DeckManagerActivityImpl2.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.CheckBox
;
import
android.widget.CompoundButton
;
import
android.widget.EditText
;
import
android.widget.Spinner
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.ActionBarDrawerToggle
;
import
androidx.appcompat.widget.AppCompatSpinner
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
androidx.recyclerview.widget.FastScrollLinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.bumptech.glide.Glide
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.bean.events.CardInfoEvent
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.CardLoader
;
import
cn.garymb.ygomobile.loader.DeckLoader
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.adapters.CardListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckUtils
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.widget.DeckGroupView
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.LimitType
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
YDK_FILE_EX
;
class
DeckManagerActivityImpl2
extends
BaseActivity
implements
CardLoader
.
CallBack
{
private
DeckGroupView
mDeckView
;
protected
CardSearcher
mCardSelector
;
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
private
String
mPreLoad
;
private
LimitList
mLimitList
;
private
File
mYdkFile
;
private
ImageLoader
mImageLoader
;
private
AppsSettings
mSettings
=
AppsSettings
.
get
();
private
AppCompatSpinner
mLimitSpinner
;
private
AppCompatSpinner
mDeckSpinner
;
private
SimpleSpinnerAdapter
mSimpleSpinnerAdapter
;
protected
DrawerLayout
mDrawerlayout
;
private
RecyclerView
mListView
;
protected
CardListAdapter
mCardListAdapater
;
private
String
mDeckMd5
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_deck_cards2
);
Toolbar
toolbar
=
$
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
enableBackHome
();
mLimitSpinner
=
$
(
R
.
id
.
sp_limit_list
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
mDeckView
=
$
(
R
.
id
.
deck_group
);
mDrawerlayout
=
$
(
R
.
id
.
drawer_layout
);
mImageLoader
=
ImageLoader
.
get
(
this
);
mCardLoader
=
new
CardLoader
(
this
);
mCardLoader
.
setCallBack
(
this
);
mCardSelector
=
new
CardSearcher
(
$
(
R
.
id
.
nav_view_list
),
mCardLoader
);
mListView
=
$
(
R
.
id
.
list_cards
);
mCardListAdapater
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdapater
.
setEnableSwipe
(
true
);
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setAdapter
(
mCardListAdapater
);
setListeners
();
//
ActionBarDrawerToggle
toggle
=
new
ActionBarDrawerToggle
(
this
,
mDrawerlayout
,
toolbar
,
R
.
string
.
search_open
,
R
.
string
.
search_close
);
toggle
.
setDrawerIndicatorEnabled
(
false
);
mDrawerlayout
.
addDrawerListener
(
toggle
);
toggle
.
setToolbarNavigationClickListener
((
v
)
->
{
onBackHome
();
});
toggle
.
syncState
();
mDeckSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
adapterView
,
View
view
,
int
i
,
long
l
)
{
File
file
=
getSelectDeck
(
mDeckSpinner
);
if
(
file
!=
null
)
{
loadDeck
(
file
);
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
adapterView
)
{
}
});
if
(
getIntent
().
hasExtra
(
Intent
.
EXTRA_TEXT
))
{
String
path
=
getIntent
().
getStringExtra
(
Intent
.
EXTRA_TEXT
);
if
(!
TextUtils
.
isEmpty
(
path
))
{
mPreLoad
=
path
;
}
}
View
btnDel
=
$
(
R
.
id
.
btn_delete
);
CheckBox
checkBox
=
$
(
R
.
id
.
chk_autosort
);
mDeckView
.
setAutoSort
(
checkBox
.
isChecked
());
checkBox
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
boolean
isChecked
)
{
mDeckView
.
setAutoSort
(
isChecked
);
}
});
$
(
R
.
id
.
btn_edit_delete
).
setOnClickListener
(
v
->
{
if
(
mDeckView
.
getEditMode
()
!=
DeckGroupView
.
EditMode
.
None
)
{
mDeckView
.
setEditMode
(
DeckGroupView
.
EditMode
.
None
);
btnDel
.
setEnabled
(
false
);
}
else
{
mDeckView
.
setEditMode
(
DeckGroupView
.
EditMode
.
Delete
);
btnDel
.
setEnabled
(
true
);
}
});
$
(
R
.
id
.
btn_edit_main2side
).
setOnClickListener
(
v
->
{
if
(
mDeckView
.
getEditMode
()
!=
DeckGroupView
.
EditMode
.
None
)
{
mDeckView
.
setEditMode
(
DeckGroupView
.
EditMode
.
None
);
btnDel
.
setEnabled
(
false
);
}
else
{
mDeckView
.
setEditMode
(
DeckGroupView
.
EditMode
.
Main2Side
);
btnDel
.
setEnabled
(
true
);
}
});
$
(
R
.
id
.
btn_edit_side2main
).
setOnClickListener
(
v
->
{
if
(
mDeckView
.
getEditMode
()
!=
DeckGroupView
.
EditMode
.
None
)
{
mDeckView
.
setEditMode
(
DeckGroupView
.
EditMode
.
None
);
btnDel
.
setEnabled
(
false
);
}
else
{
mDeckView
.
setEditMode
(
DeckGroupView
.
EditMode
.
Side2Main
);
btnDel
.
setEnabled
(
true
);
}
});
btnDel
.
setOnClickListener
((
v
)
->
{
if
(
mDeckView
.
getEditMode
()
!=
DeckGroupView
.
EditMode
.
None
)
{
mDeckView
.
completedEdit
();
mDeckView
.
notifyDataSetChanged
();
}
});
EventBus
.
getDefault
().
register
(
this
);
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
DataManager
.
get
().
load
(
false
);
if
(
mLimitManager
.
getCount
()
>
0
)
{
mCardLoader
.
setLimitList
(
mLimitManager
.
getTopLimit
());
}
File
file
=
new
File
(
mSettings
.
getLastDeckPath
());
if
(!
TextUtils
.
isEmpty
(
mPreLoad
))
{
file
=
new
File
(
mPreLoad
);
mPreLoad
=
null
;
}
if
(!
file
.
exists
())
{
//当默认卡组不存在的时候
File
[]
files
=
getYdkFiles
();
if
(
files
!=
null
&&
files
.
length
>
0
)
{
file
=
files
[
0
];
}
}
//EXTRA_DECK
if
(
file
==
null
)
{
return
new
DeckInfo
();
}
mYdkFile
=
file
;
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
DeckLoader
.
readDeck
(
mCardLoader
,
file
,
mLimitList
);
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
isLoad
=
true
;
dlg
.
dismiss
();
mCardSelector
.
initItems
();
mLimitList
=
mCardLoader
.
getLimitList
();
isLoad
=
true
;
setCurYdkFile
(
mYdkFile
,
false
);
initLimitListSpinners
(
mLimitSpinner
);
initDecksListSpinners
(
mDeckSpinner
);
mDeckView
.
setDeck
(
rs
);
mDeckMd5
=
rs
.
makeMd5
();
mDeckView
.
notifyDataSetChanged
();
});
}
@Override
protected
void
onDestroy
()
{
ImageLoader
.
onDestory
(
this
);
EventBus
.
getDefault
().
unregister
(
this
);
super
.
onDestroy
();
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
onCardInfoEvent
(
CardInfoEvent
event
)
{
int
pos
=
event
.
position
;
Card
cardInfo
=
mCardListAdapater
.
getItem
(
pos
);
if
(
cardInfo
==
null
)
{
mCardListAdapater
.
hideMenu
(
null
);
}
else
if
(
event
.
toMain
)
{
if
(!
addMainCard
(
cardInfo
))
{
// || !checkLimit(cardInfo, false)) {
mCardListAdapater
.
hideMenu
(
null
);
}
}
else
{
if
(!
addSideCard
(
cardInfo
))
{
// || !checkLimit(cardInfo, false)) {
mCardListAdapater
.
hideMenu
(
null
);
}
}
}
private
File
getSelectDeck
(
Spinner
spinner
)
{
Object
o
=
SimpleSpinnerAdapter
.
getSelectTag
(
spinner
);
if
(
o
!=
null
&&
o
instanceof
File
)
{
return
(
File
)
o
;
}
return
null
;
}
private
void
loadDeck
(
File
file
)
{
loadDeck
(
file
,
false
);
}
private
void
loadDeck
(
File
file
,
boolean
noSaveLast
)
{
DialogPlus
dlg
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
loading
));
VUiKit
.
defer
().
when
(()
->
{
if
(
file
==
null
)
{
return
new
DeckInfo
();
}
if
(
mCardLoader
.
isOpen
()
&&
file
.
exists
())
{
return
DeckLoader
.
readDeck
(
mCardLoader
,
file
,
mLimitList
);
}
else
{
return
new
DeckInfo
();
}
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
setCurYdkFile
(
file
,
noSaveLast
);
mDeckView
.
setDeck
(
rs
);
mDeckMd5
=
rs
.
makeMd5
();
mDeckView
.
notifyDataSetChanged
();
});
}
private
void
initDecksListSpinners
(
Spinner
spinner
)
{
File
[]
files
=
getYdkFiles
();
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
String
name
=
mYdkFile
!=
null
?
mYdkFile
.
getName
()
:
null
;
int
index
=
-
1
;
if
(
files
!=
null
)
{
int
i
=
0
;
for
(
File
file
:
files
)
{
if
(
name
!=
null
&&
TextUtils
.
equals
(
name
,
file
.
getName
()))
{
index
=
i
;
}
String
filename
=
IOUtils
.
tirmName
(
file
.
getName
(),
YDK_FILE_EX
);
items
.
add
(
new
SimpleSpinnerItem
(
i
++,
filename
).
setTag
(
file
));
}
}
mSimpleSpinnerAdapter
=
new
SimpleSpinnerAdapter
(
this
);
mSimpleSpinnerAdapter
.
set
(
items
);
mSimpleSpinnerAdapter
.
setColor
(
Color
.
WHITE
);
mSimpleSpinnerAdapter
.
setSingleLine
(
true
);
spinner
.
setAdapter
(
mSimpleSpinnerAdapter
);
if
(
index
>=
0
)
{
spinner
.
setSelection
(
index
);
}
}
private
void
initLimitListSpinners
(
Spinner
spinner
)
{
List
<
SimpleSpinnerItem
>
items
=
new
ArrayList
<>();
List
<
String
>
limitLists
=
mLimitManager
.
getLimitNames
();
int
index
=
-
1
;
int
count
=
mLimitManager
.
getCount
();
LimitList
cur
=
mLimitList
;
items
.
add
(
new
SimpleSpinnerItem
(
0
,
getString
(
R
.
string
.
label_limitlist
)));
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
int
j
=
i
+
1
;
String
name
=
limitLists
.
get
(
i
);
items
.
add
(
new
SimpleSpinnerItem
(
j
,
name
));
if
(
cur
!=
null
&&
TextUtils
.
equals
(
cur
.
getName
(),
name
))
{
index
=
j
;
}
}
SimpleSpinnerAdapter
adapter
=
new
SimpleSpinnerAdapter
(
this
);
adapter
.
setColor
(
Color
.
WHITE
);
adapter
.
set
(
items
);
spinner
.
setAdapter
(
adapter
);
if
(
index
>=
0
)
{
spinner
.
setSelection
(
index
);
}
spinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
setLimitList
(
mLimitManager
.
getLimit
(
SimpleSpinnerAdapter
.
getSelectText
(
spinner
)));
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
}
private
void
setLimitList
(
LimitList
limitList
)
{
if
(
limitList
==
null
)
return
;
boolean
nochanged
=
mLimitList
!=
null
&&
TextUtils
.
equals
(
mLimitList
.
getName
(),
limitList
.
getName
());
mLimitList
=
limitList
;
mDeckView
.
setLimitList
(
limitList
);
runOnUiThread
(()
->
{
mDeckView
.
notifyDataSetChanged
();
});
}
private
void
setCurYdkFile
(
File
file
)
{
setCurYdkFile
(
file
,
false
);
}
private
void
setCurYdkFile
(
File
file
,
boolean
noSaveLast
)
{
mYdkFile
=
file
;
if
(
file
!=
null
&&
file
.
exists
())
{
String
name
=
IOUtils
.
tirmName
(
file
.
getName
(),
YDK_FILE_EX
);
setActionBarSubTitle
(
name
);
if
(!
noSaveLast
)
{
mSettings
.
setLastDeckPath
(
file
.
getAbsolutePath
());
}
}
else
{
setActionBarSubTitle
(
getString
(
R
.
string
.
noname
));
}
}
private
File
[]
getYdkFiles
()
{
File
dir
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
);
File
[]
files
=
dir
.
listFiles
((
file
,
s
)
->
{
return
s
.
toLowerCase
(
Locale
.
US
).
endsWith
(
YDK_FILE_EX
);
});
return
files
;
}
@Override
public
void
onSearchStart
()
{
hideDrawers
();
}
@Override
public
void
onLimitListChanged
(
LimitList
limitList
)
{
}
@Override
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
mCardListAdapater
.
set
(
cardInfos
);
mCardListAdapater
.
notifyDataSetChanged
();
if
(
cardInfos
!=
null
&&
cardInfos
.
size
()
>
0
)
{
mListView
.
smoothScrollToPosition
(
0
);
}
showResult
(
false
);
}
@Override
public
void
onResetSearch
()
{
}
@Override
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
getMenuInflater
().
inflate
(
R
.
menu
.
deck_menu
,
menu
);
return
true
;
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
// case R.id.action_refresh:
// mDeckAdapater.notifyDataSetChanged();
// break;
case
R
.
id
.
action_search
:
//弹条件对话框
showSearch
(
true
);
break
;
case
R
.
id
.
action_card_list
:
showResult
(
true
);
break
;
case
R
.
id
.
action_save
:
if
(
mYdkFile
==
null
)
{
inputDeckName
(
null
);
}
else
{
save
();
}
break
;
case
R
.
id
.
action_rename
:
inputDeckName
(
null
);
break
;
case
R
.
id
.
action_deck_new
:
{
final
String
old
=
mYdkFile
==
null
?
null
:
mYdkFile
.
getAbsolutePath
();
setCurYdkFile
(
null
);
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
);
});
builder
.
setRightButtonListener
((
dlg
,
rs
)
->
{
dlg
.
dismiss
();
loadDeck
(
null
);
inputDeckName
(
old
);
});
builder
.
setOnCloseLinster
((
dlg
)
->
{
dlg
.
dismiss
();
loadDeck
(
null
);
inputDeckName
(
old
);
});
builder
.
show
();
}
break
;
case
R
.
id
.
action_clear_deck
:
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_clear_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
mDeckView
.
setDeck
(
new
DeckInfo
());
mDeckMd5
=
mDeckView
.
getDeckInfo
().
makeMd5
();
mDeckView
.
notifyDataSetChanged
();
dlg
.
dismiss
();
});
builder
.
show
();
}
break
;
case
R
.
id
.
action_delete_deck
:
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_delete_deck
);
builder
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
builder
.
setLeftButtonListener
((
dlg
,
rs
)
->
{
if
(
mYdkFile
!=
null
&&
mYdkFile
.
exists
())
{
mYdkFile
.
delete
();
}
dlg
.
dismiss
();
initDecksListSpinners
(
mDeckSpinner
);
loadDeck
(
null
);
});
builder
.
show
();
}
break
;
case
R
.
id
.
action_unsort
:
//打乱
mDeckView
.
unSort
();
mDeckView
.
notifyDataSetChanged
();
break
;
case
R
.
id
.
action_sort
:
mDeckView
.
sort
();
mDeckView
.
notifyDataSetChanged
();
break
;
}
return
super
.
onOptionsItemSelected
(
item
);
}
private
void
shareDeck
()
{
// DeckUtils.save(mDeckView.getDeckInfo(), mYdkFile);
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
// final String uriString = deck.toAppUri().toString();
// final String httpUri = deck.toHttpUri().toString();
// shareUrl(uriString, label);
}
private
void
shareUrl
(
String
uri
,
String
label
)
{
String
url
=
getString
(
R
.
string
.
deck_share_head
)
+
" "
+
uri
;
ShareUtil
.
shareText
(
this
,
getString
(
R
.
string
.
share_deck
),
url
,
null
);
ClipboardManager
clipboardManager
=
(
ClipboardManager
)
getSystemService
(
CLIPBOARD_SERVICE
);
if
(
Build
.
VERSION
.
SDK_INT
>
19
)
{
clipboardManager
.
setPrimaryClip
(
ClipData
.
newPlainText
(
label
,
uri
));
}
else
{
clipboardManager
.
setText
(
uri
);
}
showToast
(
R
.
string
.
copy_to_clipbroad
,
Toast
.
LENGTH_SHORT
);
}
private
void
inputDeckName
(
String
old
)
{
DialogPlus
builder
=
new
DialogPlus
(
this
);
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.
setTitle
(
R
.
string
.
intpu_name
);
EditText
editText
=
new
EditText
(
this
);
editText
.
setGravity
(
Gravity
.
TOP
|
Gravity
.
LEFT
);
editText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_NO_SUGGESTIONS
);
editText
.
setSingleLine
();
if
(
mYdkFile
!=
null
)
{
editText
.
setText
(
mYdkFile
.
getName
());
}
builder
.
setContentView
(
editText
);
builder
.
setOnCloseLinster
((
dlg
)
->
{
dlg
.
dismiss
();
if
(
old
!=
null
)
{
loadDeck
(
new
File
(
old
));
}
});
builder
.
setLeftButtonListener
((
dlg
,
s
)
->
{
CharSequence
name
=
editText
.
getText
();
if
(!
TextUtils
.
isEmpty
(
name
))
{
String
filename
=
String
.
valueOf
(
name
);
if
(!
filename
.
endsWith
(
YDK_FILE_EX
))
{
filename
+=
YDK_FILE_EX
;
}
File
ydk
=
new
File
(
mSettings
.
getResourcePath
(),
Constants
.
CORE_DECK_PATH
+
"/"
+
filename
);
if
(
ydk
.
exists
())
{
showToast
(
R
.
string
.
file_exist
,
Toast
.
LENGTH_SHORT
);
return
;
}
if
(
mYdkFile
!=
null
&&
mYdkFile
.
exists
())
{
if
(
mYdkFile
.
renameTo
(
ydk
))
{
mYdkFile
=
ydk
;
initDecksListSpinners
(
mDeckSpinner
);
dlg
.
dismiss
();
loadDeck
(
ydk
);
}
}
else
{
dlg
.
dismiss
();
try
{
ydk
.
createNewFile
();
}
catch
(
IOException
e
)
{
}
mYdkFile
=
ydk
;
initDecksListSpinners
(
mDeckSpinner
);
save
();
setCurYdkFile
(
mYdkFile
);
}
}
else
{
dlg
.
dismiss
();
}
});
builder
.
show
();
}
private
void
save
()
{
mDeckMd5
=
mDeckView
.
getDeckInfo
().
makeMd5
();
//保存了,记录状态
if
(
DeckUtils
.
save
(
mDeckView
.
getDeckInfo
(),
mYdkFile
))
{
showToast
(
R
.
string
.
save_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
save_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
}
protected
void
showSearch
(
boolean
autoclose
)
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerlayout
.
closeDrawer
(
Gravity
.
LEFT
);
}
if
(
autoclose
&&
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerlayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
else
if
(
isLoad
)
{
mDrawerlayout
.
openDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
}
protected
void
showResult
(
boolean
autoclose
)
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerlayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
}
if
(
autoclose
&&
mDrawerlayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerlayout
.
closeDrawer
(
Gravity
.
LEFT
);
}
else
if
(
isLoad
)
{
mDrawerlayout
.
openDrawer
(
Gravity
.
LEFT
);
}
}
protected
void
onCardClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
if
(
mCardListAdapater
.
isShowMenu
(
view
))
{
return
;
}
if
(
cardInfo
!=
null
)
{
//TODO 显示详情
}
}
protected
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
// mCardListAdapater.showMenu(view);
}
protected
void
hideDrawers
()
{
if
(
mDrawerlayout
.
isDrawerOpen
(
Gravity
.
RIGHT
))
{
mDrawerlayout
.
closeDrawer
(
Gravity
.
RIGHT
);
}
if
(
mDrawerlayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerlayout
.
closeDrawer
(
Gravity
.
LEFT
);
}
}
protected
void
setListeners
()
{
mListView
.
addOnItemTouchListener
(
new
RecyclerViewItemListener
(
mListView
,
new
RecyclerViewItemListener
.
OnItemListener
()
{
@Override
public
void
onItemClick
(
View
view
,
int
pos
)
{
onCardClick
(
view
,
mCardListAdapater
.
getItem
(
pos
),
pos
);
}
@Override
public
void
onItemLongClick
(
View
view
,
int
pos
)
{
onCardLongClick
(
view
,
mCardListAdapater
.
getItem
(
pos
),
pos
);
}
@Override
public
void
onItemDoubleClick
(
View
view
,
int
pos
)
{
}
}));
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
@Override
public
void
onScrollStateChanged
(
RecyclerView
recyclerView
,
int
newState
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
switch
(
newState
)
{
case
RecyclerView
.
SCROLL_STATE_IDLE
:
Glide
.
with
(
getContext
()).
resumeRequests
();
break
;
case
RecyclerView
.
SCROLL_STATE_DRAGGING
:
Glide
.
with
(
getContext
()).
pauseRequests
();
break
;
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
Glide
.
with
(
getContext
()).
resumeRequests
();
break
;
}
}
});
}
private
boolean
checkLimit
(
Card
cardInfo
,
boolean
tip
)
{
int
count
=
mDeckView
.
getDeckInfo
().
getCardUseCount
(
cardInfo
.
Code
);
if
(
mLimitList
!=
null
&&
mLimitList
.
check
(
cardInfo
,
LimitType
.
Forbidden
))
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
0
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
if
(
mLimitList
!=
null
&&
mLimitList
.
check
(
cardInfo
,
LimitType
.
Limit
))
{
if
(
count
>=
1
)
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
1
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
}
else
if
(
mLimitList
!=
null
&&
mLimitList
.
check
(
cardInfo
,
LimitType
.
SemiLimit
))
{
if
(
count
>=
2
)
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
2
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
if
(
tip
)
{
showToast
(
getString
(
R
.
string
.
tip_card_max
,
3
),
Toast
.
LENGTH_SHORT
);
}
return
false
;
}
return
true
;
}
private
boolean
addSideCard
(
Card
cardInfo
)
{
if
(
checkLimit
(
cardInfo
,
true
))
{
boolean
rs
=
mDeckView
.
addSideCards
(
cardInfo
);
if
(
rs
)
{
showToast
(
R
.
string
.
add_card_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
add_card_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
return
rs
;
}
return
false
;
}
private
boolean
addMainCard
(
Card
cardInfo
)
{
if
(
checkLimit
(
cardInfo
,
true
))
{
boolean
rs
;
if
(
cardInfo
.
isExtraCard
())
{
rs
=
mDeckView
.
addExtraCards
(
cardInfo
);
}
else
{
rs
=
mDeckView
.
addMainCards
(
cardInfo
);
}
if
(
rs
)
{
showToast
(
R
.
string
.
add_card_tip_ok
,
Toast
.
LENGTH_SHORT
);
}
else
{
showToast
(
R
.
string
.
add_card_tip_fail
,
Toast
.
LENGTH_SHORT
);
}
return
rs
;
}
return
false
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckAdapter.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards.deck2
;
import
android.content.Context
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.recyclerview.widget.ItemTouchHelperPlus
;
import
androidx.recyclerview.widget.OnItemDragListener
;
import
androidx.recyclerview.widget.RecyclerView
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
ocgcore.data.Card
;
import
static
cn
.
garymb
.
ygomobile
.
bean
.
DeckInfo
.
Type
.
Extra
;
import
static
cn
.
garymb
.
ygomobile
.
bean
.
DeckInfo
.
Type
.
Main
;
import
static
cn
.
garymb
.
ygomobile
.
bean
.
DeckInfo
.
Type
.
Side
;
public
class
DeckAdapter
extends
RecyclerView
.
Adapter
<
DeckViewHolder
>
implements
IDeckLayout
{
private
final
Context
mContext
;
private
final
RecyclerView
mRecyclerView
;
private
final
LayoutInflater
mLayoutInflater
;
private
final
DeckLayoutManager
mDeckLayoutManager
;
private
int
mWidth
;
private
int
mHeight
;
private
int
mPWidth
;
private
final
DeckInfo
mDeckInfo
;
private
ImageLoader
mImageLoader
;
public
DeckAdapter
(
Context
context
,
RecyclerView
recyclerView
,
OnItemDragListener
listener
)
{
mDeckInfo
=
new
DeckInfo
();
mImageLoader
=
ImageLoader
.
get
(
context
);
mContext
=
context
;
mRecyclerView
=
recyclerView
;
mLayoutInflater
=
LayoutInflater
.
from
(
context
);
recyclerView
.
addItemDecoration
(
new
DeckItemDecoration
(
this
));
mDeckLayoutManager
=
new
DeckLayoutManager
(
getContext
(),
getLineLimitCount
(),
this
);
recyclerView
.
setLayoutManager
(
mDeckLayoutManager
);
DeckHelperCallback
deckHelperCallback
=
new
DeckHelperCallback
(
this
);
ItemTouchHelperPlus
touchHelper
=
new
ItemTouchHelperPlus
(
getContext
(),
deckHelperCallback
);
touchHelper
.
setEnableClickDrag
(
true
);
touchHelper
.
attachToRecyclerView
(
recyclerView
);
touchHelper
.
setItemDragListener
(
listener
);
deckHelperCallback
.
setItemTouchHelper
(
touchHelper
);
}
public
Context
getContext
()
{
return
mContext
;
}
@Override
public
DeckViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
View
view
=
mLayoutInflater
.
inflate
(
R
.
layout
.
item_deck_card2
,
parent
,
false
);
return
new
DeckViewHolder
(
view
);
}
@Override
public
int
getLineLimitCount
()
{
return
15
;
}
//region width/height
private
void
makeHeight
()
{
mWidth
=
getWidth10
();
mHeight
=
scaleHeight
(
mWidth
);
}
public
void
setDeckInfo
(
DeckInfo
deckInfo
)
{
mDeckInfo
.
update
(
deckInfo
);
}
@Override
public
int
getMaxWidth
()
{
if
(
mPWidth
==
0
)
{
mPWidth
=
mRecyclerView
.
getMeasuredWidth
()
-
mRecyclerView
.
getPaddingRight
()
-
mRecyclerView
.
getPaddingLeft
();
}
return
mPWidth
;
}
@Override
public
int
getWidth15
()
{
return
getMaxWidth
()
/
15
;
}
@Override
public
int
getWidth10
()
{
return
getMaxWidth
()
/
10
;
}
private
int
scaleHeight
(
int
width
)
{
return
Math
.
round
((
float
)
width
*
((
float
)
255
/
177
));
}
//endregion
//region count/limit
@Override
public
int
getMainCount
()
{
return
Math
.
max
(
31
,
getMainRealCount
());
}
public
int
getMainRealCount
()
{
return
mDeckInfo
.
getMainCount
();
}
@Override
public
int
getExtraCount
()
{
return
Math
.
max
(
1
,
getExtraRealCount
());
}
public
int
getExtraRealCount
()
{
return
mDeckInfo
.
getExtraCount
();
}
@Override
public
int
getSideCount
()
{
return
Math
.
max
(
1
,
getSideRealCount
());
}
public
int
getSideRealCount
()
{
return
mDeckInfo
.
getSideCount
();
}
@Override
public
int
getMainLimit
()
{
return
Math
.
max
(
10
,
(
int
)
Math
.
ceil
(
getMainCount
()
/
4.0f
));
}
@Override
public
int
getExtraLimit
()
{
return
Math
.
max
(
getLineCardCount
(),
getExtraCount
());
}
@Override
public
int
getSideLimit
()
{
return
Math
.
max
(
getLineCardCount
(),
getSideCount
());
}
//endregion
//region index
@Override
public
boolean
isMain
(
int
pos
)
{
return
pos
>=
getMainStart
()
&&
pos
<=
getMainEnd
();
}
@Override
public
boolean
isExtra
(
int
pos
)
{
return
pos
>=
getExtraStart
()
&&
pos
<=
getExtraEnd
();
}
@Override
public
boolean
isSide
(
int
pos
)
{
return
pos
>=
getSideStart
()
&&
pos
<=
getSideEnd
();
}
@Override
public
boolean
isLabel
(
int
position
)
{
if
(
position
==
getMainLabel
()
||
position
==
getExtraLabel
()
||
position
==
getSideLabel
())
{
return
true
;
}
return
false
;
}
private
int
getMainLabel
()
{
return
0
;
}
private
int
getMainStart
()
{
return
getMainLabel
()
+
1
;
}
private
int
getMainEnd
()
{
return
getMainStart
()
+
getMainCount
()
-
1
;
}
private
int
getExtraLabel
()
{
return
getMainEnd
()
+
1
;
}
private
int
getExtraStart
()
{
return
getExtraLabel
()
+
1
;
}
private
int
getExtraEnd
()
{
return
getExtraStart
()
+
getExtraCount
()
-
1
;
}
private
int
getSideLabel
()
{
return
getExtraEnd
()
+
1
;
}
private
int
getSideStart
()
{
return
getSideLabel
()
+
1
;
}
private
int
getSideEnd
()
{
return
getSideStart
()
+
getSideCount
()
-
1
;
}
@Override
public
int
getMainIndex
(
int
pos
)
{
return
pos
-
getMainStart
();
}
@Override
public
int
getExtraIndex
(
int
pos
)
{
return
pos
-
getExtraStart
();
}
@Override
public
int
getSideIndex
(
int
pos
)
{
return
pos
-
getSideStart
();
}
//endregion
@Override
public
int
getItemCount
()
{
return
getMainCount
()
+
getExtraCount
()
+
getSideCount
()
+
3
;
}
@Override
public
int
getLineCardCount
()
{
return
10
;
}
@Override
public
void
onBindViewHolder
(
DeckViewHolder
holder
,
int
position
)
{
if
(
isLabel
(
position
))
{
if
(
position
==
getMainLabel
())
{
holder
.
setText
(
"main"
);
}
else
if
(
position
==
getExtraLabel
())
{
holder
.
setText
(
"extra"
);
}
else
if
(
position
==
getSideLabel
())
{
holder
.
setText
(
"side"
);
}
holder
.
setSize
(-
1
,
-
1
);
}
else
{
holder
.
showImage
();
if
(
mHeight
<=
0
)
{
makeHeight
();
}
holder
.
setSize
(
mWidth
,
mHeight
);
if
(
isMain
(
position
))
{
position
=
getMainIndex
(
position
);
if
(
position
>=
getMainRealCount
())
{
holder
.
empty
();
}
else
{
Card
card
=
mDeckInfo
.
getMainCard
(
position
);
if
(
card
==
null
)
{
holder
.
useDefault
();
}
else
{
mImageLoader
.
bindImage
(
holder
.
getCardImage
(),
card
.
Code
);
}
}
}
else
if
(
isExtra
(
position
))
{
position
=
getExtraIndex
(
position
);
if
(
position
>=
getExtraRealCount
())
{
holder
.
empty
();
}
else
{
Card
card
=
mDeckInfo
.
getExtraCard
(
position
);
if
(
card
==
null
)
{
holder
.
useDefault
();
}
else
{
mImageLoader
.
bindImage
(
holder
.
getCardImage
(),
card
.
Code
);
}
}
}
else
if
(
isSide
(
position
))
{
position
=
getSideIndex
(
position
);
if
(
position
>=
getSideRealCount
())
{
holder
.
empty
();
}
else
{
Card
card
=
mDeckInfo
.
getSideCard
(
position
);
if
(
card
==
null
)
{
holder
.
useDefault
();
}
else
{
mImageLoader
.
bindImage
(
holder
.
getCardImage
(),
card
.
Code
);
}
}
}
}
}
@Override
public
boolean
moveItem
(
int
from
,
int
to
)
{
if
(
isMain
(
from
))
{
if
(
isMain
(
to
))
{
int
pos
=
getMainIndex
(
to
);
if
(
pos
>=
getMainRealCount
())
{
to
=
getMainRealCount
()
-
1
+
getMainStart
();
}
mDeckInfo
.
move
(
Main
,
getMainIndex
(
from
),
getMainIndex
(
to
));
notifyItemMoved
(
from
,
to
);
return
true
;
}
if
(
isSide
(
to
))
{
//TODO check side
if
(
getSideRealCount
()
>=
Constants
.
DECK_SIDE_MAX
)
{
return
false
;
}
boolean
resize
=
getMainRealCount
()
%
4
==
1
;
Card
card
=
mDeckInfo
.
removeMain
(
getMainIndex
(
from
));
mDeckInfo
.
addSideCards
(
getSideIndex
(
to
),
card
);
Log
.
d
(
"kk"
,
"move main -> side "
+
getMainIndex
(
from
)
+
"->"
+
getSideIndex
(
to
));
notifyItemMoved
(
from
,
to
);
notifyItemRemoved
(
getSideEnd
());
notifyItemInserted
(
getMainEnd
());
notifyItemChanged
(
getMainLabel
());
notifyItemChanged
(
getSideLabel
());
if
(
resize
)
{
notifyItemRangeChanged
(
getMainStart
(),
getMainStart
()
+
getMainEnd
());
}
return
true
;
}
}
else
if
(
isExtra
(
from
))
{
if
(
isExtra
(
to
))
{
mDeckInfo
.
move
(
Extra
,
getExtraIndex
(
from
),
getExtraIndex
(
to
));
notifyItemMoved
(
from
,
to
);
return
true
;
}
if
(
isSide
(
to
))
{
//TODO check side
if
(
getSideRealCount
()
>=
Constants
.
DECK_SIDE_MAX
)
{
return
false
;
}
Card
card
=
mDeckInfo
.
removeExtra
(
getExtraIndex
(
from
));
mDeckInfo
.
addSideCards
(
getSideIndex
(
to
),
card
);
Log
.
d
(
"kk"
,
"move extra -> side "
+
getExtraIndex
(
from
)
+
"->"
+
getSideIndex
(
to
));
notifyItemMoved
(
from
,
to
);
notifyItemRemoved
(
getSideEnd
());
notifyItemInserted
(
getExtraEnd
());
notifyItemChanged
(
getExtraLabel
());
notifyItemChanged
(
getSideLabel
());
return
true
;
}
}
else
if
(
isSide
(
from
))
{
if
(
isSide
(
to
))
{
mDeckInfo
.
move
(
Side
,
getSideIndex
(
from
),
getSideIndex
(
to
));
notifyItemMoved
(
from
,
to
);
return
true
;
}
if
(
isExtra
(
to
))
{
//TODO check extra
if
(
getExtraRealCount
()
>=
Constants
.
DECK_EXTRA_MAX
)
{
return
false
;
}
Card
card
=
mDeckInfo
.
removeSide
(
getSideIndex
(
from
));
mDeckInfo
.
addExtraCards
(
getExtraIndex
(
to
),
card
);
Log
.
d
(
"kk"
,
"move side -> extra "
+
getSideIndex
(
from
)
+
"->"
+
getExtraIndex
(
to
));
notifyItemMoved
(
from
,
to
);
notifyItemRemoved
(
getExtraEnd
());
notifyItemInserted
(
getSideEnd
());
notifyItemChanged
(
getExtraLabel
());
notifyItemChanged
(
getSideLabel
());
return
true
;
}
if
(
isMain
(
to
))
{
//TODO check main
if
(
getMainRealCount
()
>=
Constants
.
DECK_MAIN_MAX
)
{
return
false
;
}
int
pos
=
getMainIndex
(
to
);
if
(
pos
>=
getMainRealCount
())
{
to
=
getMainRealCount
()
-
1
+
getMainStart
();
}
boolean
resize
=
getMainRealCount
()
%
4
==
0
;
Card
card
=
mDeckInfo
.
removeSide
(
getSideIndex
(
from
));
mDeckInfo
.
addMainCards
(
getMainIndex
(
to
),
card
);
Log
.
d
(
"kk"
,
"move side -> main "
+
getSideIndex
(
from
)
+
"->"
+
getMainIndex
(
to
));
notifyItemMoved
(
from
,
to
);
notifyItemRemoved
(
getMainEnd
());
notifyItemInserted
(
getSideEnd
());
notifyItemChanged
(
getMainLabel
());
notifyItemChanged
(
getSideLabel
());
if
(
resize
)
{
notifyItemRangeChanged
(
getMainStart
(),
getMainStart
()
+
getMainEnd
());
}
return
true
;
}
}
return
false
;
}
}
\ No newline at end of file
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckHelperCallback.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards.deck2
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.ItemTouchHelper
;
import
androidx.recyclerview.widget.ItemTouchHelperPlus
;
import
androidx.recyclerview.widget.RecyclerView
;
class
DeckHelperCallback
extends
ItemTouchHelperPlus
.
Callback2
{
private
IDeckLayout
mDeckAdapter
;
DeckHelperCallback
(
IDeckLayout
deckAdapter
)
{
mDeckAdapter
=
deckAdapter
;
}
private
boolean
isLabel
(
int
position
)
{
return
mDeckAdapter
.
isLabel
(
position
);
}
@Override
public
int
getMovementFlags
(
RecyclerView
recyclerView
,
RecyclerView
.
ViewHolder
viewHolder
)
{
int
id
=
viewHolder
.
getAdapterPosition
();
if
(
isLabel
(
id
))
{
return
makeMovementFlags
(
0
,
0
);
}
int
dragFlags
;
if
(
recyclerView
.
getLayoutManager
()
instanceof
GridLayoutManager
)
{
dragFlags
=
ItemTouchHelper
.
UP
|
ItemTouchHelper
.
DOWN
|
ItemTouchHelper
.
RIGHT
|
ItemTouchHelper
.
LEFT
;
}
else
{
dragFlags
=
ItemTouchHelper
.
UP
|
ItemTouchHelper
.
DOWN
;
}
return
makeMovementFlags
(
dragFlags
,
0
);
}
@Override
public
boolean
onMove
(
RecyclerView
recyclerView
,
RecyclerView
.
ViewHolder
viewHolder
,
RecyclerView
.
ViewHolder
target
)
{
return
mDeckAdapter
.
moveItem
(
viewHolder
.
getAdapterPosition
(),
target
.
getAdapterPosition
());
}
@Override
public
void
onSwiped
(
RecyclerView
.
ViewHolder
viewHolder
,
int
direction
)
{
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckItemDecoration.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards.deck2
;
import
android.graphics.Rect
;
import
android.view.View
;
import
androidx.recyclerview.widget.RecyclerView
;
class
DeckItemDecoration
extends
RecyclerView
.
ItemDecoration
{
private
IDeckLayout
mDeckLayout
;
DeckItemDecoration
(
IDeckLayout
deckLayout
)
{
mDeckLayout
=
deckLayout
;
}
@Override
public
void
getItemOffsets
(
Rect
outRect
,
View
view
,
RecyclerView
parent
,
RecyclerView
.
State
state
)
{
final
int
LINE_COUNT
=
mDeckLayout
.
getLineLimitCount
();
final
int
CARD_COUNT
=
mDeckLayout
.
getLineCardCount
();
int
position
=
((
RecyclerView
.
LayoutParams
)
view
.
getLayoutParams
()).
getViewLayoutPosition
();
if
(
mDeckLayout
.
isLabel
(
position
))
{
super
.
getItemOffsets
(
outRect
,
view
,
parent
,
state
);
return
;
}
float
w
=
mDeckLayout
.
getWidth10
()
-
mDeckLayout
.
getWidth15
();
int
limit
;
if
(
mDeckLayout
.
isMain
(
position
))
{
position
=
mDeckLayout
.
getMainIndex
(
position
);
limit
=
mDeckLayout
.
getMainLimit
();
}
else
if
(
mDeckLayout
.
isExtra
(
position
))
{
position
=
mDeckLayout
.
getExtraIndex
(
position
);
limit
=
mDeckLayout
.
getExtraLimit
();
//10
}
else
if
(
mDeckLayout
.
isSide
(
position
))
{
position
=
mDeckLayout
.
getSideIndex
(
position
);
limit
=
mDeckLayout
.
getSideLimit
();
//10
}
else
{
return
;
}
float
_w
=
w
/
(
limit
-
1.0f
);
float
w2
;
if
(
limit
<
LINE_COUNT
-
1
)
{
//10-13
w
=
mDeckLayout
.
getWidth15
()
*
(
LINE_COUNT
-
limit
);
w2
=
(
w
/
(
limit
-
1.0f
))
-
_w
;
}
else
if
(
limit
==
LINE_COUNT
-
1
)
{
//14
w
=
mDeckLayout
.
getWidth15
()
*
(
LINE_COUNT
-
limit
);
_w
=
_w
/
64.0f
*
65.0f
;
w2
=
(
w
/
(
limit
-
1.0f
))
-
_w
;
}
else
{
//15
w
=
mDeckLayout
.
getWidth15
()
*
(
LINE_COUNT
-
limit
);
_w
=
_w
/
32.0f
*
33.0f
;
w2
=
(
w
/
(
limit
-
1.0f
))
-
_w
;
}
int
linePos
=
position
%
limit
;
outRect
.
left
=
(
int
)
(
w2
*
linePos
);
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckLayoutManager.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards.deck2
;
import
android.content.Context
;
import
androidx.recyclerview.widget.GridLayoutManagerPlus
;
class
DeckLayoutManager
extends
GridLayoutManagerPlus
{
DeckLayoutManager
(
Context
context
,
final
int
span
,
final
IDeckLayout
deckAdapter
)
{
super
(
context
,
span
);
setSpanSizeLookup
(
new
SpanSizeLookup
()
{
@Override
public
int
getSpanSize
(
int
position
)
{
if
(
deckAdapter
.
isLabel
(
position
))
{
return
span
;
}
else
if
(
deckAdapter
.
isMain
(
position
))
{
position
=
deckAdapter
.
getMainIndex
(
position
);
int
limit
=
deckAdapter
.
getMainLimit
();
if
(
position
%
limit
==
(
limit
-
1
))
{
return
span
-
limit
+
1
;
}
}
else
if
(
deckAdapter
.
isExtra
(
position
))
{
position
=
deckAdapter
.
getExtraIndex
(
position
);
if
(
deckAdapter
.
getExtraCount
()
<
deckAdapter
.
getLineCardCount
())
{
if
(
position
==
deckAdapter
.
getExtraCount
()
-
1
)
{
return
deckAdapter
.
getLineCardCount
()
-
position
;
}
}
}
else
if
(
deckAdapter
.
isSide
(
position
))
{
}
return
1
;
}
});
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/DeckViewHolder.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards.deck2
;
import
android.graphics.Bitmap
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.GridLayoutManagerPlus
;
import
cn.garymb.ygomobile.lite.R
;
import
ocgcore.data.Card
;
class
DeckViewHolder
extends
GridLayoutManagerPlus
.
GridViewHolder
{
DeckViewHolder
(
View
view
)
{
super
(
view
);
this
.
view
=
view
;
view
.
setTag
(
view
.
getId
(),
this
);
cardImage
=
$
(
R
.
id
.
card_image
);
labelText
=
$
(
R
.
id
.
label
);
textLayout
=
$
(
R
.
id
.
layout_label
);
rightImage
=
$
(
R
.
id
.
right_top
);
}
@SuppressWarnings
(
"unchecked"
)
private
<
T
extends
View
>
T
$
(
int
id
)
{
return
(
T
)
view
.
findViewById
(
id
);
}
void
setSize
(
int
width
,
int
height
)
{
view
.
setMinimumWidth
(
width
);
view
.
setMinimumHeight
(
height
);
ViewGroup
.
LayoutParams
layoutParams
=
view
.
getLayoutParams
();
if
(
layoutParams
!=
null
)
{
if
(
width
>
0
)
{
layoutParams
.
width
=
width
;
}
else
{
layoutParams
.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
}
if
(
height
>
0
)
{
layoutParams
.
height
=
height
;
}
else
{
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
;
}
}
view
.
setLayoutParams
(
layoutParams
);
}
public
void
empty
()
{
showEmpty
();
}
public
void
useDefault
()
{
cardImage
.
setImageResource
(
R
.
drawable
.
unknown
);
//TODO sdcard的卡背
// File outFile = new File(AppsSettings.get().getCoreSkinPath(), Constants.UNKNOWN_IMAGE);
// ViewGroup.LayoutParams layoutParams = cardImage.getLayoutParams();
// if (layoutParams != null) {
// layoutParams.height = h;
// }
// imageLoader.$(outFile, cardImage, outFile.getName().endsWith(Constants.BPG), 0, null);
}
public
void
setText
(
String
text
)
{
labelText
.
setText
(
text
);
textLayout
.
setVisibility
(
View
.
VISIBLE
);
cardImage
.
setVisibility
(
View
.
GONE
);
rightImage
.
setVisibility
(
View
.
GONE
);
}
public
void
showImage
()
{
textLayout
.
setVisibility
(
View
.
GONE
);
cardImage
.
setVisibility
(
View
.
VISIBLE
);
rightImage
.
setVisibility
(
View
.
VISIBLE
);
//
cardImage
.
setImageResource
(
R
.
drawable
.
unknown
);
}
public
void
showEmpty
()
{
textLayout
.
setVisibility
(
View
.
GONE
);
cardImage
.
setVisibility
(
View
.
INVISIBLE
);
rightImage
.
setVisibility
(
View
.
GONE
);
}
public
ImageView
getCardImage
()
{
return
cardImage
;
}
/**
* 左上角图标
* @param bitmap
*/
public
void
setRightImage
(
Bitmap
bitmap
)
{
rightImage
.
setImageBitmap
(
bitmap
);
}
public
void
setHeadVisibility
(
int
visibility
)
{
}
private
final
View
view
;
private
final
View
textLayout
;
private
final
TextView
labelText
;
private
final
ImageView
cardImage
;
private
final
ImageView
rightImage
;
private
Card
mCard
;
private
Type
mType
;
public
Card
getCard
()
{
return
mCard
;
}
public
void
setCard
(
Card
card
)
{
mCard
=
card
;
}
public
Type
getType
()
{
return
mType
;
}
public
void
setType
(
Type
type
)
{
mType
=
type
;
}
public
enum
Type
{
None
,
Main
,
Extra
,
Side
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck2/IDeckLayout.java
deleted
100644 → 0
View file @
43c0391b
package
cn.garymb.ygomobile.ui.cards.deck2
;
public
interface
IDeckLayout
{
int
getMaxWidth
();
int
getWidth15
();
int
getWidth10
();
boolean
isLabel
(
int
position
);
boolean
isMain
(
int
position
);
boolean
isExtra
(
int
position
);
boolean
isSide
(
int
position
);
int
getMainCount
();
int
getExtraCount
();
int
getSideCount
();
int
getMainLimit
();
int
getExtraLimit
();
int
getSideLimit
();
int
getMainIndex
(
int
pos
);
int
getExtraIndex
(
int
pos
);
int
getSideIndex
(
int
pos
);
int
getLineLimitCount
();
int
getLineCardCount
();
boolean
moveItem
(
int
fromPosition
,
int
toPosition
);
}
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
0474dbee
...
@@ -75,7 +75,7 @@ import cn.garymb.ygomobile.ui.activities.WebActivity;
...
@@ -75,7 +75,7 @@ import cn.garymb.ygomobile.ui.activities.WebActivity;
import
cn.garymb.ygomobile.ui.adapters.ServerListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.ServerListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleListAdapter
;
import
cn.garymb.ygomobile.ui.cards.CardDetailRandom
;
import
cn.garymb.ygomobile.ui.cards.CardDetailRandom
;
import
cn.garymb.ygomobile.ui.cards.CardSearchAc
i
tivity
;
import
cn.garymb.ygomobile.ui.cards.CardSearchActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckUtils
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckUtils
;
import
cn.garymb.ygomobile.ui.mycard.MyCardActivity
;
import
cn.garymb.ygomobile.ui.mycard.MyCardActivity
;
...
@@ -194,8 +194,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -194,8 +194,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
@Override
@Override
public
void
onCardSearch
(
String
key
,
int
id
)
{
public
void
onCardSearch
(
String
key
,
int
id
)
{
if
(
id
==
ID_MAINACTIVITY
)
{
if
(
id
==
ID_MAINACTIVITY
)
{
Intent
intent
=
new
Intent
(
this
,
CardSearchAc
i
tivity
.
class
);
Intent
intent
=
new
Intent
(
this
,
CardSearchActivity
.
class
);
intent
.
putExtra
(
CardSearchAc
i
tivity
.
SEARCH_MESSAGE
,
key
);
intent
.
putExtra
(
CardSearchActivity
.
SEARCH_MESSAGE
,
key
);
startActivity
(
intent
);
startActivity
(
intent
);
}
}
}
}
...
@@ -333,10 +333,10 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -333,10 +333,10 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
mServerListManager
.
addServer
();
mServerListManager
.
addServer
();
break
;
break
;
case
R
.
id
.
action_card_search
:
case
R
.
id
.
action_card_search
:
startActivity
(
new
Intent
(
this
,
CardSearchAc
i
tivity
.
class
));
startActivity
(
new
Intent
(
this
,
CardSearchActivity
.
class
));
break
;
break
;
case
R
.
id
.
action_deck_manager
:
case
R
.
id
.
action_deck_manager
:
startActivity
(
new
Intent
(
this
,
DeckManagerActivity
.
getDeckManager
())
);
DeckManagerActivity
.
start
(
this
,
null
);
break
;
break
;
case
R
.
id
.
action_join_qq_group
:
case
R
.
id
.
action_join_qq_group
:
String
key
=
"anEjPCDdhLgxtfLre-nT52G1Coye3LkK"
;
String
key
=
"anEjPCDdhLgxtfLre-nT52G1Coye3LkK"
;
...
@@ -597,17 +597,13 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -597,17 +597,13 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
if
(
isUrl
)
{
if
(
isUrl
)
{
Deck
deckInfo
=
new
Deck
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
Uri
.
parse
(
deckMessage
));
Deck
deckInfo
=
new
Deck
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
Uri
.
parse
(
deckMessage
));
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
Intent
startdeck
=
new
Intent
(
this
,
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
this
,
file
.
getAbsolutePath
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
startActivity
(
startdeck
);
}
else
{
}
else
{
//如果是卡组文本
//如果是卡组文本
try
{
try
{
//以当前时间戳作为卡组名保存卡组
//以当前时间戳作为卡组名保存卡组
File
file
=
DeckUtils
.
save
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
deckMessage
);
File
file
=
DeckUtils
.
save
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
deckMessage
);
Intent
startdeck
=
new
Intent
(
this
,
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
this
,
file
.
getAbsolutePath
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
startActivity
(
startdeck
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
save_failed_bcos
)
+
e
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
save_failed_bcos
)
+
e
,
Toast
.
LENGTH_SHORT
).
show
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
0474dbee
...
@@ -58,7 +58,6 @@ import static cn.garymb.ygomobile.Constants.PERF_TEST_REPLACE_KERNEL;
...
@@ -58,7 +58,6 @@ import static cn.garymb.ygomobile.Constants.PERF_TEST_REPLACE_KERNEL;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_CHANGE_LOG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_CHANGE_LOG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_CHECK_UPDATE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_CHECK_UPDATE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DECK_DELETE_DILAOG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DECK_DELETE_DILAOG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DECK_MANAGER_V2
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEL_EX
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEL_EX
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_ANTIALIAS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_ANTIALIAS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_SIZE
;
...
@@ -138,7 +137,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -138,7 +137,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
bind
(
PREF_GAME_FONT
,
mSettings
.
getFontPath
());
bind
(
PREF_GAME_FONT
,
mSettings
.
getFontPath
());
bind
(
PREF_READ_EX
,
mSettings
.
isReadExpansions
());
bind
(
PREF_READ_EX
,
mSettings
.
isReadExpansions
());
bind
(
PREF_DEL_EX
,
getString
(
R
.
string
.
about_delete_ex
));
bind
(
PREF_DEL_EX
,
getString
(
R
.
string
.
about_delete_ex
));
bind
(
PREF_DECK_MANAGER_V2
,
mSettings
.
isUseDeckManagerV2
());
bind
(
PERF_TEST_REPLACE_KERNEL
,
"需root权限,请在开发者的指导下食用"
);
bind
(
PERF_TEST_REPLACE_KERNEL
,
"需root权限,请在开发者的指导下食用"
);
Preference
preference
=
findPreference
(
PREF_READ_EX
);
Preference
preference
=
findPreference
(
PREF_READ_EX
);
if
(
preference
!=
null
)
{
if
(
preference
!=
null
)
{
...
...
mobile/src/main/java/com/ourygo/assistant/service/DuelAssistantService.java
View file @
0474dbee
...
@@ -42,7 +42,7 @@ import cn.garymb.ygomobile.bean.ServerInfo;
...
@@ -42,7 +42,7 @@ import cn.garymb.ygomobile.bean.ServerInfo;
import
cn.garymb.ygomobile.bean.ServerList
;
import
cn.garymb.ygomobile.bean.ServerList
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.adapters.ServerListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.ServerListAdapter
;
import
cn.garymb.ygomobile.ui.cards.CardSearchAc
i
tivity
;
import
cn.garymb.ygomobile.ui.cards.CardSearchActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckUtils
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckUtils
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
...
@@ -236,19 +236,13 @@ public class DuelAssistantService extends Service implements OnDuelAssistantList
...
@@ -236,19 +236,13 @@ public class DuelAssistantService extends Service implements OnDuelAssistantList
if
(
isUrl
)
{
if
(
isUrl
)
{
Deck
deckInfo
=
new
Deck
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
Uri
.
parse
(
deckMessage
));
Deck
deckInfo
=
new
Deck
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
Uri
.
parse
(
deckMessage
));
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
Intent
startdeck
=
new
Intent
(
DuelAssistantService
.
this
,
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
DuelAssistantService
.
this
,
file
.
getAbsolutePath
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
startdeck
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
startdeck
);
}
else
{
}
else
{
//如果是卡组文本
//如果是卡组文本
try
{
try
{
//以当前时间戳作为卡组名保存卡组
//以当前时间戳作为卡组名保存卡组
File
file
=
DeckUtils
.
save
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
deckMessage
);
File
file
=
DeckUtils
.
save
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
deckMessage
);
Intent
startdeck
=
new
Intent
(
DuelAssistantService
.
this
,
DeckManagerActivity
.
getDeckManager
());
DeckManagerActivity
.
start
(
DuelAssistantService
.
this
,
file
.
getAbsolutePath
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
startdeck
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
startdeck
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Toast
.
makeText
(
DuelAssistantService
.
this
,
getString
(
R
.
string
.
save_failed_bcos
)
+
e
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
DuelAssistantService
.
this
,
getString
(
R
.
string
.
save_failed_bcos
)
+
e
,
Toast
.
LENGTH_SHORT
).
show
();
...
@@ -378,9 +372,9 @@ public class DuelAssistantService extends Service implements OnDuelAssistantList
...
@@ -378,9 +372,9 @@ public class DuelAssistantService extends Service implements OnDuelAssistantList
@Override
@Override
public
void
onCardSearch
(
String
key
,
int
id
)
{
public
void
onCardSearch
(
String
key
,
int
id
)
{
if
(
id
==
ClipManagement
.
ID_CLIP_LISTENER
)
{
if
(
id
==
ClipManagement
.
ID_CLIP_LISTENER
)
{
Intent
intent
=
new
Intent
(
DuelAssistantService
.
this
,
CardSearchAc
i
tivity
.
class
);
Intent
intent
=
new
Intent
(
DuelAssistantService
.
this
,
CardSearchActivity
.
class
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
putExtra
(
CardSearchAc
i
tivity
.
SEARCH_MESSAGE
,
key
);
intent
.
putExtra
(
CardSearchActivity
.
SEARCH_MESSAGE
,
key
);
startActivity
(
intent
);
startActivity
(
intent
);
}
}
}
}
...
...
mobile/src/main/res/layout/activity_deck_cards2.xml
deleted
100644 → 0
View file @
43c0391b
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.drawerlayout.widget.DrawerLayout
android:id=
"@+id/drawer_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/content_toolbar_list"
/>
<LinearLayout
android:id=
"@+id/layout_main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg3"
android:orientation=
"vertical"
>
<View
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
/>
<cn.garymb.ygomobile.ui.widget.DeckGroupView
android:id=
"@+id/deck_group"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<cn.garymb.ygomobile.ui.widget.DeckView
android:id=
"@+id/deckview"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
/>
<CheckBox
android:id=
"@+id/chk_autosort"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:checked=
"true"
android:text=
"自动排序"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/btn_edit_delete"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"删除模式"
/>
<Button
android:id=
"@+id/btn_edit_main2side"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"主卡组到副卡组"
/>
<Button
android:id=
"@+id/btn_edit_side2main"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"副卡组到主卡组"
/>
<Button
android:id=
"@+id/btn_delete"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:enabled=
"false"
android:text=
"完成"
/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"left"
android:background=
"@android:color/transparent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/blue"
android:orientation=
"vertical"
android:paddingLeft=
"4dp"
android:paddingTop=
"2dp"
android:paddingRight=
"4dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/item_height"
android:layout_marginLeft=
"20dp"
android:layout_marginTop=
"10dp"
android:layout_marginRight=
"30dp"
android:layout_marginBottom=
"4dp"
>
<androidx.appcompat.widget.AppCompatSpinner
android:id=
"@+id/sp_limit_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</LinearLayout>
<com.tubb.smrv.SwipeMenuRecyclerView
android:id=
"@+id/list_cards"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:divider=
"@android:color/transparent"
android:dividerHeight=
"4dp"
android:padding=
"2dp"
android:scrollbars=
"none"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"right"
android:background=
"@android:color/transparent"
android:orientation=
"vertical"
>
<include
android:id=
"@+id/nav_view_list"
layout=
"@layout/nav_card_search"
/>
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
mobile/src/main/res/layout/activity_deck_cards3.xml
deleted
100644 → 0
View file @
43c0391b
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.drawerlayout.widget.DrawerLayout
android:id=
"@+id/drawer_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/content_toolbar_list"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/bg3"
android:orientation=
"vertical"
>
<View
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:layout_marginBottom=
"5dp"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/recyclerview"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/refresh"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"refresh"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"left"
android:background=
"@android:color/transparent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/blue"
android:orientation=
"vertical"
android:paddingLeft=
"4dp"
android:paddingTop=
"2dp"
android:paddingRight=
"4dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/item_height"
android:layout_marginLeft=
"20dp"
android:layout_marginTop=
"10dp"
android:layout_marginRight=
"30dp"
android:layout_marginBottom=
"4dp"
>
<androidx.appcompat.widget.AppCompatSpinner
android:id=
"@+id/sp_limit_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</LinearLayout>
<com.tubb.smrv.SwipeMenuRecyclerView
android:id=
"@+id/list_cards"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:divider=
"@android:color/transparent"
android:dividerHeight=
"4dp"
android:padding=
"2dp"
android:scrollbars=
"none"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"right"
android:background=
"@android:color/transparent"
android:orientation=
"vertical"
>
<include
android:id=
"@+id/nav_view_list"
layout=
"@layout/nav_card_search"
/>
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
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