From 8d52168468091facabadeda227c8d9a5cb6ff309 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 30 Jan 2020 15:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rss/source/manage/RssSourceViewModel.kt | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index bf82505d3..bed9a6e62 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -6,7 +6,6 @@ import com.jayway.jsonpath.JsonPath import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseViewModel -import io.legado.app.data.api.IHttpGetApi import io.legado.app.data.entities.RssSource import io.legado.app.help.http.HttpHelper import io.legado.app.help.storage.Backup @@ -174,20 +173,18 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) } private fun importSourceUrl(url: String): Int { - NetworkUtils.getBaseUrl(url)?.let { - val response = HttpHelper.getApiService(it).get(url, mapOf()).execute() - response.body()?.let { body -> - val sources = mutableListOf() - val items: List> = jsonPath.parse(body).read("$") - for (item in items) { - val jsonItem = jsonPath.parse(item) - GSON.fromJsonObject(jsonItem.jsonString())?.let { source -> - sources.add(source) - } + HttpHelper.simpleGet(url)?.let { body -> + val sources = mutableListOf() + val items: List> = jsonPath.parse(body).read("$") + for (item in items) { + val jsonItem = jsonPath.parse(item) + GSON.fromJsonObject(jsonItem.jsonString())?.let { source -> + sources.add(source) } - App.db.rssSourceDao().insert(*sources.toTypedArray()) - return sources.size } + App.db.rssSourceDao().insert(*sources.toTypedArray()) + return sources.size + } return 0 }