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
fbf605bf
Commit
fbf605bf
authored
Nov 30, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak
parent
94d22641
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+10
-15
mobile/src/main/java/cn/garymb/ygomobile/utils/DownloadUtil.java
...src/main/java/cn/garymb/ygomobile/utils/DownloadUtil.java
+2
-0
mobile/src/main/java/cn/garymb/ygomobile/utils/UnzipUtils.java
...e/src/main/java/cn/garymb/ygomobile/utils/UnzipUtils.java
+3
-1
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
fbf605bf
...
...
@@ -2,6 +2,7 @@ package cn.garymb.ygomobile.ui.activities;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_ADVANCE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
DownloadUtil
.
TYPE_DOWNLOAD_EXCEPTION
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
...
...
@@ -38,12 +39,6 @@ public class WebActivity extends BaseActivity {
private
String
mUrl
;
private
String
mTitle
;
private
Button
btn_download
;
private
static
final
int
TYPE_DOWNLOAD_EXCEPTION
=
1
;
private
static
final
int
TYPE_DOWNLOAD_ING
=
2
;
private
static
final
int
ZIP_READY
=
600
;
private
static
final
int
ZIP_UPDATE_PATH_PROGRESS
=
601
;
private
static
final
int
ZIP_UNZIP_OK
=
602
;
private
static
final
int
ZIP_UNZIP_EXCEPTION
=
603
;
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
...
...
@@ -51,16 +46,16 @@ public class WebActivity extends BaseActivity {
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
TYPE_DOWNLOAD_ING:
case
DownloadUtil
.
TYPE_DOWNLOAD_ING
:
btn_download
.
setText
(
msg
.
arg1
+
"%"
);
break
;
case
TYPE_DOWNLOAD_EXCEPTION:
case
DownloadUtil
.
TYPE_DOWNLOAD_EXCEPTION
:
YGOUtil
.
show
(
"error"
+
msg
.
obj
);
break
;
case
ZIP_READY:
case
UnzipUtils
.
ZIP_READY
:
btn_download
.
setText
(
R
.
string
.
title_use_ex
);
break
;
case
ZIP_UNZIP_OK:
case
UnzipUtils
.
ZIP_UNZIP_OK
:
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
Intent
startSetting
=
new
Intent
(
getContext
(),
SettingsActivity
.
class
);
startActivity
(
startSetting
);
...
...
@@ -71,7 +66,7 @@ public class WebActivity extends BaseActivity {
}
btn_download
.
setVisibility
(
View
.
GONE
);
break
;
case
ZIP_UNZIP_EXCEPTION:
case
UnzipUtils
.
ZIP_UNZIP_EXCEPTION
:
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
install_failed_bcos
)
+
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
break
;
...
...
@@ -211,13 +206,13 @@ public class WebActivity extends BaseActivity {
@Override
public
void
onDownloadSuccess
(
File
file
)
{
Message
message
=
new
Message
();
message
.
what
=
ZIP_READY
;
message
.
what
=
UnzipUtils
.
ZIP_READY
;
try
{
UnzipUtils
.
upZipFile
(
file
,
AppsSettings
.
get
().
getResourcePath
());
}
catch
(
Exception
e
)
{
message
.
what
=
ZIP_UNZIP_EXCEPTION
;
message
.
what
=
UnzipUtils
.
ZIP_UNZIP_EXCEPTION
;
}
finally
{
message
.
what
=
ZIP_UNZIP_OK
;
message
.
what
=
UnzipUtils
.
ZIP_UNZIP_OK
;
}
handler
.
sendMessage
(
message
);
}
...
...
@@ -226,7 +221,7 @@ public class WebActivity extends BaseActivity {
@Override
public
void
onDownloading
(
int
progress
)
{
Message
message
=
new
Message
();
message
.
what
=
TYPE_DOWNLOAD_ING
;
message
.
what
=
DownloadUtil
.
TYPE_DOWNLOAD_ING
;
message
.
arg1
=
progress
;
handler
.
sendMessage
(
message
);
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/DownloadUtil.java
View file @
fbf605bf
...
...
@@ -20,6 +20,8 @@ public class DownloadUtil {
private
static
DownloadUtil
downloadUtil
;
private
final
OkHttpClient
okHttpClient
;
public
static
final
int
TYPE_DOWNLOAD_EXCEPTION
=
1
;
public
static
final
int
TYPE_DOWNLOAD_ING
=
2
;
//暂时关闭
private
static
final
boolean
ENABLE_CACHE
=
false
;
private
static
final
Map
<
String
,
Call
>
cache
=
new
HashMap
<>();
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/UnzipUtils.java
View file @
fbf605bf
...
...
@@ -12,7 +12,9 @@ import java.util.zip.ZipFile;
public
class
UnzipUtils
{
private
static
final
int
BUFFER_SIZE
=
1024
*
1024
;
//1M Byte
public
static
final
int
ZIP_READY
=
600
;
public
static
final
int
ZIP_UNZIP_OK
=
601
;
public
static
final
int
ZIP_UNZIP_EXCEPTION
=
602
;
/**
* 解压缩一个文件
*
...
...
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