manager: Fix remote template fetch error.
This commit is contained in:
@@ -88,10 +88,10 @@ class TemplateViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchRemoteTemplates() {
|
private fun fetchRemoteTemplates() {
|
||||||
OkHttpClient().newCall(
|
runCatching {
|
||||||
Request.Builder().url(TEMPLATE_INDEX_URL).build()
|
OkHttpClient().newCall(
|
||||||
).runCatching {
|
Request.Builder().url(TEMPLATE_INDEX_URL).build()
|
||||||
execute().use { response ->
|
).execute().use { response ->
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -125,9 +125,7 @@ private fun fetchRemoteTemplates() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.onFailure {
|
}.onFailure { Log.e(TAG, "fetchRemoteTemplates: $it", it) }
|
||||||
Log.e(TAG, "fetchRemoteTemplates error", it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@@ -168,7 +166,7 @@ private fun fromJSON(templateJson: JSONObject): TemplateViewModel.TemplateInfo?
|
|||||||
id = templateJson.getString("id"),
|
id = templateJson.getString("id"),
|
||||||
name = templateJson.getString("name"),
|
name = templateJson.getString("name"),
|
||||||
description = templateJson.getString("description"),
|
description = templateJson.getString("description"),
|
||||||
local = templateJson.getBoolean("local"),
|
local = templateJson.optBoolean("local"),
|
||||||
namespace = Natives.Profile.Namespace.valueOf(
|
namespace = Natives.Profile.Namespace.valueOf(
|
||||||
templateJson.getString("namespace").uppercase()
|
templateJson.getString("namespace").uppercase()
|
||||||
).ordinal,
|
).ordinal,
|
||||||
|
|||||||
Reference in New Issue
Block a user