优化 #5598
This commit is contained in:
@@ -25,8 +25,14 @@ import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.ui.widget.dialog.CodeDialog
|
||||
import io.legado.app.ui.widget.dialog.WaitDialog
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.dpToPx
|
||||
import io.legado.app.utils.fromJsonObject
|
||||
import io.legado.app.utils.putPrefBoolean
|
||||
import io.legado.app.utils.setLayout
|
||||
import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import io.legado.app.utils.visible
|
||||
import splitties.views.onClick
|
||||
|
||||
/**
|
||||
@@ -223,10 +229,11 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
|
||||
binding.apply {
|
||||
cbSourceName.isChecked = viewModel.selectStatus[holder.layoutPosition]
|
||||
cbSourceName.text = item.sourceName
|
||||
tvSourceState.text = if (viewModel.checkSources[holder.layoutPosition] != null) {
|
||||
"已有"
|
||||
} else {
|
||||
"新增"
|
||||
val localSource = viewModel.checkSources[holder.layoutPosition]
|
||||
tvSourceState.text = when {
|
||||
localSource == null -> "新增"
|
||||
item.lastUpdateTime > localSource.lastUpdateTime -> "更新"
|
||||
else -> "已有"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
|
||||
allSources.forEach {
|
||||
val has = appDb.rssSourceDao.getByKey(it.sourceUrl)
|
||||
checkSources.add(has)
|
||||
selectStatus.add(has == null)
|
||||
selectStatus.add(has == null || has.lastUpdateTime < it.lastUpdateTime)
|
||||
}
|
||||
successLiveData.postValue(allSources.size)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.AppCacheManager
|
||||
import io.legado.app.help.RuleComplete
|
||||
import io.legado.app.help.http.CookieStore
|
||||
import io.legado.app.help.source.removeSortCache
|
||||
import io.legado.app.model.SharedJsScope
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.fromJsonObject
|
||||
import io.legado.app.utils.getClipText
|
||||
@@ -41,6 +43,16 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
|
||||
if (source.sourceName.isBlank() || source.sourceName.isBlank()) {
|
||||
throw NoStackTraceException(context.getString(R.string.non_null_name_url))
|
||||
}
|
||||
val oldSource = rssSource ?: RssSource()
|
||||
if (!source.equal(oldSource)) {
|
||||
source.lastUpdateTime = System.currentTimeMillis()
|
||||
if (oldSource.sortUrl != source.sortUrl) {
|
||||
oldSource.removeSortCache()
|
||||
}
|
||||
if (oldSource.jsLib != source.jsLib) {
|
||||
SharedJsScope.remove(oldSource.jsLib)
|
||||
}
|
||||
}
|
||||
rssSource?.let {
|
||||
appDb.rssSourceDao.delete(it)
|
||||
//更新收藏的源地址
|
||||
|
||||
Reference in New Issue
Block a user