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
efc2bb18
Commit
efc2bb18
authored
Jun 21, 2022
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并卡组编辑类
parent
2fb780ce
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
253 additions
and
309 deletions
+253
-309
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/BaseActivity.java
.../java/cn/garymb/ygomobile/ui/activities/BaseActivity.java
+1
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
.../java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
+0
-278
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
+250
-24
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCardActivity.java
...in/java/cn/garymb/ygomobile/ui/mycard/MyCardActivity.java
+0
-1
mobile/src/main/res/menu/nav_main_menu.xml
mobile/src/main/res/menu/nav_main_menu.xml
+0
-4
No files found.
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
efc2bb18
...
@@ -248,7 +248,7 @@ public class GameUriManager {
...
@@ -248,7 +248,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
());
if
(!
deckInfo
.
isCompleteDeck
()){
if
(!
deckInfo
.
isCompleteDeck
())
{
YGOUtil
.
show
(
"当前卡组缺少完整信息,将只显示已有卡片"
);
YGOUtil
.
show
(
"当前卡组缺少完整信息,将只显示已有卡片"
);
}
}
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/BaseActivity.java
View file @
efc2bb18
...
@@ -34,6 +34,7 @@ import androidx.appcompat.app.AppCompatActivity;
...
@@ -34,6 +34,7 @@ import androidx.appcompat.app.AppCompatActivity;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.appcompat.widget.Toolbar
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/BaseCardsActivity.java
deleted
100644 → 0
View file @
2fb780ce
package
cn.garymb.ygomobile.ui.cards
;
import
android.graphics.Color
;
import
android.graphics.DashPathEffect
;
import
android.graphics.Paint
;
import
android.graphics.RectF
;
import
android.os.Bundle
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
androidx.recyclerview.widget.FastScrollLinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.app.hubert.guide.NewbieGuide
;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.listener.OnItemClickListener
;
import
com.chad.library.adapter.base.listener.OnItemLongClickListener
;
import
java.util.List
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.CardLoader
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.adapters.CardListAdapter
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
public
abstract
class
BaseCardsActivity
extends
BaseActivity
implements
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
protected
DrawerLayout
mDrawerLayout
;
protected
RecyclerView
mListView
;
protected
CardSearcher
mCardSelector
;
protected
CardListAdapter
mCardListAdapter
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
ImageLoader
mImageLoader
;
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
int
screenWidth
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_deck_cards
);
AnimationShake2
();
mImageLoader
=
new
ImageLoader
(
true
);
mDrawerLayout
=
$
(
R
.
id
.
drawer_layout
);
screenWidth
=
getResources
().
getDisplayMetrics
().
widthPixels
;
mListView
=
$
(
R
.
id
.
list_cards
);
mCardListAdapter
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdapter
.
setEnableSwipe
(
true
);
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setAdapter
(
mCardListAdapter
);
setListeners
();
mCardLoader
=
new
CardLoader
(
this
);
mCardLoader
.
setCallBack
(
this
);
mCardSelector
=
new
CardSearcher
(
$
(
R
.
id
.
nav_view_list
),
mCardLoader
);
mCardSelector
.
setCallBack
(
this
);
showNewbieGuide
(
"deckmain"
);
}
//https://www.jianshu.com/p/99649af3b191
public
void
showNewbieGuide
(
String
scene
)
{
HighlightOptions
options
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线圈
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
Paint
paint
=
new
Paint
();
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawCircle
(
rectF
.
centerX
(),
rectF
.
centerY
(),
rectF
.
width
()
/
2
+
10
,
paint
);
}).
build
();
HighlightOptions
options2
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线矩形
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
Paint
paint
=
new
Paint
();
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawRect
(
rectF
,
paint
);
}).
build
();
if
(
scene
.
equals
(
"deckmain"
))
{
NewbieGuide
.
with
(
this
)
//with方法可以传入Activity或者Fragment,获取引导页的依附者
.
setLabel
(
"deckmainGuide"
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
deck_menu
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
//可只创建一个引导layout并把相关内容都放在其中并GONE,获得ID并初始化相应为显示
view
.
findViewById
(
R
.
id
.
view_abt_bmb
).
setVisibility
(
View
.
VISIBLE
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_search
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_list
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search_result
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
tv_deckmanger
),
HighLight
.
Shape
.
CIRCLE
,
options2
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_view_deck_manager
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
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
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_abt_mid
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_view_move_card
);
})
)
//.alwaysShow(true)//总是显示,调试时可以打开
.
show
();
}
}
protected
void
setListeners
()
{
mCardListAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
onCardClick
(
view
,
mCardListAdapter
.
getItem
(
position
),
position
);
});
mCardListAdapter
.
setOnItemLongClickListener
((
adapter
,
view
,
position
)
->
{
onCardLongClick
(
view
,
mCardListAdapter
.
getItem
(
position
),
position
);
return
true
;
});
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
@Override
public
void
onScrollStateChanged
(
@NonNull
RecyclerView
recyclerView
,
int
newState
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
switch
(
newState
)
{
case
RecyclerView
.
SCROLL_STATE_IDLE
:
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
GlideCompat
.
with
(
getContext
()).
resumeRequests
();
break
;
case
RecyclerView
.
SCROLL_STATE_DRAGGING
:
GlideCompat
.
with
(
getContext
()).
pauseRequests
();
break
;
}
}
});
}
public
ImageLoader
getImageLoader
()
{
return
mImageLoader
;
}
@Override
protected
void
onBackHome
()
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
return
;
}
if
(
mDrawerLayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerLayout
.
closeDrawer
(
Gravity
.
LEFT
);
return
;
}
finish
();
}
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
// Log.d("kk", "find " + (cardInfos == null ? -1 : cardInfos.size()));
mCardListAdapter
.
set
(
cardInfos
);
mCardListAdapter
.
notifyDataSetChanged
();
if
(
cardInfos
!=
null
&&
cardInfos
.
size
()
>
0
)
{
mListView
.
smoothScrollToPosition
(
0
);
}
}
@Override
protected
void
onResume
()
{
// mImageLoader.resume();
super
.
onResume
();
}
@Override
protected
void
onPause
()
{
//仅退出的时候才关闭zip
// mImageLoader.pause();
super
.
onPause
();
}
@Override
protected
void
onDestroy
()
{
mImageLoader
.
close
();
super
.
onDestroy
();
}
@Override
public
void
onResetSearch
()
{
}
public
void
AnimationShake2
()
{
Animation
shake
=
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
shake
);
//加载动画资源文件
findViewById
(
R
.
id
.
cube2
).
startAnimation
(
shake
);
//给组件播放动画效果
}
protected
void
hideDrawers
()
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Gravity
.
RIGHT
))
{
mDrawerLayout
.
closeDrawer
(
Gravity
.
RIGHT
);
}
if
(
mDrawerLayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerLayout
.
closeDrawer
(
Gravity
.
LEFT
);
}
}
protected
abstract
void
onCardClick
(
View
view
,
Card
cardInfo
,
int
pos
);
protected
abstract
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
);
protected
void
showSearch
(
boolean
autoClose
)
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
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
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
showNewbieGuide
(
"searchResult"
);
}
else
if
(
isLoad
)
{
mDrawerLayout
.
openDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivity.java
View file @
efc2bb18
package
cn.garymb.ygomobile.ui.cards
;
package
cn.garymb.ygomobile.ui.cards
;
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
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.ClipData
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.ClipboardManager
;
...
@@ -8,6 +12,9 @@ import android.content.DialogInterface;
...
@@ -8,6 +12,9 @@ import android.content.DialogInterface;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.graphics.DashPathEffect
;
import
android.graphics.Paint
;
import
android.graphics.RectF
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
...
@@ -19,6 +26,8 @@ import android.view.Gravity;
...
@@ -19,6 +26,8 @@ import android.view.Gravity;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.EditText
;
...
@@ -27,13 +36,23 @@ import android.widget.Spinner;
...
@@ -27,13 +36,23 @@ import android.widget.Spinner;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.AppCompatSpinner
;
import
androidx.appcompat.widget.AppCompatSpinner
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.appcompat.widget.RecyclerViewItemListener
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
androidx.recyclerview.widget.FastScrollLinearLayoutManager
;
import
androidx.recyclerview.widget.ItemTouchHelperPlus
;
import
androidx.recyclerview.widget.ItemTouchHelperPlus
;
import
androidx.recyclerview.widget.OnItemDragListener
;
import
androidx.recyclerview.widget.OnItemDragListener
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.app.hubert.guide.NewbieGuide
;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.listener.OnItemClickListener
;
import
com.chad.library.adapter.base.listener.OnItemLongClickListener
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
com.nightonke.boommenu.BoomButtons.BoomButton
;
import
com.nightonke.boommenu.BoomButtons.BoomButton
;
import
com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton
;
import
com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton
;
...
@@ -60,7 +79,11 @@ import cn.garymb.ygomobile.bean.events.CardInfoEvent;
...
@@ -60,7 +79,11 @@ import cn.garymb.ygomobile.bean.events.CardInfoEvent;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.bean.events.DeckFile
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.CardLoader
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.adapters.CardListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckAdapater
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckAdapater
;
...
@@ -80,18 +103,15 @@ import cn.garymb.ygomobile.utils.IOUtils;
...
@@ -80,18 +103,15 @@ import cn.garymb.ygomobile.utils.IOUtils;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.ShareUtil
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGODialogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
ocgcore.DataManager
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.LimitType
;
import
ocgcore.enums.LimitType
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ORI_DECK
;
public
abstract
class
DeckManagerActivity
extends
BaseActivity
implements
RecyclerViewItemListener
.
OnItemListener
,
OnItemDragListener
,
YGODialogUtil
.
OnDeckMenuListener
,
CardLoader
.
CallBack
,
CardSearcher
.
CallBack
{
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
)
{
public
static
void
start
(
Context
context
,
String
path
)
{
Intent
starter
=
new
Intent
(
context
,
DeckManagerActivity
.
class
);
Intent
starter
=
new
Intent
(
context
,
DeckManagerActivity
.
class
);
starter
.
putExtra
(
Intent
.
EXTRA_TEXT
,
path
);
starter
.
putExtra
(
Intent
.
EXTRA_TEXT
,
path
);
...
@@ -100,6 +120,16 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -100,6 +120,16 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
}
}
context
.
startActivity
(
starter
);
context
.
startActivity
(
starter
);
}
}
protected
DrawerLayout
mDrawerLayout
;
protected
RecyclerView
mListView
;
protected
CardSearcher
mCardSelector
;
protected
CardListAdapter
mCardListAdapter
;
protected
CardLoader
mCardLoader
;
protected
boolean
isLoad
=
false
;
protected
ImageLoader
mImageLoader
;
protected
StringManager
mStringManager
=
DataManager
.
get
().
getStringManager
();
protected
LimitManager
mLimitManager
=
DataManager
.
get
().
getLimitManager
();
protected
int
screenWidth
;
//region ui onCreate/onDestroy
//region ui onCreate/onDestroy
private
RecyclerView
mRecyclerView
;
private
RecyclerView
mRecyclerView
;
...
@@ -120,7 +150,24 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -120,7 +150,24 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
getSupportActionBar
().
hide
();
setContentView
(
R
.
layout
.
activity_deck_cards
);
AnimationShake2
();
mImageLoader
=
new
ImageLoader
(
true
);
mDrawerLayout
=
$
(
R
.
id
.
drawer_layout
);
screenWidth
=
getResources
().
getDisplayMetrics
().
widthPixels
;
mListView
=
$
(
R
.
id
.
list_cards
);
mCardListAdapter
=
new
CardListAdapter
(
this
,
mImageLoader
);
mCardListAdapter
.
setEnableSwipe
(
true
);
mListView
.
setLayoutManager
(
new
FastScrollLinearLayoutManager
(
this
));
mListView
.
setAdapter
(
mCardListAdapter
);
setListeners
();
mCardLoader
=
new
CardLoader
(
this
);
mCardLoader
.
setCallBack
(
this
);
mCardSelector
=
new
CardSearcher
(
$
(
R
.
id
.
nav_view_list
),
mCardLoader
);
mCardSelector
.
setCallBack
(
this
);
showNewbieGuide
(
"deckmain"
);
tv_deck
=
$
(
R
.
id
.
tv_deck
);
tv_deck
=
$
(
R
.
id
.
tv_deck
);
tv_result_count
=
$
(
R
.
id
.
result_count
);
tv_result_count
=
$
(
R
.
id
.
result_count
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
mDeckSpinner
=
$
(
R
.
id
.
toolbar_list
);
...
@@ -175,7 +222,134 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -175,7 +222,134 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
tv_deck
.
setOnClickListener
(
v
->
YGODialogUtil
.
dialogDeckSelect
(
getActivity
(),
AppsSettings
.
get
().
getLastDeckPath
(),
this
));
tv_deck
.
setOnClickListener
(
v
->
YGODialogUtil
.
dialogDeckSelect
(
getActivity
(),
AppsSettings
.
get
().
getLastDeckPath
(),
this
));
}
}
//endregion
//https://www.jianshu.com/p/99649af3b191
public
void
showNewbieGuide
(
String
scene
)
{
HighlightOptions
options
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线圈
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
Paint
paint
=
new
Paint
();
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawCircle
(
rectF
.
centerX
(),
rectF
.
centerY
(),
rectF
.
width
()
/
2
+
10
,
paint
);
}).
build
();
HighlightOptions
options2
=
new
HighlightOptions
.
Builder
()
//绘制一个高亮虚线矩形
.
setOnHighlightDrewListener
((
canvas
,
rectF
)
->
{
Paint
paint
=
new
Paint
();
paint
.
setColor
(
Color
.
WHITE
);
paint
.
setStyle
(
Paint
.
Style
.
STROKE
);
paint
.
setStrokeWidth
(
20
);
paint
.
setPathEffect
(
new
DashPathEffect
(
new
float
[]{
20
,
20
},
0
));
canvas
.
drawRect
(
rectF
,
paint
);
}).
build
();
if
(
scene
.
equals
(
"deckmain"
))
{
NewbieGuide
.
with
(
this
)
//with方法可以传入Activity或者Fragment,获取引导页的依附者
.
setLabel
(
"deckmainGuide"
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
deck_menu
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
//可只创建一个引导layout并把相关内容都放在其中并GONE,获得ID并初始化相应为显示
view
.
findViewById
(
R
.
id
.
view_abt_bmb
).
setVisibility
(
View
.
VISIBLE
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_search
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
nav_list
),
HighLight
.
Shape
.
CIRCLE
,
options
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_button_search_result
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
addHighLightWithOptions
(
findViewById
(
R
.
id
.
tv_deckmanger
),
HighLight
.
Shape
.
CIRCLE
,
options2
)
.
setLayoutRes
(
R
.
layout
.
view_guide_home
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_about
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_view_deck_manager
);
})
)
.
addGuidePage
(
GuidePage
.
newInstance
().
setEverywhereCancelable
(
true
)
.
setBackgroundColor
(
0xbc000000
)
.
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
)
.
setOnLayoutInflatedListener
((
view
,
controller
)
->
{
TextView
tv
=
view
.
findViewById
(
R
.
id
.
text_abt_mid
);
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setText
(
R
.
string
.
guide_view_move_card
);
})
)
//.alwaysShow(true)//总是显示,调试时可以打开
.
show
();
}
}
protected
void
setListeners
()
{
mCardListAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
onCardClick
(
view
,
mCardListAdapter
.
getItem
(
position
),
position
);
});
mCardListAdapter
.
setOnItemLongClickListener
((
adapter
,
view
,
position
)
->
{
onCardLongClick
(
view
,
mCardListAdapter
.
getItem
(
position
),
position
);
return
true
;
});
mListView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
@Override
public
void
onScrollStateChanged
(
@NonNull
RecyclerView
recyclerView
,
int
newState
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
);
switch
(
newState
)
{
case
RecyclerView
.
SCROLL_STATE_IDLE
:
case
RecyclerView
.
SCROLL_STATE_SETTLING
:
GlideCompat
.
with
(
getContext
()).
resumeRequests
();
break
;
case
RecyclerView
.
SCROLL_STATE_DRAGGING
:
GlideCompat
.
with
(
getContext
()).
pauseRequests
();
break
;
}
}
});
}
public
ImageLoader
getImageLoader
()
{
return
mImageLoader
;
}
@Override
protected
void
onResume
()
{
// mImageLoader.resume();
super
.
onResume
();
}
@Override
protected
void
onPause
()
{
//仅退出的时候才关闭zip
// mImageLoader.pause();
super
.
onPause
();
}
@Override
@Override
protected
void
onStop
()
{
protected
void
onStop
()
{
...
@@ -185,18 +359,12 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -185,18 +359,12 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
@Override
protected
void
onDestroy
()
{
protected
void
onDestroy
()
{
EventBus
.
getDefault
().
unregister
(
this
);
mImageLoader
.
close
(
);
super
.
onDestroy
();
super
.
onDestroy
();
}
}
//region card edit
@Override
public
void
onLimitListChanged
(
LimitList
limitList
)
{
}
@Override
@Override
public
void
on
DragStart
()
{
public
void
on
ResetSearch
()
{
}
}
...
@@ -230,10 +398,42 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -230,10 +398,42 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
}
}
//endregion
//endregion
@Override
public
void
AnimationShake2
()
{
public
void
onDragEnd
()
{
Animation
shake
=
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
shake
);
//加载动画资源文件
findViewById
(
R
.
id
.
cube2
).
startAnimation
(
shake
);
//给组件播放动画效果
}
protected
void
hideDrawers
()
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Gravity
.
RIGHT
))
{
mDrawerLayout
.
closeDrawer
(
Gravity
.
RIGHT
);
}
if
(
mDrawerLayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerLayout
.
closeDrawer
(
Gravity
.
LEFT
);
}
}
protected
void
showSearch
(
boolean
autoClose
)
{
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
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
(
Constants
.
CARD_RESULT_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
showNewbieGuide
(
"searchResult"
);
}
else
if
(
isLoad
)
{
mDrawerLayout
.
openDrawer
(
Constants
.
CARD_RESULT_GRAVITY
);
}
}
}
//endregion
//region load deck
//region load deck
private
void
loadDeckFromFile
(
File
file
)
{
private
void
loadDeckFromFile
(
File
file
)
{
...
@@ -253,7 +453,6 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -253,7 +453,6 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
setCurDeck
(
rs
);
setCurDeck
(
rs
);
});
});
}
}
//endregion
//region init
//region init
private
void
init
(
@Nullable
File
ydk
)
{
private
void
init
(
@Nullable
File
ydk
)
{
...
@@ -329,7 +528,6 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -329,7 +528,6 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
hideDrawers
();
hideDrawers
();
}
}
@Override
protected
void
onCardClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
protected
void
onCardClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
if
(
mCardListAdapter
.
isShowMenu
(
view
))
{
if
(
mCardListAdapter
.
isShowMenu
(
view
))
{
return
;
return
;
...
@@ -339,7 +537,6 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -339,7 +537,6 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
}
}
}
}
@Override
protected
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
protected
void
onCardLongClick
(
View
view
,
Card
cardInfo
,
int
pos
)
{
// mCardListAdapater.showMenu(view);
// mCardListAdapater.showMenu(view);
}
}
...
@@ -363,8 +560,13 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -363,8 +560,13 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
@Override
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
public
void
onSearchResult
(
List
<
Card
>
cardInfos
,
boolean
isHide
)
{
super
.
onSearchResult
(
cardInfos
,
isHide
);
//
super.onSearchResult(cardInfos, isHide);
tv_result_count
.
setText
(
String
.
valueOf
(
cardInfos
.
size
()));
tv_result_count
.
setText
(
String
.
valueOf
(
cardInfos
.
size
()));
mCardListAdapter
.
set
(
cardInfos
);
mCardListAdapter
.
notifyDataSetChanged
();
if
(
cardInfos
!=
null
&&
cardInfos
.
size
()
>
0
)
{
mListView
.
smoothScrollToPosition
(
0
);
}
if
(!
isHide
)
if
(!
isHide
)
showResult
(
false
);
showResult
(
false
);
}
}
...
@@ -531,6 +733,15 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -531,6 +733,15 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
}
else
{
}
else
{
super
.
onBackHome
();
super
.
onBackHome
();
}
}
if
(
mDrawerLayout
.
isDrawerOpen
(
Constants
.
CARD_SEARCH_GRAVITY
))
{
mDrawerLayout
.
closeDrawer
(
Constants
.
CARD_SEARCH_GRAVITY
);
return
;
}
if
(
mDrawerLayout
.
isDrawerOpen
(
Gravity
.
LEFT
))
{
mDrawerLayout
.
closeDrawer
(
Gravity
.
LEFT
);
return
;
}
finish
();
}
}
@Override
@Override
...
@@ -1189,4 +1400,19 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
...
@@ -1189,4 +1400,19 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
public
void
onDeckNew
(
DeckType
currentDeckType
)
{
public
void
onDeckNew
(
DeckType
currentDeckType
)
{
createDeck
(
currentDeckType
.
getPath
());
createDeck
(
currentDeckType
.
getPath
());
}
}
//region card edit
@Override
public
void
onLimitListChanged
(
LimitList
limitList
)
{
}
@Override
public
void
onDragStart
()
{
}
@Override
public
void
onDragEnd
()
{
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
efc2bb18
...
@@ -91,7 +91,7 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista
...
@@ -91,7 +91,7 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista
// 配置navigation与底部菜单之间的联系
// 配置navigation与底部菜单之间的联系
// 底部菜单的样式里面的item里面的ID与navigation布局里面指定的ID必须相同,否则会出现绑定失败的情况
// 底部菜单的样式里面的item里面的ID与navigation布局里面指定的ID必须相同,否则会出现绑定失败的情况
appBarConfiguration
=
new
AppBarConfiguration
.
Builder
(
appBarConfiguration
=
new
AppBarConfiguration
.
Builder
(
R
.
id
.
home_fragment
,
R
.
id
.
mycard_fragment
,
R
.
id
.
setting_fragment
).
build
();
R
.
id
.
home_fragment
,
R
.
id
.
cardSearcher_fragment
,
R
.
id
.
mycard_fragment
,
R
.
id
.
setting_fragment
).
build
();
// 建立fragment容器的控制器,这个容器就是页面的上的fragment容器
// 建立fragment容器的控制器,这个容器就是页面的上的fragment容器
NavController
navController
=
Navigation
.
findNavController
(
this
,
R
.
id
.
nav_host_fragment
);
NavController
navController
=
Navigation
.
findNavController
(
this
,
R
.
id
.
nav_host_fragment
);
// 启动
// 启动
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCardActivity.java
View file @
efc2bb18
...
@@ -11,7 +11,6 @@ import android.os.Bundle;
...
@@ -11,7 +11,6 @@ import android.os.Bundle;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.Message
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
...
...
mobile/src/main/res/menu/nav_main_menu.xml
View file @
efc2bb18
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/action_card_search"
android:icon=
"@drawable/ic_search"
android:title=
"@string/card_search"
/>
<item
<item
android:id=
"@+id/action_deck_manager"
android:id=
"@+id/action_deck_manager"
android:icon=
"@drawable/ic_edit"
android:icon=
"@drawable/ic_edit"
...
...
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