Commit f25c0336 authored by feihuaduo's avatar feihuaduo

textures文件夹检查优化

数据库检查优化
parent b64b2b95
...@@ -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(), false); mSettings.getCoreSkinPath(), needsUpdate);
} }
//复制字体 //复制字体
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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment