|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package io.legado.app.ui.rss.article |
|
|
|
|
|
|
|
|
|
import android.app.Application |
|
|
|
|
import androidx.lifecycle.MutableLiveData |
|
|
|
|
import io.legado.app.App |
|
|
|
|
import io.legado.app.base.BaseViewModel |
|
|
|
|
import io.legado.app.model.rss.RssParser |
|
|
|
@ -10,9 +11,14 @@ import java.net.URL |
|
|
|
|
|
|
|
|
|
class RssArticlesViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
val titleLiveData = MutableLiveData<String>() |
|
|
|
|
|
|
|
|
|
fun loadContent(url: String, onFinally: () -> Unit) { |
|
|
|
|
execute { |
|
|
|
|
val rssSource = App.db.rssSourceDao().getByKey(url) |
|
|
|
|
rssSource?.let { |
|
|
|
|
titleLiveData.postValue(rssSource.sourceName) |
|
|
|
|
} |
|
|
|
|
val xml = URL(url).readText() |
|
|
|
|
if (rssSource == null || rssSource.ruleArticles.isNullOrBlank()) { |
|
|
|
|
RssParser.parseXML(xml, url).let { |
|
|
|
|