pull/83/head
kunfei 5 years ago
parent fb5d88a054
commit 8d52168468
  1. 7
      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.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.api.IHttpGetApi
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.help.http.HttpHelper import io.legado.app.help.http.HttpHelper
import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Backup
@ -174,9 +173,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
private fun importSourceUrl(url: String): Int { private fun importSourceUrl(url: String): Int {
NetworkUtils.getBaseUrl(url)?.let { HttpHelper.simpleGet(url)?.let { body ->
val response = HttpHelper.getApiService<IHttpGetApi>(it).get(url, mapOf()).execute()
response.body()?.let { body ->
val sources = mutableListOf<RssSource>() val sources = mutableListOf<RssSource>()
val items: List<Map<String, Any>> = jsonPath.parse(body).read("$") val items: List<Map<String, Any>> = jsonPath.parse(body).read("$")
for (item in items) { for (item in items) {
@ -187,7 +184,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
App.db.rssSourceDao().insert(*sources.toTypedArray()) App.db.rssSourceDao().insert(*sources.toTypedArray())
return sources.size return sources.size
}
} }
return 0 return 0
} }

Loading…
Cancel
Save