pull/306/head
gedoor 4 years ago
parent 812c891e00
commit 552350a3be
  1. 6
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
  3. 6
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt
  4. 4
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt

@ -47,7 +47,11 @@ class ImportBookSourceActivity : VMBaseActivity<ImportBookSourceViewModel>(
}) })
viewModel.successLiveData.observe(this, Observer { viewModel.successLiveData.observe(this, Observer {
rotate_loading.hide() rotate_loading.hide()
successDialog() if (it > 0) {
successDialog()
} else {
errorDialog(getString(R.string.wrong_format))
}
}) })
initData() initData()
} }

@ -18,7 +18,7 @@ import java.io.File
class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
val errorLiveData = MutableLiveData<String>() val errorLiveData = MutableLiveData<String>()
val successLiveData = MutableLiveData<Boolean>() val successLiveData = MutableLiveData<Int>()
val allSources = arrayListOf<BookSource>() val allSources = arrayListOf<BookSource>()
val sourceCheckState = arrayListOf<Boolean>() val sourceCheckState = arrayListOf<Boolean>()
@ -110,7 +110,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
sourceCheckState.add(has) sourceCheckState.add(has)
selectStatus.add(!has) selectStatus.add(!has)
} }
successLiveData.postValue(true) successLiveData.postValue(allSources.size)
} }
} }

@ -47,7 +47,11 @@ class ImportRssSourceActivity : VMBaseActivity<ImportRssSourceViewModel>(
}) })
viewModel.successLiveData.observe(this, Observer { viewModel.successLiveData.observe(this, Observer {
rotate_loading.hide() rotate_loading.hide()
successDialog() if (it > 0) {
successDialog()
} else {
errorDialog(getString(R.string.wrong_format))
}
}) })
initData() initData()
} }

@ -17,7 +17,7 @@ import java.io.File
class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) { class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
val errorLiveData = MutableLiveData<String>() val errorLiveData = MutableLiveData<String>()
val successLiveData = MutableLiveData<Boolean>() val successLiveData = MutableLiveData<Int>()
val allSources = arrayListOf<RssSource>() val allSources = arrayListOf<RssSource>()
val sourceCheckState = arrayListOf<Boolean>() val sourceCheckState = arrayListOf<Boolean>()
@ -105,7 +105,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
sourceCheckState.add(has) sourceCheckState.add(has)
selectStatus.add(!has) selectStatus.add(!has)
} }
successLiveData.postValue(true) successLiveData.postValue(allSources.size)
} }
} }

Loading…
Cancel
Save