Skip to content

Commit

Permalink
Bug fix: into module settings activity when cfg not exist causes a crash
Browse files Browse the repository at this point in the history
Update version
  • Loading branch information
KyuubiRan committed Apr 27, 2021
1 parent 1c6a485 commit 2dfe203
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
24 changes: 18 additions & 6 deletions app/src/main/java/me/kyuubiran/qqcleaner/utils/ConfigManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object ConfigManager {
}

private fun <T> checkArrayHasValue(key: String, defValue: ArrayList<T>) {
if (getJsonArray(key).isNullOrEmpty()) {
if (getJsonArray(key).isNull()) {
setJsonArray(key, defValue)
}
}
Expand Down Expand Up @@ -156,7 +156,11 @@ object ConfigManager {
}

fun getJsonArray(key: String): JSONArray? {
return getConfig()?.getJSONArray(key)
return try {
getConfig()?.getJSONArray(key)
} catch (e: Exception) {
null
}
}

fun <T> JSONArray.toArrayList(): ArrayList<T> {
Expand All @@ -175,12 +179,20 @@ object ConfigManager {
return hs
}

fun JSONArray?.isNotNullOrEmpty(): Boolean {
return this != null || this?.length() != 0
fun JSONArray?.isNull(): Boolean {
return this == null
}

fun JSONArray?.isNotNull(): Boolean {
return !this.isNull()
}

fun JSONArray.isEmpty(): Boolean {
return this.length() == 0
}

fun JSONArray?.isNullOrEmpty(): Boolean {
return !this.isNotNullOrEmpty()
fun JSONArray.isNotEmpty(): Boolean {
return !this.isEmpty()
}

private fun save(jsonObject: JSONObject) {
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@
<string name="support_me">点我扶贫</string>
<string name="support_me_hint">本模块完全免费开源 一切开发旨在学习 请勿用于非法用途 喜欢本模块的可以捐赠支持我 谢谢~</string>
<string name="update_info">更新日志</string>
<string name="update_info_content">-1.7.1(35)\n
1.修复配置文件不存在时进入设置页面导致宿主崩溃的问题
<string name="update_info_content">-1.7.0(34)\n
1.极限压缩APK体积\n
2.修复强力模式开关无效的问题\n
3.现在瘦身设置完全由配置文件控制 避免一些设置与配置文件不同步的BUG\n
4.[QQ/TIM]修改部分瘦身内容 新增一些路径\n
5.新增静默模式(不弹出清理Toast)\n
6.修改Toast样式
</string>
<string name="join_qq_group">点击加入QQ群</string>
<string name="join_qq_group_hint">有问题可以来群里反馈哦~</string>
Expand Down

0 comments on commit 2dfe203

Please sign in to comment.