diff --git a/app/src/main/java/io/legado/app/base/BaseViewModel.kt b/app/src/main/java/io/legado/app/base/BaseViewModel.kt index 655cd7097..e14fa7a3d 100644 --- a/app/src/main/java/io/legado/app/base/BaseViewModel.kt +++ b/app/src/main/java/io/legado/app/base/BaseViewModel.kt @@ -24,4 +24,8 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio super.onCleared() cancel() } + + open fun toast(message: Int) { + + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt index c345cccbc..6b023c7a0 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt @@ -5,12 +5,14 @@ import android.content.Intent import androidx.lifecycle.MediatorLiveData import androidx.lifecycle.MutableLiveData import io.legado.app.App +import io.legado.app.R import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookSource import io.legado.app.help.BookHelp import io.legado.app.model.WebBook +import io.legado.app.utils.toast import kotlinx.coroutines.Dispatchers.IO class ReadBookViewModel(application: Application) : BaseViewModel(application) { @@ -44,10 +46,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } }?.onError { - - } ?: let { - - } + getApplication().toast(R.string.load_toc_error) + } ?: autoChangeSource() } else { chapterMaxIndex.postValue(count) } @@ -78,6 +78,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } } + private fun autoChangeSource() { + + } interface CallBack { fun loadContentFinish(bookChapter: BookChapter, content: String) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6caf136b6..51172e3ed 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -474,4 +474,5 @@ ]]> 阅读 + 加载目录失败