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
11396615
Commit
11396615
authored
Jan 20, 2020
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
高清卡图下载
parent
96a79072
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
389 additions
and
102 deletions
+389
-102
build.gradle
build.gradle
+1
-1
mobile/build.gradle
mobile/build.gradle
+2
-0
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+10
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
...rc/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
+100
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
...cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
+3
-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/mycard/mcchat/McchatActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/McchatActivity.java
+3
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
...arymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
+4
-4
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
.../java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
+0
-57
mobile/src/main/java/cn/garymb/ygomobile/utils/DownloadUtil.java
...src/main/java/cn/garymb/ygomobile/utils/DownloadUtil.java
+133
-0
mobile/src/main/java/cn/garymb/ygomobile/utils/PayUtils.java
mobile/src/main/java/cn/garymb/ygomobile/utils/PayUtils.java
+17
-16
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
+50
-0
mobile/src/main/res/anim/in_from_top.xml
mobile/src/main/res/anim/in_from_top.xml
+8
-0
mobile/src/main/res/anim/out_from_bottom.xml
mobile/src/main/res/anim/out_from_bottom.xml
+8
-0
mobile/src/main/res/layout/dialog_photo.xml
mobile/src/main/res/layout/dialog_photo.xml
+45
-6
mobile/src/main/res/layout/dialog_upgrade.xml
mobile/src/main/res/layout/dialog_upgrade.xml
+1
-2
No files found.
build.gradle
View file @
11396615
...
...
@@ -9,7 +9,7 @@ buildscript {
dependencies
{
classpath
'com.android.tools.build:gradle:3.5.3'
//classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
d
}
}
ext
{
...
...
mobile/build.gradle
View file @
11396615
...
...
@@ -117,5 +117,7 @@ dependencies {
//Tencent bugly
implementation
'com.tencent.bugly:crashreport_upgrade:latest.release'
implementation
'com.tencent.bugly:nativecrashreport:latest.release'
//http请求库
implementation
'com.squareup.okhttp3:okhttp:3.12.0'
}
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
11396615
...
...
@@ -336,6 +336,16 @@ public class AppsSettings {
mSharedPreferences
.
putString
(
Constants
.
PREF_IMAGE_QUALITY
,
""
+
quality
);
}
/**
* 根据卡密获取卡图的路径
* @param code 卡密
* @return
*/
public
String
getCardImagePath
(
int
code
){
return
new
File
(
getCardImagePath
(),
code
+
".jpg"
).
getAbsolutePath
();
}
/***
* 图片文件夹
*/
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardDetail.java
View file @
11396615
package
cn.garymb.ygomobile.ui.cards
;
import
android.annotation.SuppressLint
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.animation.AnimationUtils
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
com.feihua.dialogutils.util.DialogUtils
;
import
java.io.File
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.adapters.BaseAdapterPlus
;
import
cn.garymb.ygomobile.utils.CardUtils
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.enums.CardType
;
...
...
@@ -22,6 +36,11 @@ import ocgcore.enums.CardType;
* 卡片详情
*/
public
class
CardDetail
extends
BaseAdapterPlus
.
BaseViewHolder
{
private
static
final
int
TYPE_DOWNLOAD_CARD_IMAGE_OK
=
0
;
private
static
final
int
TYPE_DOWNLOAD_CARD_IMAGE_EXCEPTION
=
1
;
private
static
final
int
TYPE_DOWNLOAD_CARD_IMAGE_ING
=
2
;
private
static
final
String
TAG
=
"CardDetail"
;
private
ImageView
cardImage
;
private
TextView
name
;
...
...
@@ -53,6 +72,36 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
private
OnCardClickListener
mListener
;
private
DialogUtils
dialog
;
private
ImageView
photoView
;
private
LinearLayout
ll_bar
;
private
ProgressBar
pb_loading
;
private
TextView
tv_loading
;
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_DOWNLOAD_CARD_IMAGE_OK:
ll_bar
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
context
,
R
.
anim
.
out_from_bottom
));
ll_bar
.
setVisibility
(
View
.
GONE
);
imageLoader
.
bindImage
(
photoView
,
msg
.
arg1
,
null
,
true
);
break
;
case
TYPE_DOWNLOAD_CARD_IMAGE_ING:
tv_loading
.
setText
(
"下载高清卡图中 "
+
msg
.
arg1
+
"%"
);
pb_loading
.
setProgress
(
msg
.
arg1
);
break
;
case
TYPE_DOWNLOAD_CARD_IMAGE_EXCEPTION:
ll_bar
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
context
,
R
.
anim
.
out_from_bottom
));
ll_bar
.
setVisibility
(
View
.
GONE
);
YGOUtil
.
show
(
"下载失败,原因为"
+
msg
.
obj
);
break
;
}
}
};
public
CardDetail
(
BaseActivity
context
,
ImageLoader
imageLoader
,
StringManager
stringManager
)
{
super
(
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
dialog_cardinfo
,
null
));
...
...
@@ -173,12 +222,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
imageLoader
.
bindImage
(
cardImage
,
cardInfo
.
Code
,
null
,
true
);
dialog
=
DialogUtils
.
getdx
(
context
);
cardImage
.
setOnClickListener
((
v
)
->
{
View
view
=
dialog
.
initDialog
(
context
,
R
.
layout
.
dialog_photo
);
ImageView
photoView
=
view
.
findViewById
(
R
.
id
.
photoView
);
photoView
.
setOnClickListener
(
View
->
{
dialog
.
dis
();
});
imageLoader
.
bindImage
(
photoView
,
cardInfo
.
Code
,
null
,
true
);
showCardImageDetail
(
cardInfo
.
Code
);
});
name
.
setText
(
cardInfo
.
Name
);
desc
.
setText
(
cardInfo
.
Desc
);
...
...
@@ -244,6 +288,55 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
}
}
private
void
showCardImageDetail
(
int
code
)
{
AppsSettings
appsSettings
=
AppsSettings
.
get
();
File
file
=
new
File
(
appsSettings
.
getCardImagePath
(
code
));
View
view
=
dialog
.
initDialog
(
context
,
R
.
layout
.
dialog_photo
);
dialog
.
setDialogWidth
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
);
photoView
=
view
.
findViewById
(
R
.
id
.
photoView
);
ll_bar
=
view
.
findViewById
(
R
.
id
.
ll_bar
);
pb_loading
=
view
.
findViewById
(
R
.
id
.
pb_loading
);
tv_loading
=
view
.
findViewById
(
R
.
id
.
tv_name
);
pb_loading
.
setMax
(
100
);
photoView
.
setOnClickListener
(
View
->
{
dialog
.
dis
();
});
//先显示普通卡片大图,判断如果没有高清图就下载
imageLoader
.
bindImage
(
photoView
,
code
,
null
,
true
);
if
(!
file
.
exists
())
{
ll_bar
.
setVisibility
(
View
.
VISIBLE
);
ll_bar
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
context
,
R
.
anim
.
in_from_top
));
DownloadUtil
.
get
().
download
(
YGOUtil
.
getCardImageDetailUrl
(
code
),
file
.
getParent
(),
file
.
getName
(),
new
DownloadUtil
.
OnDownloadListener
()
{
@Override
public
void
onDownloadSuccess
(
File
file
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_DOWNLOAD_CARD_IMAGE_OK
;
message
.
arg1
=
code
;
handler
.
sendMessage
(
message
);
}
@Override
public
void
onDownloading
(
int
progress
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_DOWNLOAD_CARD_IMAGE_ING
;
message
.
arg1
=
progress
;
handler
.
sendMessage
(
message
);
}
@Override
public
void
onDownloadFailed
(
Exception
e
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_DOWNLOAD_CARD_IMAGE_EXCEPTION
;
message
.
obj
=
e
.
toString
();
handler
.
sendMessage
(
message
);
}
});
}
}
public
void
onPreCard
()
{
int
position
=
getCurPosition
();
CardListProvider
provider
=
getProvider
();
...
...
@@ -327,4 +420,5 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
View file @
11396615
...
...
@@ -66,7 +66,6 @@ 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.mycard.mcchat.util.Util
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
...
...
@@ -78,6 +77,7 @@ 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.DataManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
...
...
@@ -800,10 +800,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
public
void
onClick
(
View
v
)
{
du
.
dis
();
stopService
(
new
Intent
(
DeckManagerActivityImpl
.
this
,
ServiceDuelAssistant
.
class
));
Util
.
fz
Message
(
DeckManagerActivityImpl
.
this
,
et_code
.
getText
().
toString
().
trim
());
YGOUtil
.
copy
Message
(
DeckManagerActivityImpl
.
this
,
et_code
.
getText
().
toString
().
trim
());
showToast
(
getString
(
R
.
string
.
deck_text_copyed
));
//复制完毕开启决斗助手
Util
.
startDuelService
(
DeckManagerActivityImpl
.
this
);
YGO
Util
.
startDuelService
(
DeckManagerActivityImpl
.
this
);
}
});
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
11396615
...
...
@@ -77,9 +77,9 @@ import cn.garymb.ygomobile.utils.ComponentUtils;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
import
cn.garymb.ygomobile.utils.PayUtils
;
import
cn.garymb.ygomobile.utils.ScreenUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSET_SERVER_LIST
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
mycard
.
mcchat
.
util
.
Util
.
startDuelService
;
public
abstract
class
HomeActivity
extends
BaseActivity
implements
NavigationView
.
OnNavigationItemSelectedListener
{
//卡查关键字
...
...
@@ -152,7 +152,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//check update
Beta
.
checkUpgrade
(
false
,
false
);
//ServiceDuelAssistant
startDuelService
(
this
);
YGOUtil
.
startDuelService
(
this
);
//萌卡
StartMycard
();
checkNotch
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/McchatActivity.java
View file @
11396615
...
...
@@ -18,7 +18,7 @@ import cn.garymb.ygomobile.lite.R;
import
cn.garymb.ygomobile.ui.mycard.mcchat.adapter.ChatAdapter
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.u
i.mycard.mcchat.util.
Util
;
import
cn.garymb.ygomobile.u
tils.YGO
Util
;
public
class
McchatActivity
extends
Activity
implements
ChatListener
{
...
...
@@ -101,13 +101,13 @@ public class McchatActivity extends Activity implements ChatListener {
public
void
onClick
(
View
p1
)
{
String
message
=
main_send_message
.
getText
().
toString
().
trim
();
if
(
message
.
equals
(
""
))
{
Util
.
show
(
McchatActivity
.
this
,
getString
(
R
.
string
.
noting_to_send
));
YGOUtil
.
show
(
getString
(
R
.
string
.
noting_to_send
));
}
else
{
try
{
su
.
sendMessage
(
message
);
main_send_message
.
setText
(
""
);
}
catch
(
Exception
e
)
{
Util
.
show
(
McchatActivity
.
this
,
getString
(
R
.
string
.
sending_failed
));
YGOUtil
.
show
(
getString
(
R
.
string
.
sending_failed
));
}
}
// TODO: Implement this method
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
View file @
11396615
...
...
@@ -23,7 +23,7 @@ import cn.garymb.ygomobile.lite.R;
import
cn.garymb.ygomobile.ui.mycard.MyCardActivity
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.u
i.mycard.mcchat.util.
Util
;
import
cn.garymb.ygomobile.u
tils.YGO
Util
;
public
class
SplashActivity
extends
Activity
{
...
...
@@ -43,7 +43,7 @@ public class SplashActivity extends Activity {
su
.
setIsConnected
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
Util
.
show
(
SplashActivity
.
this
,
getString
(
R
.
string
.
failed_reason
)
+
msg
.
obj
);
YGOUtil
.
show
(
getString
(
R
.
string
.
failed_reason
)
+
msg
.
obj
);
break
;
case
1
:
startActivity
(
new
Intent
(
SplashActivity
.
this
,
McchatActivity
.
class
));
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
View file @
11396615
...
...
@@ -19,7 +19,7 @@ import cn.garymb.ygomobile.lite.R;
import
cn.garymb.ygomobile.ui.mycard.mcchat.ChatMessage
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.u
i.mycard.mcchat.util.
Util
;
import
cn.garymb.ygomobile.u
tils.YGO
Util
;
public
class
ChatAdapter
extends
RecyclerView
.
Adapter
<
ChatAdapter
.
ViewHolder
>
{
...
...
@@ -84,8 +84,8 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
@Override
public
boolean
onLongClick
(
View
p1
)
{
Util
.
fz
Message
(
context
,
cm
.
getMessage
());
Util
.
show
(
context
,
"已复制到剪贴板"
);
YGOUtil
.
copy
Message
(
context
,
cm
.
getMessage
());
YGOUtil
.
show
(
"已复制到剪贴板"
);
// TODO: Implement this method
return
true
;
}
...
...
@@ -94,7 +94,7 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
@Override
public
void
onClick
(
View
p1
)
{
Util
.
closeKeyboard
((
Activity
)
context
);
YGO
Util
.
closeKeyboard
((
Activity
)
context
);
// TODO: Implement this method
}
});
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
deleted
100644 → 0
View file @
96a79072
package
cn.garymb.ygomobile.ui.mycard.mcchat.util
;
import
android.app.Activity
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.Toast
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant
;
import
cn.garymb.ygomobile.utils.PermissionUtil
;
public
class
Util
{
//提示
public
static
void
show
(
Context
context
,
String
message
)
{
Toast
.
makeText
(
context
,
message
,
Toast
.
LENGTH_SHORT
).
show
();
}
//关闭输入法
public
static
void
closeKeyboard
(
Activity
activity
)
{
InputMethodManager
inputMethodManager
=
(
InputMethodManager
)
activity
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
if
(
inputMethodManager
==
null
)
return
;
View
view
=
activity
.
getCurrentFocus
();
if
(
view
==
null
)
return
;
inputMethodManager
.
hideSoftInputFromWindow
(
view
.
getWindowToken
()
,
InputMethodManager
.
HIDE_NOT_ALWAYS
);
}
//复制字符串到剪贴板
public
static
void
fzMessage
(
Context
context
,
String
message
)
{
ClipboardManager
cmb
=
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
cmb
.
setPrimaryClip
(
ClipData
.
newPlainText
(
null
,
message
));
//复制命令
}
public
static
void
startDuelService
(
Context
context
)
{
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
()
&&
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
DialogPlus
dialogPlus
=
PermissionUtil
.
isNotificationPermission
(
context
);
if
(
dialogPlus
==
null
)
context
.
startForegroundService
(
new
Intent
(
context
,
ServiceDuelAssistant
.
class
));
else
dialogPlus
.
show
();
}
else
{
context
.
startService
(
new
Intent
(
context
,
ServiceDuelAssistant
.
class
));
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/DownloadUtil.java
0 → 100644
View file @
11396615
package
cn.garymb.ygomobile.utils
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
okhttp3.Call
;
import
okhttp3.Callback
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
public
class
DownloadUtil
{
private
static
DownloadUtil
downloadUtil
;
private
final
OkHttpClient
okHttpClient
;
public
static
DownloadUtil
get
()
{
if
(
downloadUtil
==
null
)
{
downloadUtil
=
new
DownloadUtil
();
}
return
downloadUtil
;
}
public
DownloadUtil
()
{
okHttpClient
=
new
OkHttpClient
();
}
/**
* @param url 下载连接
* @param destFileDir 下载的文件储存目录
* @param destFileName 下载文件名称
* @param listener 下载监听
*/
public
void
download
(
final
String
url
,
final
String
destFileDir
,
final
String
destFileName
,
final
OnDownloadListener
listener
)
{
Request
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
build
();
/* OkHttpClient client = new OkHttpClient();
try {
Response response = client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}*/
//异步请求
okHttpClient
.
newCall
(
request
).
enqueue
(
new
Callback
()
{
@Override
public
void
onFailure
(
Call
call
,
IOException
e
)
{
// 下载失败监听回调
listener
.
onDownloadFailed
(
e
);
}
@Override
public
void
onResponse
(
Call
call
,
Response
response
)
throws
IOException
{
InputStream
is
=
null
;
byte
[]
buf
=
new
byte
[
2048
];
int
len
=
0
;
FileOutputStream
fos
=
null
;
//储存下载文件的目录
File
dir
=
new
File
(
destFileDir
);
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
File
file
=
new
File
(
dir
,
destFileName
);
try
{
is
=
response
.
body
().
byteStream
();
long
total
=
response
.
body
().
contentLength
();
fos
=
new
FileOutputStream
(
file
);
long
sum
=
0
;
while
((
len
=
is
.
read
(
buf
))
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
len
);
sum
+=
len
;
int
progress
=
(
int
)
(
sum
*
1.0f
/
total
*
100
);
//下载中更新进度条
listener
.
onDownloading
(
progress
);
}
fos
.
flush
();
//下载完成
listener
.
onDownloadSuccess
(
file
);
}
catch
(
Exception
e
)
{
listener
.
onDownloadFailed
(
e
);
}
finally
{
try
{
if
(
is
!=
null
)
{
is
.
close
();
}
if
(
fos
!=
null
)
{
fos
.
close
();
}
}
catch
(
IOException
e
)
{
}
}
}
});
}
public
static
interface
OnDownloadListener
{
/**
* 下载成功之后的文件
*/
void
onDownloadSuccess
(
File
file
);
/**
* 下载进度
*/
void
onDownloading
(
int
progress
);
/**
* 下载异常信息
*/
void
onDownloadFailed
(
Exception
e
);
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/PayUtils.java
View file @
11396615
package
cn.garymb.ygomobile.utils
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.telephony.TelephonyManager
;
import
android.text.InputType
;
import
android.view.Gravity
;
import
android.widget.EditText
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.telephony.TelephonyManager
;
import
android.text.InputType
;
import
android.view.Gravity
;
import
android.widget.EditText
;
import
com.base.bj.paysdk.domain.TrPayResult
;
import
com.base.bj.paysdk.listener.PayResultListener
;
import
com.base.bj.paysdk.utils.TrPay
;
import
com.base.bj.paysdk.domain.TrPayResult
;
import
com.base.bj.paysdk.listener.PayResultListener
;
import
com.base.bj.paysdk.utils.TrPay
;
import
java.net.URLEncoder
;
import
java.util.UUID
;
import
java.net.URLEncoder
;
import
java.util.UUID
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ALIPAY_URL
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ALIPAY_URL
;
public
class
PayUtils
{
/***
...
...
@@ -88,7 +89,7 @@ public class PayUtils {
public
static
String
getID
(
Context
context
)
{
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
String
imei
=
telephonyManager
.
getDeviceId
();
@SuppressLint
(
"MissingPermission"
)
String
imei
=
telephonyManager
.
getDeviceId
();
return
imei
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/YGOUtil.java
View file @
11396615
package
cn.garymb.ygomobile.utils
;
import
android.app.Activity
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.Toast
;
import
androidx.core.content.ContextCompat
;
import
cn.garymb.ygomobile.App
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant
;
public
class
YGOUtil
{
...
...
@@ -20,4 +31,43 @@ public class YGOUtil {
public
static
String
s
(
int
stringId
){
return
App
.
get
().
getResources
().
getString
(
stringId
);
}
public
static
String
getCardImageDetailUrl
(
int
code
){
return
"https://code.mycard.moe/fallenstardust/ygoimage/raw/master/"
+
code
+
".jpg"
;
}
//关闭输入法
public
static
void
closeKeyboard
(
Activity
activity
)
{
InputMethodManager
inputMethodManager
=
(
InputMethodManager
)
activity
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
if
(
inputMethodManager
==
null
)
return
;
View
view
=
activity
.
getCurrentFocus
();
if
(
view
==
null
)
return
;
inputMethodManager
.
hideSoftInputFromWindow
(
view
.
getWindowToken
()
,
InputMethodManager
.
HIDE_NOT_ALWAYS
);
}
//复制字符串到剪贴板
public
static
void
copyMessage
(
Context
context
,
String
message
)
{
ClipboardManager
cmb
=
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
cmb
.
setPrimaryClip
(
ClipData
.
newPlainText
(
null
,
message
));
//复制命令
}
public
static
void
startDuelService
(
Context
context
)
{
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
()
&&
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
DialogPlus
dialogPlus
=
PermissionUtil
.
isNotificationPermission
(
context
);
if
(
dialogPlus
==
null
)
context
.
startForegroundService
(
new
Intent
(
context
,
ServiceDuelAssistant
.
class
));
else
dialogPlus
.
show
();
}
else
{
context
.
startService
(
new
Intent
(
context
,
ServiceDuelAssistant
.
class
));
}
}
}
}
mobile/src/main/res/anim/in_from_top.xml
0 → 100644
View file @
11396615
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:interpolator=
"@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta =
"-100%"
android:toYDelta =
"0%"
android:duration =
"250"
>
</translate>
mobile/src/main/res/anim/out_from_bottom.xml
0 → 100644
View file @
11396615
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:interpolator=
"@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta =
"0%"
android:toYDelta =
"-100%"
android:duration =
"250"
>
</translate>
mobile/src/main/res/layout/dialog_photo.xml
View file @
11396615
<ImageView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/photoView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:scaleType=
"fitCenter"
android:background=
"@color/tr_transparent_background"
/>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_height=
"match_parent"
android:layout_width=
"match_parent"
>
<ImageView
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:id=
"@+id/photoView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_centerInParent=
"true"
android:scaleType=
"fitCenter"
/>
<LinearLayout
android:visibility=
"gone"
android:id=
"@+id/ll_bar"
android:background=
"@color/gray"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<androidx.appcompat.widget.AppCompatTextView
android:id=
"@+id/tv_name"
android:textColor=
"@color/black"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"5dp"
android:gravity=
"center"
android:textStyle=
"bold"
android:text=
"下载高清卡图中"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<ProgressBar
android:layout_marginBottom=
"5dp"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:id=
"@+id/pb_loading"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
style=
"@style/Widget.AppCompat.ProgressBar.Horizontal"
/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
mobile/src/main/res/layout/dialog_upgrade.xml
View file @
11396615
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/tr_transparent_background"
>
android:layout_height=
"match_parent"
>
<RelativeLayout
android:layout_width=
"350dp"
...
...
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