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
f630a634
Commit
f630a634
authored
Nov 29, 2024
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化Toast封装
parent
1616b209
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
148 additions
and
140 deletions
+148
-140
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+2
-3
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+6
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
.../java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
.../cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
...rc/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchFragment.java
...java/cn/garymb/ygomobile/ui/cards/CardSearchFragment.java
+3
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+21
-22
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileActivity.java
...c/main/java/cn/garymb/ygomobile/ui/file/FileActivity.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileAdapter.java
...rc/main/java/cn/garymb/ygomobile/ui/file/FileAdapter.java
+4
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+6
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
+3
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ServerListManager.java
...n/java/cn/garymb/ygomobile/ui/home/ServerListManager.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
...in/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/VUiKit.java
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/VUiKit.java
+0
-42
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/PreferenceFragmentPlus.java
.../garymb/ygomobile/ui/settings/PreferenceFragmentPlus.java
+2
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
...java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
+9
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/DeckGroupView.java
...ain/java/cn/garymb/ygomobile/ui/widget/DeckGroupView.java
+3
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/CrashHandler.java
...src/main/java/cn/garymb/ygomobile/utils/CrashHandler.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/DensityUtils.java
...src/main/java/cn/garymb/ygomobile/utils/DensityUtils.java
+0
-24
mobile/src/main/java/cn/garymb/ygomobile/utils/ScreenUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/ScreenUtil.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/ShareUtil.java
...le/src/main/java/cn/garymb/ygomobile/utils/ShareUtil.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
+72
-4
No files found.
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
f630a634
...
...
@@ -54,13 +54,12 @@ import java.util.List;
import
java.util.Locale
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.settings.SharedPreferencesPlus
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.DensityUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
/**
* 静态类
...
...
@@ -195,7 +194,7 @@ public class AppsSettings {
}
int
ret
=
Math
.
min
(
w
,
h
);
//测试代码,曲面屏左右2变需要留空白,但是游戏画面比例不对,需要修改c那边代码
int
fix_h
=
DensityUtils
.
dp2px
(
context
,
getScreenPadding
());
int
fix_h
=
YGOUtil
.
dp2px
(
getScreenPadding
());
Log
.
d
(
IrrlichtBridge
.
TAG
,
"screen padding="
+
fix_h
);
return
ret
-
fix_h
*
2
;
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
f630a634
...
...
@@ -84,7 +84,7 @@ public class GameUriManager {
options
.
mRoomName
=
intent
.
getStringExtra
(
Constants
.
QUERY_ROOM
);
YGOStarter
.
startGame
(
getActivity
(),
options
);
}
catch
(
Exception
e
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
start_game_error
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
start_game_error
)
);
activity
.
finish
();
}
}
else
{
...
...
@@ -242,10 +242,10 @@ public class GameUriManager {
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
startSetting
.
putExtra
(
"flag"
,
4
);
activity
.
startActivity
(
startSetting
);
//todo ??再次打开MainActivity?
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
start_game_error
),
Toast
.
LENGTH_LONG
);
}
else
{
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_installed
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
ypk_installed
),
Toast
.
LENGTH_LONG
);
loadServerInfoFromZipOrYpk
(
getActivity
(),
file
);
//ypk不与excard机制相干涉
...
...
@@ -253,20 +253,20 @@ public class GameUriManager {
}
else
if
(
isYrp
)
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
()))
{
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-r"
,
file
.
getName
());
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
file_installed
),
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
file_installed
),
Toast
.
LENGTH_LONG
);
}
else
{
Log
.
w
(
Constants
.
TAG
,
"game is running"
);
}
}
else
if
(
isLua
)
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
()))
{
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-s"
,
file
.
getName
());
Toast
.
makeText
(
activity
,
"load single lua file"
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
"load single lua file"
,
Toast
.
LENGTH_LONG
);
}
else
{
Log
.
w
(
Constants
.
TAG
,
"game is running"
);
}
}
else
if
(
isConf
)
{
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
restart_app
),
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
restart_app
),
Toast
.
LENGTH_LONG
);
}
}
else
{
String
host
=
uri
.
getHost
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
View file @
f630a634
...
...
@@ -12,6 +12,7 @@ import cn.garymb.ygomobile.AppsSettings;
import
cn.garymb.ygomobile.YGOStarter
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
LogoActivity
extends
Activity
{
Handler
handler
;
...
...
@@ -39,7 +40,7 @@ public class LogoActivity extends Activity {
}
};
handler
.
postDelayed
(
runnable
,
1000
);
Toast
.
makeText
(
LogoActivity
.
this
,
R
.
string
.
logo_text
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
LogoActivity
.
this
.
getString
(
R
.
string
.
logo_text
),
Toast
.
LENGTH_SHORT
);
}
if
(!
isTaskRoot
())
{
finish
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/ShareFileActivity.java
View file @
f630a634
...
...
@@ -15,6 +15,7 @@ import cn.garymb.ygomobile.AppsSettings;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
ShareFileActivity
extends
Activity
{
@Override
...
...
@@ -56,7 +57,7 @@ public class ShareFileActivity extends Activity {
try
{
startActivity
(
Intent
.
createChooser
(
shareIntent
,
getString
(
R
.
string
.
send
)));
}
catch
(
Exception
e
)
{
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
sending_failed
)
+
e
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
sending_failed
)
+
e
,
Toast
.
LENGTH_LONG
);
}
finish
();
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
View file @
f630a634
...
...
@@ -419,7 +419,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
try
{
context
.
startActivity
(
intent
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
context
,
"dev error:not found activity."
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
"dev error:not found activity."
,
Toast
.
LENGTH_SHORT
);
}
});
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardSearchFragment.java
View file @
f630a634
...
...
@@ -43,6 +43,7 @@ import cn.garymb.ygomobile.ui.home.HomeActivity;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
...
...
@@ -103,7 +104,7 @@ public class CardSearchFragment extends BaseFragemnt implements CardLoader.CallB
mCardLoader
.
setLimitList
(
activity
.
getmLimitManager
().
getTopLimit
());
}
}).
fail
((
e
)
->
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
tip_load_cdb_error
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_load_cdb_error
),
Toast
.
LENGTH_SHORT
);
Log
.
e
(
IrrlichtBridge
.
TAG
,
"load cdb"
,
e
);
}).
done
((
rs
)
->
{
dlg
.
dismiss
();
...
...
@@ -259,7 +260,7 @@ public class CardSearchFragment extends BaseFragemnt implements CardLoader.CallB
return
false
;
}
else
{
exitLasttime
=
System
.
currentTimeMillis
();
Toast
.
makeText
(
getContext
(),
R
.
string
.
back_tip
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
back_tip
,
Toast
.
LENGTH_SHORT
);
}
}
return
true
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
f630a634
...
...
@@ -664,7 +664,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
false
;
}
else
{
exitLasttime
=
System
.
currentTimeMillis
();
Toast
.
makeText
(
getContext
(),
R
.
string
.
back_tip
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
back_tip
);
}
}
return
true
;
...
...
@@ -679,22 +679,22 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
count
!=
null
&&
count
<=
3
;
}
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Forbidden
))
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
tip_card_max
,
0
),
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
0
)
);
return
false
;
}
if
(
count
!=
null
)
{
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Limit
))
{
if
(
count
>=
1
)
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
tip_card_max
,
1
),
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
1
)
);
return
false
;
}
}
else
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
SemiLimit
))
{
if
(
count
>=
2
)
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
tip_card_max
,
2
),
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
2
)
);
return
false
;
}
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
tip_card_max
,
3
),
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
3
)
);
return
false
;
}
}
...
...
@@ -739,7 +739,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
break
;
case
R
.
id
.
action_share_deck
:
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
unable_to_edit_empty_deck
);
return
true
;
}
shareDeck
();
...
...
@@ -754,7 +754,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
else
{
if
(
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getAiDeckDir
())
||
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getPackDeckDir
()))
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
donot_edit_Deck
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
donot_edit_Deck
);
}
else
{
save
(
mDeckAdapater
.
getYdkFile
());
}
...
...
@@ -763,12 +763,12 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
break
;
case
R
.
id
.
action_rename
:
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
unable_to_edit_empty_deck
);
return
true
;
}
if
(
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getAiDeckDir
())
||
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getPackDeckDir
()))
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
donot_edit_Deck
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
donot_edit_Deck
);
}
else
{
inputDeckName
(
mDeckAdapater
.
getYdkFile
(),
mDeckAdapater
.
getYdkFile
().
getParent
(),
false
);
}
...
...
@@ -791,12 +791,12 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
break
;
case
R
.
id
.
action_delete_deck
:
{
if
(
mDeckAdapater
.
getYdkFile
()
==
null
)
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
unable_to_edit_empty_deck
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
unable_to_edit_empty_deck
);
return
true
;
}
if
(
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getAiDeckDir
())
||
TextUtils
.
equals
(
mDeckAdapater
.
getYdkFile
().
getParent
(),
mSettings
.
getPackDeckDir
()))
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
donot_edit_Deck
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
donot_edit_Deck
);
}
else
{
builder
.
setTitle
(
R
.
string
.
question
);
builder
.
setMessage
(
R
.
string
.
question_delete_deck
);
...
...
@@ -929,8 +929,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
du
.
dis
();
YGOUtil
.
copyMessage
(
getContext
(),
tv_code
.
getText
().
toString
().
trim
());
DuelAssistantManagement
.
getInstance
().
setLastMessage
(
tv_code
.
getText
().
toString
().
trim
());
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
deck_text_copyed
),
Toast
.
LENGTH_SHORT
).
show
();
YGOUtil
.
showTextToast
(
R
.
string
.
deck_text_copyed
);
});
bt_image_share
.
setOnClickListener
(
v
->
{
...
...
@@ -950,7 +949,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
try
{
startActivity
(
intent
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
"dev error:not found activity."
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
"dev error:not found activity."
+
e
);
}
});
...
...
@@ -974,7 +973,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
else
{
clipboardManager
.
setText
(
uri
);
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
copy_to_clipbroad
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
copy_to_clipbroad
);
}
private
File
getSelectDeck
(
Spinner
spinner
)
{
...
...
@@ -1082,7 +1081,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
else
ydk
=
new
File
(
savePath
,
filename
);
if
(
ydk
.
exists
())
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
file_exist
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
file_exist
);
return
;
}
if
(!
keepOld
&&
oldYdk
!=
null
&&
oldYdk
.
exists
())
{
...
...
@@ -1111,9 +1110,9 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
private
void
save
(
File
ydk
)
{
if
(
mDeckAdapater
.
save
(
ydk
))
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
save_tip_ok
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
save_tip_ok
);
}
else
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
save_tip_fail
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
save_tip_fail
);
}
}
...
...
@@ -1169,18 +1168,18 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
files
.
delete
();
}
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
e
+
""
);
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
done
);
}
private
void
doRestoreDeck
()
{
try
{
FileUtils
.
copyDir
(
ORI_DECK
,
mSettings
.
getDeckDir
(),
false
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
e
+
""
);
}
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
done
);
}
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileActivity.java
View file @
f630a634
...
...
@@ -21,6 +21,7 @@ import java.io.File;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
FileActivity
extends
BaseActivity
implements
AdapterView
.
OnItemClickListener
,
AdapterView
.
OnItemLongClickListener
...
...
@@ -126,7 +127,7 @@ public class FileActivity extends BaseActivity implements AdapterView.OnItemClic
if
(!
file
.
isDirectory
())
{
selectFile
(
file
);
}
else
{
Toast
.
makeText
(
this
,
R
.
string
.
the_name_is_folder
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
the_name_is_folder
);
return
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileAdapter.java
View file @
f630a634
...
...
@@ -23,6 +23,7 @@ import cn.garymb.ygomobile.Constants;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.adapters.BaseAdapterPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
class
FileAdapter
extends
BaseAdapterPlus
<
File
>
{
...
...
@@ -236,15 +237,15 @@ class FileAdapter extends BaseAdapterPlus<File> {
public
ViewHolder
(
Context
context
)
{
icon
=
new
ImageView
(
context
);
icon
.
setPadding
(
VUiKit
.
dpToP
x
(
4
),
0
,
0
,
0
);
icon
.
setPadding
(
YGOUtil
.
dp2p
x
(
4
),
0
,
0
,
0
);
icon
.
setScaleType
(
ImageView
.
ScaleType
.
FIT_CENTER
);
name
=
new
TextView
(
context
);
name
.
setPadding
(
VUiKit
.
dpToP
x
(
8
),
0
,
0
,
0
);
name
.
setPadding
(
YGOUtil
.
dp2p
x
(
8
),
0
,
0
,
0
);
name
.
setSingleLine
();
name
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
checkBox
=
new
CheckBox
(
context
);
checkBox
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
checkBox
.
setPadding
(
VUiKit
.
dpToP
x
(
4
),
0
,
0
,
0
);
checkBox
.
setPadding
(
YGOUtil
.
dp2p
x
(
4
),
0
,
0
,
0
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
f630a634
...
...
@@ -55,6 +55,7 @@ import cn.garymb.ygomobile.utils.OkhttpUtil;
import
cn.garymb.ygomobile.utils.ScreenUtil
;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
...
...
@@ -397,8 +398,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
super
.
onBackPressed
();
}
else
{
exitLasttime
=
System
.
currentTimeMillis
();
if
(
fragment_home
.
isVisible
()
||
fragment_settings
.
isVisible
())
Toast
.
makeText
(
getContext
(),
R
.
string
.
back_tip
,
Toast
.
LENGTH_SHORT
).
show
();
if
(
fragment_home
.
isVisible
()
||
fragment_settings
.
isVisible
())
YGOUtil
.
showTextToast
(
R
.
string
.
back_tip
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
f630a634
...
...
@@ -301,7 +301,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
NEED_UPDATE
)
{
ll_new_notice
.
setVisibility
(
View
.
VISIBLE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_iii
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
ex_card_check_toast_message_iii
);
ll_new_notice
.
setVisibility
(
View
.
GONE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
)
{
//do nothing
...
...
@@ -407,9 +407,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
builder
.
setLeftButtonListener
((
dlg
,
i
)
->
{
dlg
.
dismiss
();
if
(
Build
.
VERSION
.
SDK_INT
>=
23
&&
YGOStarter
.
isGameRunning
(
getActivity
()))
{
Toast
toast
=
Toast
.
makeText
(
App
.
get
().
getApplicationContext
(),
R
.
string
.
tip_return_to_duel
,
Toast
.
LENGTH_SHORT
);
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
toast
.
show
();
YGOUtil
.
showTextToast
(
Gravity
.
CENTER
,
R
.
string
.
tip_return_to_duel
);
openGame
();
}
else
{
//保存名字
...
...
@@ -523,7 +521,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
String
[]
tipsList
=
this
.
getResources
().
getStringArray
(
R
.
array
.
tips
);
int
x
=
(
int
)
(
Math
.
random
()
*
tipsList
.
length
);
String
tips
=
tipsList
[
x
];
Toast
.
makeText
(
getActivity
(),
tips
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
tips
,
Toast
.
LENGTH_LONG
);
}
}
...
...
@@ -669,10 +667,10 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
//如果是先行卡服务器,并且未开启先行卡设置,则通过toast提示
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
ex_card_check_toast_message
,
Toast
.
LENGTH_LONG
);
}
else
if
(
ServerUtil
.
exCardState
!=
ServerUtil
.
ExCardState
.
UPDATED
)
{
//如果是先行卡服务器,并且未开启下载先行卡,则通过toast提示
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_ii
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
ex_card_check_toast_message_ii
,
Toast
.
LENGTH_LONG
);
}
}
joinRoom
(
event
.
position
);
...
...
@@ -827,7 +825,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
case
R
.
id
.
nav_webpage
:
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
Uri
.
parse
(
Constants
.
URL_DONATE
));
Toast
.
makeText
(
getActivity
(),
R
.
string
.
donatefor
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
donatefor
,
Toast
.
LENGTH_LONG
);
startActivity
(
intent
);
}
break
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
View file @
f630a634
...
...
@@ -35,6 +35,7 @@ import cn.garymb.ygomobile.ui.plus.DialogPlus;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.NetUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
MainActivity
extends
HomeActivity
implements
BottomNavigationBar
.
OnTabSelectedListener
{
private
final
String
[]
PERMISSIONS
=
{
...
...
@@ -148,9 +149,9 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
try
{
FileUtils
.
copyDir
(
ORI_DECK
,
AppsSettings
.
get
().
getDeckDir
(),
false
);
}
catch
(
Throwable
e
)
{
Toast
.
makeText
(
MainActivity
.
this
,
e
+
""
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
e
+
""
,
Toast
.
LENGTH_LONG
);
}
Toast
.
makeText
(
MainActivity
.
this
,
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
done
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ServerListManager.java
View file @
f630a634
...
...
@@ -26,6 +26,7 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.XmlUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.StringManager
;
public
class
ServerListManager
{
...
...
@@ -133,7 +134,7 @@ public class ServerListManager {
if
(
TextUtils
.
isEmpty
(
info
.
getName
())
||
TextUtils
.
isEmpty
(
info
.
getServerAddr
())
||
TextUtils
.
isEmpty
(
editViewHolder
.
serverPort
.
getText
()))
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
server_is_exist
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
server_is_exist
);
return
;
}
if
(
isAdd
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
View file @
f630a634
...
...
@@ -389,7 +389,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
return
false
;
}
else
{
exitLasttime
=
System
.
currentTimeMillis
();
Toast
.
makeText
(
getContext
(),
R
.
string
.
back_tip
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
back_tip
);
}
}
if
(
mWebViewPlus
.
canGoBack
()
&&
!
homeActivity
.
fragment_mycard_chatting_room
.
isVisible
())
{
...
...
@@ -440,7 +440,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
if
(
mMcUser
.
getUsername
()
!=
null
&&
mMcUser
.
getPassword
()
!=
null
)
{
serviceManagement
.
start
();
}
else
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
login_mycard
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
login_mycard
);
}
}
break
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/VUiKit.java
View file @
f630a634
...
...
@@ -17,53 +17,11 @@ import org.jdeferred.android.AndroidDeferredManager;
public
class
VUiKit
{
private
static
final
AndroidDeferredManager
gDM
=
new
AndroidDeferredManager
();
private
static
final
Handler
gUiHandler
=
new
Handler
(
Looper
.
getMainLooper
());
private
static
Toast
mToast
;
public
static
AndroidDeferredManager
defer
()
{
return
gDM
;
}
public
static
int
dpToPx
(
Context
context
,
int
dp
)
{
return
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
dp
,
context
.
getResources
().
getDisplayMetrics
());
}
public
static
int
dpToPx
(
int
dp
)
{
return
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
dp
,
Resources
.
getSystem
().
getDisplayMetrics
());
}
public
static
int
getScreenWidth
()
{
return
Resources
.
getSystem
().
getDisplayMetrics
().
widthPixels
;
}
public
static
int
getScreenHeiget
()
{
return
Resources
.
getSystem
().
getDisplayMetrics
().
heightPixels
;
}
public
static
void
show
(
final
Context
context
,
int
id
,
Object
...
args
)
{
final
String
str
=
args
.
length
==
0
?
context
.
getString
(
id
)
:
context
.
getString
(
id
,
args
);
post
(()
->
{
if
(
mToast
==
null
)
{
mToast
=
Toast
.
makeText
(
context
,
str
,
Toast
.
LENGTH_SHORT
);
}
else
{
mToast
.
setText
(
str
);
}
mToast
.
show
();
});
}
public
static
void
show
(
final
Context
context
,
String
str
)
{
post
(()
->
{
if
(
mToast
==
null
)
{
mToast
=
Toast
.
makeText
(
context
,
str
,
Toast
.
LENGTH_SHORT
);
}
else
{
mToast
.
setText
(
str
);
}
mToast
.
show
();
});
}
public
static
void
post
(
Runnable
r
)
{
gUiHandler
.
post
(
r
);
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/PreferenceFragmentPlus.java
View file @
f630a634
...
...
@@ -27,6 +27,7 @@ import cn.garymb.ygomobile.ui.file.FileActivity;
import
cn.garymb.ygomobile.ui.file.FileOpenType
;
import
cn.garymb.ygomobile.utils.CurImageInfo
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
abstract
class
PreferenceFragmentPlus
extends
BasePreferenceFragment
{
private
Preference
curPreference
;
...
...
@@ -175,7 +176,7 @@ public abstract class PreferenceFragmentPlus extends BasePreferenceFragment {
try
{
FileUtils
.
copyFile
(
cachePath
,
mCurImageInfo
.
mOutFile
);
}
catch
(
IOException
e
)
{
Toast
.
makeText
(
getContext
(),
e
+
""
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
e
+
""
,
Toast
.
LENGTH_LONG
);
onChooseFileFail
(
curPreference
);
}
onChooseFileOk
(
curPreference
,
mCurImageInfo
.
mOutFile
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
View file @
f630a634
...
...
@@ -96,6 +96,7 @@ import cn.garymb.ygomobile.utils.OkhttpUtil;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
ocgcore.DataManager
;
import
okhttp3.Call
;
...
...
@@ -243,7 +244,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
mSettings
.
setDataLanguage
(
Integer
.
valueOf
(
listPreference
.
getValue
()));
Toast
.
makeText
(
getContext
(),
R
.
string
.
restart_app
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
restart_app
,
Toast
.
LENGTH_LONG
);
DataManager
.
get
().
load
(
true
);
}
mSharedPreferences
.
edit
().
putString
(
preference
.
getKey
(),
listPreference
.
getValue
()).
apply
();
...
...
@@ -281,10 +282,10 @@ public class SettingFragment extends PreferenceFragmentPlus {
});
dialog
.
show
();
}
else
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
Already_Lastest
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
Already_Lastest
);
}
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
),
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
Checking_Update_Failed
);
}
break
;
case
TYPE_SETTING_GET_VERSION_FAILED:
...
...
@@ -292,7 +293,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
if
(
FailedCount
<=
2
)
{
checkUpgrade
(
URL_HOME_VERSION
);
}
else
{
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
Checking_Update_Failed
)
+
msg
.
obj
.
toString
()
);
}
break
;
}
...
...
@@ -344,7 +345,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
simpleListAdapter
.
notifyDataSetChanged
();
FileUtils
.
delFile
(
mSettings
.
getExpansionsPath
().
getAbsolutePath
()
+
"/"
+
name
);
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
done
,
Toast
.
LENGTH_LONG
);
if
(
name
.
contains
(
Constants
.
officialExCardPackageName
))
{
//如果删除的是官方先行卡ypk,则更新其相关UI状态
SharedPreferenceUtil
.
setExpansionDataVer
(
null
);
//删除先行卡后,更新版本状态
ServerUtil
.
exCardState
=
ServerUtil
.
ExCardState
.
NEED_UPDATE
;
...
...
@@ -572,12 +573,12 @@ public class SettingFragment extends PreferenceFragmentPlus {
dlg
.
dismiss
();
mSettings
.
setUseExtraCards
(
false
);
checkBoxPreference
.
setChecked
(
false
);
Toast
.
makeText
(
getActivity
(),
R
.
string
.
restart_app
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
restart_app
);
}).
done
((
ok
)
->
{
dlg
.
dismiss
();
checkBoxPreference
.
setChecked
(
ok
);
mSettings
.
setUseExtraCards
(
ok
);
Toast
.
makeText
(
getActivity
(),
R
.
string
.
restart_app
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
restart_app
);
});
}
...
...
@@ -670,7 +671,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
Log
.
e
(
"SettingFragment"
,
"错误"
+
e
);
}
}).
done
((
rs
)
->
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
done
);
dialog
.
dismiss
();
});
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/widget/DeckGroupView.java
View file @
f630a634
...
...
@@ -23,6 +23,7 @@ import cn.garymb.ygomobile.lite.R;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.cards.deck.ImageTop
;
import
cn.garymb.ygomobile.ui.cards.deck.LabelInfo
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
...
...
@@ -501,13 +502,13 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
if
(
EditMode
.
None
!=
getEditMode
())
{
if
(
getEditMode
()
==
EditMode
.
Main2Side
)
{
if
(
type
==
Type
.
Side
)
{
Toast
.
makeText
(
getContext
(),
"不能选择side的"
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
"不能选择side的"
);
return
;
}
}
if
(
getEditMode
()
==
EditMode
.
Side2Main
)
{
if
(
type
==
Type
.
Main
||
type
==
Type
.
Extra
)
{
Toast
.
makeText
(
getContext
(),
"只能选择side的"
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
"只能选择side的"
);
return
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/CrashHandler.java
View file @
f630a634
...
...
@@ -69,7 +69,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
@Override
public
void
run
()
{
Looper
.
prepare
();
Toast
.
makeText
(
context
,
R
.
string
.
crashed
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
context
.
getString
(
R
.
string
.
crashed
),
Toast
.
LENGTH_LONG
);
Looper
.
loop
();
}
}.
start
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/DensityUtils.java
deleted
100644 → 0
View file @
1616b209
package
cn.garymb.ygomobile.utils
;
import
android.content.Context
;
public
class
DensityUtils
{
/**
* dp转px
*/
public
static
int
dp2px
(
Context
ctx
,
float
dp
)
{
if
(
dp
==
0
){
return
0
;
}
float
density
=
ctx
.
getResources
().
getDisplayMetrics
().
density
;
int
px
=
Math
.
round
(
dp
*
density
);
// 4.9->5 4.4->4
return
px
;
}
public
static
float
px2dp
(
Context
ctx
,
int
px
)
{
float
density
=
ctx
.
getResources
().
getDisplayMetrics
().
density
;
float
dp
=
px
/
density
;
return
dp
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/ScreenUtil.java
View file @
f630a634
...
...
@@ -240,7 +240,7 @@ public class ScreenUtil {
public
static
int
getNotchHeightOPPO
(
Context
context
)
{
if
(
isNotchVivo
(
context
))
{
//oppo刘海区域则都是宽度为324px, 高度为80px
return
(
int
)
DensityUtils
.
px2dp
(
context
,
80
);
return
(
int
)
YGOUtil
.
px2dp
(
80
);
}
return
0
;
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ShareUtil.java
View file @
f630a634
...
...
@@ -33,7 +33,7 @@ public class ShareUtil {
}
}
if
(!
ok
)
{
Toast
.
makeText
(
context
,
R
.
string
.
no_share_app
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
context
.
getString
(
R
.
string
.
no_share_app
)
);
}
return
ok
;
}
...
...
@@ -70,7 +70,7 @@ public class ShareUtil {
}
}
if
(!
ok
)
{
Toast
.
makeText
(
context
,
R
.
string
.
no_share_app
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
R
.
string
.
no_share_app
);
}
return
ok
;
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
View file @
f630a634
...
...
@@ -5,9 +5,13 @@ import android.content.ClipData;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.res.Resources
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.Toast
;
...
...
@@ -19,19 +23,31 @@ import androidx.recyclerview.widget.RecyclerView;
import
com.ourygo.lib.duelassistant.util.PermissionUtil
;
import
com.ourygo.lib.duelassistant.util.Util
;
import
org.jdeferred.android.AndroidDeferredManager
;
import
java.time.Duration
;
import
cn.garymb.ygomobile.App
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
public
class
YGOUtil
{
private
static
Toast
mToast
;
//提示
public
static
void
showTextToast
(
int
resId
)
{
showTextToast
(
s
(
resId
));
}
public
static
void
showTextToast
(
String
message
)
{
showTextToast
(
Gravity
.
BOTTOM
,
message
,
Toast
.
LENGTH_SHORT
);
}
public
static
void
showTextToast
(
int
resId
,
int
duration
)
{
showTextToast
(
s
(
resId
),
duration
);
}
public
static
void
showTextToast
(
String
message
,
int
duration
)
{
showTextToast
(
Gravity
.
BOTTOM
,
message
,
duration
);
}
...
...
@@ -40,11 +56,47 @@ public class YGOUtil {
showTextToast
(
gravity
,
message
,
Toast
.
LENGTH_SHORT
);
}
public
static
void
showTextToast
(
int
gravity
,
int
resId
,
int
duration
)
{
showTextToast
(
gravity
,
s
(
resId
),
duration
);
}
public
static
void
showTextToast
(
int
gravity
,
String
message
,
int
duration
)
{
Toast
toast
=
Toast
.
makeText
(
App
.
get
(),
message
,
duration
);
toast
.
setGravity
(
gravity
,
0
,
0
);
toast
.
setText
(
message
);
toast
.
show
();
mToast
=
Toast
.
makeText
(
App
.
get
(),
message
,
duration
);
mToast
.
setGravity
(
gravity
,
0
,
0
);
mToast
.
setText
(
message
);
mToast
.
show
();
}
public
static
void
show
(
int
id
,
Object
...
args
)
{
Context
context
=
App
.
get
();
final
String
str
=
args
.
length
==
0
?
context
.
getString
(
id
)
:
context
.
getString
(
id
,
args
);
VUiKit
.
post
(()
->
{
if
(
mToast
==
null
)
{
showTextToast
(
str
);
}
else
{
mToast
.
setText
(
str
);
}
mToast
.
show
();
});
}
public
static
void
show
(
String
str
)
{
VUiKit
.
post
(()
->
{
if
(
mToast
==
null
)
{
showTextToast
(
str
);
}
else
{
mToast
.
setText
(
str
);
}
mToast
.
show
();
});
}
public
static
int
getScreenWidth
()
{
return
Resources
.
getSystem
().
getDisplayMetrics
().
widthPixels
;
}
public
static
int
getScreenHeiget
()
{
return
Resources
.
getSystem
().
getDisplayMetrics
().
heightPixels
;
}
public
static
int
c
(
int
colorId
)
{
...
...
@@ -175,7 +227,23 @@ public class YGOUtil {
return
dialog
;
}
/**
* dp转px
*/
public
static
int
dp2px
(
float
dp
)
{
if
(
dp
==
0
){
return
0
;
}
float
density
=
App
.
get
().
getResources
().
getDisplayMetrics
().
density
;
int
px
=
Math
.
round
(
dp
*
density
);
// 4.9->5 4.4->4
return
px
;
}
public
static
float
px2dp
(
int
px
)
{
float
density
=
App
.
get
().
getResources
().
getDisplayMetrics
().
density
;
float
dp
=
px
/
density
;
return
dp
;
}
}
...
...
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