Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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-Cn-Ko-En
Commits
f3c4e221
Commit
f3c4e221
authored
Apr 17, 2020
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
showLinkArrow统一封装到BaseActivity
parent
801c5a85
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
62 deletions
+66
-62
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/BaseActivity.java
.../java/cn/garymb/ygomobile/ui/activities/BaseActivity.java
+50
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/CardListAdapter.java
...java/cn/garymb/ygomobile/ui/adapters/CardListAdapter.java
+11
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
...rc/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
+5
-59
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/BaseActivity.java
View file @
f3c4e221
...
...
@@ -26,6 +26,7 @@ import java.io.IOException;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
import
ocgcore.data.Card
;
public
class
BaseActivity
extends
AppCompatActivity
{
...
...
@@ -35,6 +36,40 @@ public class BaseActivity extends AppCompatActivity {
private
Toast
mToast
;
public
static
int
[]
enImgs
=
new
int
[]{
R
.
drawable
.
right_top_1
,
R
.
drawable
.
top_1
,
R
.
drawable
.
left_top_1
,
R
.
drawable
.
right_1
,
0
,
R
.
drawable
.
left_1
,
R
.
drawable
.
right_bottom_1
,
R
.
drawable
.
bottom_1
,
R
.
drawable
.
left_bottom_1
};
public
static
int
[]
disImgs
=
new
int
[]{
R
.
drawable
.
right_top_0
,
R
.
drawable
.
top_0
,
R
.
drawable
.
left_top_0
,
R
.
drawable
.
right_0
,
0
,
R
.
drawable
.
left_0
,
R
.
drawable
.
right_bottom_0
,
R
.
drawable
.
bottom_0
,
R
.
drawable
.
left_bottom_0
,
};
public
static
int
[]
ids
=
new
int
[]{
R
.
id
.
iv_9
,
R
.
id
.
iv_8
,
R
.
id
.
iv_7
,
R
.
id
.
iv_6
,
0
,
R
.
id
.
iv_4
,
R
.
id
.
iv_3
,
R
.
id
.
iv_2
,
R
.
id
.
iv_1
};
protected
String
[]
getPermissions
()
{
return
PERMISSIONS
;
}
...
...
@@ -275,4 +310,19 @@ public class BaseActivity extends AppCompatActivity {
toast
.
setDuration
(
duration
);
toast
.
show
();
}
public
static
void
showLinkArrows
(
Card
cardInfo
,
View
view
){
String
lk
=
Integer
.
toBinaryString
(
cardInfo
.
Defense
);
String
Linekey
=
String
.
format
(
"%09d"
,
Integer
.
parseInt
(
lk
));
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
String
arrow
=
Linekey
.
substring
(
i
,
i
+
1
);
if
(
i
!=
4
)
{
if
(
"1"
.
equals
(
arrow
))
{
view
.
findViewById
(
ids
[
i
]).
setBackgroundResource
(
enImgs
[
i
]);
}
else
{
view
.
findViewById
(
ids
[
i
]).
setBackgroundResource
(
disImgs
[
i
]);
}
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/adapters/CardListAdapter.java
View file @
f3c4e221
...
...
@@ -13,13 +13,14 @@ import org.greenrobot.eventbus.EventBus;
import
cn.garymb.ygomobile.bean.events.CardInfoEvent
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.cards.CardDetail
;
import
cn.garymb.ygomobile.ui.cards.CardListProvider
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.utils.CardUtils
;
import
ocgcore.DataManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.CardData
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.LimitType
;
...
...
@@ -31,6 +32,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
private
boolean
mItemBg
;
private
ImageLoader
imageLoader
;
private
boolean
mEnableSwipe
=
false
;
private
BaseActivity
mContext
;
public
CardListAdapter
(
Context
context
,
ImageLoader
imageLoader
)
{
super
(
context
);
...
...
@@ -109,7 +111,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
holder
.
layout_atk
.
setVisibility
(
View
.
VISIBLE
);
holder
.
layout_def
.
setVisibility
(
View
.
VISIBLE
);
// holder.view_bar.setVisibility(View.VISIBLE);
String
star
=
"★"
+
item
.
getStar
();
String
star
=
"★"
+
item
.
getStar
();
/*for (int i = 0; i < item.getStar(); i++) {
star += "★";
}*/
...
...
@@ -121,10 +123,13 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
}
holder
.
cardAtk
.
setText
((
item
.
Attack
<
0
?
"?"
:
String
.
valueOf
(
item
.
Attack
)));
if
(
item
.
isType
(
CardType
.
Link
))
{
holder
.
cardLevel
.
setVisibility
(
View
.
INVISIBLE
);
holder
.
cardLevel
.
setVisibility
(
View
.
GONE
);
holder
.
linkArrow
.
setVisibility
(
View
.
VISIBLE
);
holder
.
cardDef
.
setText
(
item
.
getStar
()
<
0
?
"?"
:
"LINK-"
+
String
.
valueOf
(
item
.
getStar
()));
holder
.
TextDef
.
setText
(
""
);
BaseActivity
.
showLinkArrows
(
item
,
holder
.
linkArrow
);
}
else
{
holder
.
linkArrow
.
setVisibility
(
View
.
GONE
);
holder
.
cardDef
.
setText
((
item
.
Defense
<
0
?
"?"
:
String
.
valueOf
(
item
.
Defense
)));
holder
.
TextDef
.
setText
(
"DEF/"
);
}
...
...
@@ -135,6 +140,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
// holder.view_bar.setVisibility(View.INVISIBLE);
// }
holder
.
cardLevel
.
setVisibility
(
View
.
INVISIBLE
);
holder
.
linkArrow
.
setVisibility
(
View
.
GONE
);
holder
.
layout_atk
.
setVisibility
(
View
.
GONE
);
holder
.
layout_def
.
setVisibility
(
View
.
GONE
);
}
...
...
@@ -215,6 +221,7 @@ class ViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder {
View
layout_atk
;
View
layout_def
;
View
view_bar
;
View
linkArrow
;
TextView
codeView
;
View
btnMain
,
btnSide
;
SwipeHorizontalMenuLayout
mMenuLayout
;
...
...
@@ -237,6 +244,7 @@ class ViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder {
btnMain
=
$
(
R
.
id
.
btn_add_main
);
btnSide
=
$
(
R
.
id
.
btn_add_side
);
mMenuLayout
=
$
(
R
.
id
.
swipe_layout
);
linkArrow
=
$
(
R
.
id
.
search_link_arrows
);
// File outFile = new File(AppsSettings.get().getCoreSkinPath(), Constants.UNKNOWN_IMAGE);
// ImageLoader.get().$(context, outFile, cardImage, outFile.getName().endsWith(Constants.BPG), 0, null);
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
View file @
f3c4e221
...
...
@@ -92,42 +92,6 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
private
TextView
tv_loading
;
private
boolean
isDownloadCardImage
=
true
;
private
CallBack
mCallBack
;
public
static
int
[]
enImgs
=
new
int
[]{
R
.
drawable
.
right_top_1
,
R
.
drawable
.
top_1
,
R
.
drawable
.
left_top_1
,
R
.
drawable
.
right_1
,
0
,
R
.
drawable
.
left_1
,
R
.
drawable
.
right_bottom_1
,
R
.
drawable
.
bottom_1
,
R
.
drawable
.
left_bottom_1
};
public
static
int
[]
disImgs
=
new
int
[]{
R
.
drawable
.
right_top_0
,
R
.
drawable
.
top_0
,
R
.
drawable
.
left_top_0
,
R
.
drawable
.
right_0
,
0
,
R
.
drawable
.
left_0
,
R
.
drawable
.
right_bottom_0
,
R
.
drawable
.
bottom_0
,
R
.
drawable
.
left_bottom_0
,
};
public
static
int
[]
ids
=
new
int
[]{
R
.
id
.
iv_9
,
R
.
id
.
iv_8
,
R
.
id
.
iv_7
,
R
.
id
.
iv_6
,
0
,
R
.
id
.
iv_4
,
R
.
id
.
iv_3
,
R
.
id
.
iv_2
,
R
.
id
.
iv_1
};
public
interface
CallBack
{
void
onSearchStart
();
...
...
@@ -363,13 +327,6 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
lb_setcode
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
cardInfo
.
isType
(
CardType
.
Monster
))
{
if
(
cardInfo
.
isType
(
CardType
.
Link
))
{
level
.
setVisibility
(
View
.
GONE
);
linkArrow
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
level
.
setVisibility
(
View
.
VISIBLE
);
linkArrow
.
setVisibility
(
View
.
GONE
);
}
atkdefView
.
setVisibility
(
View
.
VISIBLE
);
monsterlayout
.
setVisibility
(
View
.
VISIBLE
);
race
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -386,9 +343,13 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
cardAtk
.
setText
((
cardInfo
.
Attack
<
0
?
"?"
:
String
.
valueOf
(
cardInfo
.
Attack
)));
//连接怪兽设置
if
(
cardInfo
.
isType
(
CardType
.
Link
))
{
level
.
setVisibility
(
View
.
GONE
);
linkArrow
.
setVisibility
(
View
.
VISIBLE
);
cardDef
.
setText
((
cardInfo
.
getStar
()
<
0
?
"?"
:
"LINK-"
+
String
.
valueOf
(
cardInfo
.
getStar
())));
showLinkArrows
(
cardInfo
,
view
);
BaseActivity
.
showLinkArrows
(
cardInfo
,
view
);
}
else
{
level
.
setVisibility
(
View
.
VISIBLE
);
linkArrow
.
setVisibility
(
View
.
GONE
);
cardDef
.
setText
((
cardInfo
.
Defense
<
0
?
"?"
:
String
.
valueOf
(
cardInfo
.
Defense
)));
}
race
.
setText
(
mStringManager
.
getRaceString
(
cardInfo
.
Race
));
...
...
@@ -401,21 +362,6 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
}
}
public
void
showLinkArrows
(
Card
cardInfo
,
View
view
){
String
lk
=
Integer
.
toBinaryString
(
cardInfo
.
Defense
);
String
Linekey
=
String
.
format
(
"%09d"
,
Integer
.
parseInt
(
lk
));
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
String
arrow
=
Linekey
.
substring
(
i
,
i
+
1
);
if
(
i
!=
4
)
{
if
(
"1"
.
equals
(
arrow
))
{
view
.
findViewById
(
ids
[
i
]).
setBackgroundResource
(
enImgs
[
i
]);
}
else
{
view
.
findViewById
(
ids
[
i
]).
setBackgroundResource
(
disImgs
[
i
]);
}
}
}
}
private
void
showCardImageDetail
(
int
code
)
{
AppsSettings
appsSettings
=
AppsSettings
.
get
();
File
file
=
new
File
(
appsSettings
.
getCardImagePath
(
code
));
...
...
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