mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-04 18:05:04 +00:00
lag Fix v1
This commit is contained in:
parent
f93e0e3c9d
commit
b776595059
2 changed files with 16 additions and 31 deletions
|
@ -1,30 +0,0 @@
|
|||
package com.vanced.manager.utils
|
||||
|
||||
import com.beust.klaxon.Json
|
||||
import com.beust.klaxon.JsonObject
|
||||
import com.beust.klaxon.Parser
|
||||
import com.github.kittinunf.fuel.coroutines.awaitString
|
||||
import com.github.kittinunf.fuel.httpGet
|
||||
|
||||
object DataManager {
|
||||
|
||||
var dataMap: HashMap<String, JsonObject> = HashMap()
|
||||
|
||||
suspend fun getCheckJson(url: String): com.beust.klaxon.JsonObject {
|
||||
if(dataMap.containsKey(url))
|
||||
{
|
||||
return dataMap[url]!!
|
||||
}
|
||||
else
|
||||
{
|
||||
dataMap[url] = getJson(url)
|
||||
return dataMap[url]!!
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getJson(url: String): com.beust.klaxon.JsonObject =
|
||||
Parser.default().parse(
|
||||
StringBuilder(url.httpGet().awaitString())
|
||||
) as com.beust.klaxon.JsonObject
|
||||
|
||||
}
|
|
@ -12,10 +12,25 @@ import kotlinx.coroutines.withContext
|
|||
|
||||
object JsonHelper {
|
||||
|
||||
var dataMap: HashMap<String, JsonObject> = HashMap()
|
||||
|
||||
suspend fun getJson(url: String): JsonObject
|
||||
{
|
||||
return DataManager.getCheckJson(url)
|
||||
if(dataMap.containsKey(url))
|
||||
{
|
||||
return dataMap[url]!!
|
||||
}
|
||||
else
|
||||
{
|
||||
dataMap[url] = getSuspendJson(url)
|
||||
return dataMap[url]!!
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSuspendJson(url: String): com.beust.klaxon.JsonObject =
|
||||
Parser.default().parse(
|
||||
StringBuilder(url.httpGet().awaitString())
|
||||
) as com.beust.klaxon.JsonObject
|
||||
|
||||
suspend fun getJsonArray(url: String): JsonArray<String> =
|
||||
Klaxon().parseArray<String>(
|
||||
|
|
Loading…
Reference in a new issue