|
@@ -35,20 +35,23 @@ import java.util.concurrent.CountDownLatch
|
|
|
*/
|
|
|
object FoodDataProvider {
|
|
|
private val SYSTEM_MODE = BuildConfig.DEBUG
|
|
|
- private val RES_DST_PARENT = if (SYSTEM_MODE || true) {
|
|
|
- Environment.getExternalStorageDirectory()
|
|
|
- } else {
|
|
|
- globalApp().externalCacheDir!!
|
|
|
- }
|
|
|
- private val ZIP_PATH = File(RES_DST_PARENT, "cookbook/cofa_cooking.zip")
|
|
|
+ private val TARGET_DST_PARENT = Environment.getExternalStorageDirectory()
|
|
|
+ private val TARGET_PATH = File(TARGET_DST_PARENT, "cofa_cooking")
|
|
|
+ private val RES_DST_PARENT = File("vendor/bundled_uninstall_back-app/cofa_cooking")
|
|
|
+ private val ZIP_PATH = File(RES_DST_PARENT, "cofa_cooking.zip")
|
|
|
private var foodDatabase: FoodDatabase? = null
|
|
|
private var userDatabase: UserDatabase? = null
|
|
|
private var prepareLiveData = MutableLiveData<Boolean>()
|
|
|
private val preparedLock = CountDownLatch(1)
|
|
|
private val RES_DST_PATH = File(RES_DST_PARENT, "cofa_cooking")
|
|
|
-
|
|
|
private val SUCCESS_FLAG = File(RES_DST_PARENT, "success.lock")
|
|
|
|
|
|
+ init {
|
|
|
+ if (!RES_DST_PARENT.exists()) {
|
|
|
+ RES_DST_PARENT.mkdirs()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**预先准备好菜品资源包数据*/
|
|
|
fun prepareData(application: Application) {
|
|
|
var isSuccess = true
|
|
@@ -85,7 +88,7 @@ object FoodDataProvider {
|
|
|
try {
|
|
|
var targetZipFile = ZIP_PATH
|
|
|
val start = System.currentTimeMillis()
|
|
|
- ZipUtils.unzipFile(targetZipFile, RES_DST_PARENT)
|
|
|
+ ZipUtils.unzipFile(targetZipFile, TARGET_PATH)
|
|
|
Log.d(
|
|
|
"FoodDataProvider", "cost time:${System.currentTimeMillis() - start}"
|
|
|
)
|