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
f25c0336
Commit
f25c0336
authored
Jan 02, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
textures文件夹检查优化
数据库检查优化
parent
b64b2b95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+16
-14
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
f25c0336
...
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
...
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
android.content.res.AssetManager
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteException
;
import
android.database.sqlite.SQLiteException
;
...
@@ -144,11 +145,15 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -144,11 +145,15 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SINGLE_PATH
),
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SINGLE_PATH
),
mSettings
.
getSingleDir
(),
needsUpdate
);
mSettings
.
getSingleDir
(),
needsUpdate
);
}
}
//复制贴图
String
[]
textures1
=
mContext
.
getAssets
().
list
(
getDatapath
(
Constants
.
CORE_SKIN_PATH
));
if
(
needsUpdate
)
{
String
[]
textures2
=
new
File
(
mSettings
.
getCoreSkinPath
()).
list
();
//复制资源文件夹
//如果textures文件夹不存在/textures资源数量不够/是更新则复制
if
(
textures2
==
null
||(
textures1
!=
null
&&
textures1
.
length
>
textures2
.
length
)||
needsUpdate
)
{
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
game_skins
)));
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
game_skins
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
mSettings
.
getCoreSkinPath
(),
fals
e
);
mSettings
.
getCoreSkinPath
(),
needsUpdat
e
);
}
}
//复制字体
//复制字体
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
font_files
)));
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
font_files
)));
...
@@ -161,7 +166,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -161,7 +166,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
resPath
,
needsUpdate
);
resPath
,
needsUpdate
);
}
}
//复制数据库
//复制数据库
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
cards_cdb
)));
copyCdbFile
(
needsUpdate
);
copyCdbFile
(
needsUpdate
);
//复制卡图压缩包
//复制卡图压缩包
if
(
IOUtils
.
hasAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
if
(
IOUtils
.
hasAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
...
@@ -190,18 +194,16 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -190,18 +194,16 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
void
copyCdbFile
(
boolean
needsUpdate
)
throws
IOException
{
void
copyCdbFile
(
boolean
needsUpdate
)
throws
IOException
{
File
dbFile
=
new
File
(
mSettings
.
getDataBasePath
(),
DATABASE_NAME
);
File
dbFile
=
new
File
(
mSettings
.
getDataBasePath
(),
DATABASE_NAME
);
boolean
copyDb
=
true
;
//如果数据库存在
if
(
dbFile
.
exists
()&&
dbFile
.
length
()<
1024
*
1024
)
{
if
(
dbFile
.
exists
())
{
copyDb
=
false
;
//如果是更新或者数据库大小小于1m
if
(
needsUpdate
)
{
if
(
needsUpdate
||
dbFile
.
length
()
<
1024
*
1024
)
copyDb
=
true
;
dbFile
.
delete
();
dbFile
.
delete
();
}
else
}
return
;
if
(
copyDb
)
{
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
DATABASE_NAME
),
mSettings
.
getDataBasePath
(),
needsUpdate
);
// doSomeTrickOnDatabase(dbFile.getAbsolutePath());
}
}
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
cards_cdb
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
DATABASE_NAME
),
mSettings
.
getDataBasePath
(),
needsUpdate
);
}
}
public
static
boolean
checkDataBase
(
String
path
)
{
public
static
boolean
checkDataBase
(
String
path
)
{
...
...
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