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
288c833a
Commit
288c833a
authored
Nov 29, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unzip
parent
74f7930a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
14 deletions
+15
-14
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+12
-11
mobile/src/main/java/cn/garymb/ygomobile/utils/UnzipUtils.java
...e/src/main/java/cn/garymb/ygomobile/utils/UnzipUtils.java
+1
-1
No files found.
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
288c833a
...
@@ -197,7 +197,7 @@ public class GameUriManager {
...
@@ -197,7 +197,7 @@ public class GameUriManager {
}
}
private
void
doUri
(
Uri
uri
)
{
private
void
doUri
(
Uri
uri
)
{
Intent
startSeting
=
new
Intent
(
activity
,
SettingsActivity
.
class
);
Intent
startSet
t
ing
=
new
Intent
(
activity
,
SettingsActivity
.
class
);
if
(
"file"
.
equals
(
uri
.
getScheme
())
||
"content"
.
equals
(
uri
.
getScheme
()))
{
if
(
"file"
.
equals
(
uri
.
getScheme
())
||
"content"
.
equals
(
uri
.
getScheme
()))
{
File
file
=
toLocalFile
(
uri
);
File
file
=
toLocalFile
(
uri
);
if
(
file
==
null
||
!
file
.
exists
())
{
if
(
file
==
null
||
!
file
.
exists
())
{
...
@@ -213,7 +213,7 @@ public class GameUriManager {
...
@@ -213,7 +213,7 @@ public class GameUriManager {
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
}
else
if
(
isYpk
)
{
}
else
if
(
isYpk
)
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
activity
.
startActivity
(
startSeting
);
activity
.
startActivity
(
startSet
t
ing
);
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
}
else
{
DataManager
.
get
().
load
(
true
);
DataManager
.
get
().
load
(
true
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
288c833a
...
@@ -24,9 +24,11 @@ import java.io.File;
...
@@ -24,9 +24,11 @@ import java.io.File;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.preference.SettingsActivity
;
import
cn.garymb.ygomobile.ui.widget.WebViewPlus
;
import
cn.garymb.ygomobile.ui.widget.WebViewPlus
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.UnzipUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
...
@@ -42,7 +44,6 @@ public class WebActivity extends BaseActivity {
...
@@ -42,7 +44,6 @@ public class WebActivity extends BaseActivity {
private
static
final
int
ZIP_UPDATE_PATH_PROGRESS
=
601
;
private
static
final
int
ZIP_UPDATE_PATH_PROGRESS
=
601
;
private
static
final
int
ZIP_UNZIP_OK
=
602
;
private
static
final
int
ZIP_UNZIP_OK
=
602
;
private
static
final
int
ZIP_UNZIP_EXCEPTION
=
603
;
private
static
final
int
ZIP_UNZIP_EXCEPTION
=
603
;
private
boolean
isDownloadCardImage
=
true
;
@SuppressLint
(
"HandlerLeak"
)
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
Handler
handler
=
new
Handler
()
{
...
@@ -51,18 +52,11 @@ public class WebActivity extends BaseActivity {
...
@@ -51,18 +52,11 @@ public class WebActivity extends BaseActivity {
super
.
handleMessage
(
msg
);
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
switch
(
msg
.
what
)
{
case
TYPE_DOWNLOAD_OK:
case
TYPE_DOWNLOAD_OK:
isDownloadCardImage
=
true
;
btn_download
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
out_from_bottom
));
btn_download
.
setVisibility
(
View
.
GONE
);
//这里解压
break
;
break
;
case
TYPE_DOWNLOAD_ING:
case
TYPE_DOWNLOAD_ING:
btn_download
.
setText
(
msg
.
arg1
+
"%"
);
btn_download
.
setText
(
msg
.
arg1
+
"%"
);
break
;
break
;
case
TYPE_DOWNLOAD_EXCEPTION:
case
TYPE_DOWNLOAD_EXCEPTION:
isDownloadCardImage
=
true
;
btn_download
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
getContext
(),
R
.
anim
.
out_from_bottom
));
btn_download
.
setVisibility
(
View
.
GONE
);
YGOUtil
.
show
(
"error"
+
msg
.
obj
);
YGOUtil
.
show
(
"error"
+
msg
.
obj
);
break
;
break
;
case
ZIP_READY:
case
ZIP_READY:
...
@@ -72,10 +66,12 @@ public class WebActivity extends BaseActivity {
...
@@ -72,10 +66,12 @@ public class WebActivity extends BaseActivity {
btn_download
.
setText
(
msg
.
obj
.
toString
());
btn_download
.
setText
(
msg
.
obj
.
toString
());
break
;
break
;
case
ZIP_UNZIP_OK:
case
ZIP_UNZIP_OK:
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
ypk_installed
)
+
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
startSetting
=
new
Intent
(
getContext
(),
SettingsActivity
.
class
);
startActivity
(
startSetting
);
Toast
.
makeText
(
getContext
(),
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
();
break
;
break
;
case
ZIP_UNZIP_EXCEPTION:
case
ZIP_UNZIP_EXCEPTION:
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
install_failed_bcos
)
+
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
install_failed_bcos
)
+
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
break
;
break
;
}
}
...
@@ -204,13 +200,13 @@ public class WebActivity extends BaseActivity {
...
@@ -204,13 +200,13 @@ public class WebActivity extends BaseActivity {
}
}
});
});
}
}
private
void
downloadfromWeb
()
{
private
void
downloadfromWeb
()
{
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
());
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
());
final
File
tmp
=
new
File
(
file
.
getAbsolutePath
()
+
".tmp"
);
final
File
tmp
=
new
File
(
file
.
getAbsolutePath
()
+
".tmp"
);
if
(
tmp
.
exists
())
{
if
(
tmp
.
exists
())
{
FileUtils
.
deleteFile
(
tmp
);
FileUtils
.
deleteFile
(
tmp
);
}
}
isDownloadCardImage
=
false
;
DownloadUtil
.
get
().
download
(
URL_YGO233_FILE
,
tmp
.
getParent
(),
tmp
.
getName
(),
new
DownloadUtil
.
OnDownloadListener
()
{
DownloadUtil
.
get
().
download
(
URL_YGO233_FILE
,
tmp
.
getParent
(),
tmp
.
getName
(),
new
DownloadUtil
.
OnDownloadListener
()
{
@Override
@Override
public
void
onDownloadSuccess
(
File
file
)
{
public
void
onDownloadSuccess
(
File
file
)
{
...
@@ -225,6 +221,11 @@ public class WebActivity extends BaseActivity {
...
@@ -225,6 +221,11 @@ public class WebActivity extends BaseActivity {
message
.
what
=
TYPE_DOWNLOAD_OK
;
message
.
what
=
TYPE_DOWNLOAD_OK
;
handler
.
sendMessage
(
message
);
handler
.
sendMessage
(
message
);
}
}
try
{
UnzipUtils
.
UnZip
(
file
.
toString
(),
AppsSettings
.
get
().
getResourcePath
());
}
catch
(
Exception
e
)
{
YGOUtil
.
show
(
"error"
+
e
);
}
}
}
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/UnzipUtils.java
View file @
288c833a
...
@@ -117,7 +117,7 @@ public class UnzipUtils {
...
@@ -117,7 +117,7 @@ public class UnzipUtils {
* @return InputStream
* @return InputStream
* @throws Exception
* @throws Exception
*/
*/
public
static
InputStream
U
p
Zip
(
String
zipFileString
,
String
fileString
)
throws
Exception
{
public
static
InputStream
U
n
Zip
(
String
zipFileString
,
String
fileString
)
throws
Exception
{
ZipFile
zipFile
=
new
ZipFile
(
zipFileString
);
ZipFile
zipFile
=
new
ZipFile
(
zipFileString
);
ZipEntry
zipEntry
=
zipFile
.
getEntry
(
fileString
);
ZipEntry
zipEntry
=
zipFile
.
getEntry
(
fileString
);
return
zipFile
.
getInputStream
(
zipEntry
);
return
zipFile
.
getInputStream
(
zipEntry
);
...
...
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