Commit ea30dfb9514a80b6936f083b9da01df20f7b10ee
1 parent
81dbb8ad
update db crash failure ,change package name
Showing
3 changed files
with
32 additions
and
9 deletions
| @@ -2,14 +2,27 @@ package com.gimi.common.cinema.utils; | @@ -2,14 +2,27 @@ package com.gimi.common.cinema.utils; | ||
| 2 | 2 | ||
| 3 | import android.text.TextUtils; | 3 | import android.text.TextUtils; |
| 4 | import android.util.Log; | 4 | import android.util.Log; |
| 5 | -import android.view.TextureView; | ||
| 6 | - | ||
| 7 | import com.gimi.common.cinema.model.CinemaConfig; | 5 | import com.gimi.common.cinema.model.CinemaConfig; |
| 8 | import com.google.gson.Gson; | 6 | import com.google.gson.Gson; |
| 9 | import com.google.gson.JsonSyntaxException; | 7 | import com.google.gson.JsonSyntaxException; |
| 10 | import com.google.gson.reflect.TypeToken; | 8 | import com.google.gson.reflect.TypeToken; |
| 11 | 9 | ||
| 12 | -import java.io.*; | 10 | +import java.io.BufferedReader; |
| 11 | +import java.io.BufferedWriter; | ||
| 12 | +import java.io.ByteArrayInputStream; | ||
| 13 | +import java.io.ByteArrayOutputStream; | ||
| 14 | +import java.io.File; | ||
| 15 | +import java.io.FileInputStream; | ||
| 16 | +import java.io.FileNotFoundException; | ||
| 17 | +import java.io.FileOutputStream; | ||
| 18 | +import java.io.FileReader; | ||
| 19 | +import java.io.FileWriter; | ||
| 20 | +import java.io.IOException; | ||
| 21 | +import java.io.InputStream; | ||
| 22 | +import java.io.InputStreamReader; | ||
| 23 | +import java.io.RandomAccessFile; | ||
| 24 | +import java.io.Reader; | ||
| 25 | +import java.io.UnsupportedEncodingException; | ||
| 13 | import java.util.ArrayList; | 26 | import java.util.ArrayList; |
| 14 | 27 | ||
| 15 | import static com.nostra13.universalimageloader.core.download.BaseImageDownloader.XOR_CONST; | 28 | import static com.nostra13.universalimageloader.core.download.BaseImageDownloader.XOR_CONST; |
| @@ -281,11 +294,11 @@ public class FileReadUtils { | @@ -281,11 +294,11 @@ public class FileReadUtils { | ||
| 281 | // } | 294 | // } |
| 282 | String regex = "^(-?[1-9]\\d*\\.?\\d*)|(-?0\\.\\d*[1-9])|(-?[0])|(-?[0]\\.\\d*)$"; | 295 | String regex = "^(-?[1-9]\\d*\\.?\\d*)|(-?0\\.\\d*[1-9])|(-?[0])|(-?[0]\\.\\d*)$"; |
| 283 | if (trim.matches(regex)) { | 296 | if (trim.matches(regex)) { |
| 284 | - count = Integer.parseInt(trim); | 297 | + count = Integer.parseInt(trim);//转化失败则返回0 |
| 285 | } else { | 298 | } else { |
| 286 | return 0; | 299 | return 0; |
| 287 | } | 300 | } |
| 288 | - } catch (IOException e) { | 301 | + } catch (Exception e) { |
| 289 | e.printStackTrace(); | 302 | e.printStackTrace(); |
| 290 | return count; | 303 | return count; |
| 291 | } | 304 | } |
| @@ -35,7 +35,7 @@ public class FangTangApplication extends TelinkApplication { | @@ -35,7 +35,7 @@ public class FangTangApplication extends TelinkApplication { | ||
| 35 | * | 35 | * |
| 36 | *@see com.telink.bluetooth.light.model.Mesh#saveOrUpdate | 36 | *@see com.telink.bluetooth.light.model.Mesh#saveOrUpdate |
| 37 | */ | 37 | */ |
| 38 | - //TODO save by json string | 38 | + //save by json string |
| 39 | if (FileSystem.exists(Mesh.MESH_FILE_NAME)) { | 39 | if (FileSystem.exists(Mesh.MESH_FILE_NAME)) { |
| 40 | String string = Utils.getString(this, "mesh-config"); | 40 | String string = Utils.getString(this, "mesh-config"); |
| 41 | this.mesh = new Gson().fromJson(string, Mesh.class); | 41 | this.mesh = new Gson().fromJson(string, Mesh.class); |
| @@ -18,7 +18,7 @@ package com.xgimi.gimicinema.model; | @@ -18,7 +18,7 @@ package com.xgimi.gimicinema.model; | ||
| 18 | import android.content.Context; | 18 | import android.content.Context; |
| 19 | import android.os.Handler; | 19 | import android.os.Handler; |
| 20 | import android.support.annotation.NonNull; | 20 | import android.support.annotation.NonNull; |
| 21 | - | 21 | +import android.text.TextUtils; |
| 22 | import com.gimi.common.cinema.db.NewDBManager; | 22 | import com.gimi.common.cinema.db.NewDBManager; |
| 23 | import com.gimi.common.cinema.model.SambaMsg; | 23 | import com.gimi.common.cinema.model.SambaMsg; |
| 24 | import com.gimi.common.cinema.utils.AdsVideoUtils; | 24 | import com.gimi.common.cinema.utils.AdsVideoUtils; |
| @@ -43,9 +43,9 @@ public class UpdateModelImpl implements IUpdateModel { | @@ -43,9 +43,9 @@ public class UpdateModelImpl implements IUpdateModel { | ||
| 43 | = "xgimi_cinema_movie.db_bak"; | 43 | = "xgimi_cinema_movie.db_bak"; |
| 44 | private static final String DB_NAME_HIMEDIA | 44 | private static final String DB_NAME_HIMEDIA |
| 45 | = "xgimi_cinema_movie_himedia.db"; | 45 | = "xgimi_cinema_movie_himedia.db"; |
| 46 | - private static final String CINEMA_DB_PATH | 46 | + private static String CINEMA_DB_PATH |
| 47 | = "/data/data/com.xgimi.gimicinema/databases/" + DB_NAME; | 47 | = "/data/data/com.xgimi.gimicinema/databases/" + DB_NAME; |
| 48 | - private static final String CINEMA_DB_BAK_PATH | 48 | + private static String CINEMA_DB_BAK_PATH |
| 49 | = "/data/data/com.xgimi.gimicinema/databases/" + DB_NAME_BACK; | 49 | = "/data/data/com.xgimi.gimicinema/databases/" + DB_NAME_BACK; |
| 50 | 50 | ||
| 51 | private AppUpdateUtils appUpdateUtils; | 51 | private AppUpdateUtils appUpdateUtils; |
| @@ -97,6 +97,7 @@ public class UpdateModelImpl implements IUpdateModel { | @@ -97,6 +97,7 @@ public class UpdateModelImpl implements IUpdateModel { | ||
| 97 | 97 | ||
| 98 | @Override | 98 | @Override |
| 99 | public void updateServerDb(final Context context, final OnCopyDbListener l) { | 99 | public void updateServerDb(final Context context, final OnCopyDbListener l) { |
| 100 | + resetPackage(context); | ||
| 100 | ThreadUtils.subThread(new ThreadUtils.DoSomeThing() { | 101 | ThreadUtils.subThread(new ThreadUtils.DoSomeThing() { |
| 101 | @Override | 102 | @Override |
| 102 | public void doSomeThing() { | 103 | public void doSomeThing() { |
| @@ -132,8 +133,17 @@ public class UpdateModelImpl implements IUpdateModel { | @@ -132,8 +133,17 @@ public class UpdateModelImpl implements IUpdateModel { | ||
| 132 | }); | 133 | }); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 136 | + private void resetPackage(Context context) { | ||
| 137 | + String packageName = context.getPackageName(); | ||
| 138 | + if (!TextUtils.isEmpty(packageName)) { | ||
| 139 | + CINEMA_DB_PATH = CINEMA_DB_PATH.replace("com.xgimi.gimicinema", packageName); | ||
| 140 | + CINEMA_DB_BAK_PATH = CINEMA_DB_BAK_PATH.replace("com.xgimi.gimicinema", packageName); | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + | ||
| 135 | @Override | 144 | @Override |
| 136 | public void updateLocalDb(final Context context, final OnCopyDbListener l) { | 145 | public void updateLocalDb(final Context context, final OnCopyDbListener l) { |
| 146 | + resetPackage(context); | ||
| 137 | ThreadUtils.subThread(new ThreadUtils.DoSomeThing() { | 147 | ThreadUtils.subThread(new ThreadUtils.DoSomeThing() { |
| 138 | @Override | 148 | @Override |
| 139 | public void doSomeThing() { | 149 | public void doSomeThing() { |
Please
register
or
login
to post a comment