|
|
@ -17,6 +17,7 @@ import xyz.fycz.myreader.model.third3.http.text |
|
|
|
import xyz.fycz.myreader.util.SharedPreUtils |
|
|
|
import xyz.fycz.myreader.util.SharedPreUtils |
|
|
|
import xyz.fycz.myreader.util.ToastUtils |
|
|
|
import xyz.fycz.myreader.util.ToastUtils |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -38,7 +39,7 @@ object PluginUtils { |
|
|
|
config = GSON.fromJsonObject<PluginConfig>(configJson) |
|
|
|
config = GSON.fromJsonObject<PluginConfig>(configJson) |
|
|
|
val oldConfig = GSON.fromJsonObject<PluginConfig>( |
|
|
|
val oldConfig = GSON.fromJsonObject<PluginConfig>( |
|
|
|
SharedPreUtils.getInstance().getString("pluginConfig") |
|
|
|
SharedPreUtils.getInstance().getString("pluginConfig") |
|
|
|
) ?: PluginConfig("dynamic.dex", 100, "", "", "") |
|
|
|
) ?: PluginConfig("dynamic.dex", 100) |
|
|
|
if (config != null) { |
|
|
|
if (config != null) { |
|
|
|
if (config!!.versionCode > oldConfig.versionCode) { |
|
|
|
if (config!!.versionCode > oldConfig.versionCode) { |
|
|
|
downloadPlugin(config!!) |
|
|
|
downloadPlugin(config!!) |
|
|
@ -47,6 +48,11 @@ object PluginUtils { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
config = oldConfig |
|
|
|
config = oldConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (config!!.md5.lowercase(Locale.getDefault()) |
|
|
|
|
|
|
|
!= getPluginMD5(config!!)?.lowercase(Locale.getDefault()) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
downloadPlugin(config!!) |
|
|
|
|
|
|
|
} |
|
|
|
}.onSuccess { |
|
|
|
}.onSuccess { |
|
|
|
loadAppLoader(App.getmContext(), config) |
|
|
|
loadAppLoader(App.getmContext(), config) |
|
|
|
} |
|
|
|
} |
|
|
@ -60,6 +66,10 @@ object PluginUtils { |
|
|
|
.writeBytes(res.byteStream().readBytes()) |
|
|
|
.writeBytes(res.byteStream().readBytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getPluginMD5(config: PluginConfig): String? { |
|
|
|
|
|
|
|
return MD5Utils.getFileMD5s(FileUtils.getFile(APPCONST.PLUGIN_DIR_PATH + config.name), 32) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun loadAppLoader(context: Context, config: PluginConfig?) { |
|
|
|
private fun loadAppLoader(context: Context, config: PluginConfig?) { |
|
|
|
config?.let { |
|
|
|
config?.let { |
|
|
|
val pluginPath = APPCONST.PLUGIN_DIR_PATH + it.name |
|
|
|
val pluginPath = APPCONST.PLUGIN_DIR_PATH + it.name |
|
|
|