|
|
@ -6,12 +6,14 @@ import androidx.lifecycle.MutableLiveData |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.base.BaseViewModel |
|
|
|
import io.legado.app.base.BaseViewModel |
|
|
|
import io.legado.app.data.entities.RssArticle |
|
|
|
import io.legado.app.data.entities.RssArticle |
|
|
|
|
|
|
|
import io.legado.app.data.entities.RssSource |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeRule |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeRule |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
|
|
|
|
|
|
|
|
class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
var rssArticle: RssArticle? = null |
|
|
|
var rssArticle: RssArticle? = null |
|
|
|
|
|
|
|
val rssSourceLiveData = MutableLiveData<RssSource>() |
|
|
|
val contentLiveData = MutableLiveData<String>() |
|
|
|
val contentLiveData = MutableLiveData<String>() |
|
|
|
val urlLiveData = MutableLiveData<String>() |
|
|
|
val urlLiveData = MutableLiveData<String>() |
|
|
|
|
|
|
|
|
|
|
@ -19,14 +21,18 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val origin = intent.getStringExtra("origin") |
|
|
|
val origin = intent.getStringExtra("origin") |
|
|
|
val title = intent.getStringExtra("title") |
|
|
|
val title = intent.getStringExtra("title") |
|
|
|
|
|
|
|
val rssSource = App.db.rssSourceDao().getByKey(origin) |
|
|
|
|
|
|
|
rssSource?.let { |
|
|
|
|
|
|
|
rssSourceLiveData.postValue(it) |
|
|
|
|
|
|
|
} |
|
|
|
if (origin != null && title != null) { |
|
|
|
if (origin != null && title != null) { |
|
|
|
rssArticle = App.db.rssArtivleDao().get(origin, title) |
|
|
|
rssArticle = App.db.rssArticleDao().get(origin, title) |
|
|
|
rssArticle?.let { rssArticle -> |
|
|
|
rssArticle?.let { rssArticle -> |
|
|
|
if (!rssArticle.description.isNullOrBlank()) { |
|
|
|
if (!rssArticle.description.isNullOrBlank()) { |
|
|
|
contentLiveData.postValue(rssArticle.description) |
|
|
|
contentLiveData.postValue(rssArticle.description) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
App.db.rssSourceDao().getByKey(rssArticle.origin)?.let { source -> |
|
|
|
rssSource?.let { |
|
|
|
val ruleContent = source.ruleContent |
|
|
|
val ruleContent = rssSource.ruleContent |
|
|
|
if (!ruleContent.isNullOrBlank()) { |
|
|
|
if (!ruleContent.isNullOrBlank()) { |
|
|
|
loadContent(rssArticle, ruleContent) |
|
|
|
loadContent(rssArticle, ruleContent) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|