0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-23 11:45:11 +00:00

fixed crashes

This commit is contained in:
X1nto 2020-07-12 22:33:14 +04:00
parent 31b1c7aef7
commit 292405b05e
2 changed files with 4 additions and 4 deletions

View file

@ -29,7 +29,7 @@ object InternetTools {
suspend fun getObjectFromJson(url: String, obj: String): String {
return try {
JsonHelper.getJson(url).get(obj).asString ?: ""
JsonHelper.getJson(url).string(obj) ?: ""
} catch (e: Exception) {
Log.e(TAG, "Error: ", e)
""
@ -39,7 +39,7 @@ object InternetTools {
suspend fun getJsonInt(file: String, obj: String, context: Context): Int {
val installUrl = getDefaultSharedPreferences(context).getString("install_url", baseUrl)
return try {
JsonHelper.getJson("$installUrl/$file").get(obj).asInt
JsonHelper.getJson("$installUrl/$file").int(obj) ?: 0
} catch (e: Exception) {
Log.e(TAG, "Error: ", e)
0
@ -49,7 +49,7 @@ object InternetTools {
suspend fun getJsonString(file: String, obj: String, context: Context): String {
val installUrl = getDefaultSharedPreferences(context).getString("install_url", baseUrl)
return try {
JsonHelper.getJson("$installUrl/$file").get(obj).asString ?: context.getString(R.string.unavailable)
JsonHelper.getJson("$installUrl/$file").string(obj) ?: context.getString(R.string.unavailable)
} catch (e: Exception) {
Log.e(TAG, "Error: ", e)
context.getString(R.string.unavailable)

View file

@ -1,9 +1,9 @@
package com.vanced.manager.utils
import com.beust.klaxon.JsonObject
import com.beust.klaxon.Parser
import com.github.kittinunf.fuel.coroutines.awaitString
import com.github.kittinunf.fuel.httpGet
import com.google.gson.JsonObject
object JsonHelper {