pull/32/head
kunfei 5 years ago
parent 471a08a7b1
commit a41346b6de
  1. 4
      app/src/main/java/io/legado/app/base/BaseViewModel.kt
  2. 11
      app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt
  3. 1
      app/src/main/res/values/strings.xml

@ -24,4 +24,8 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio
super.onCleared() super.onCleared()
cancel() cancel()
} }
open fun toast(message: Int) {
}
} }

@ -5,12 +5,14 @@ import android.content.Intent
import androidx.lifecycle.MediatorLiveData import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import io.legado.app.App import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import io.legado.app.utils.toast
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
class ReadBookViewModel(application: Application) : BaseViewModel(application) { class ReadBookViewModel(application: Application) : BaseViewModel(application) {
@ -44,10 +46,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
}?.onError { }?.onError {
getApplication<App>().toast(R.string.load_toc_error)
} ?: let { } ?: autoChangeSource()
}
} else { } else {
chapterMaxIndex.postValue(count) chapterMaxIndex.postValue(count)
} }
@ -78,6 +78,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
} }
private fun autoChangeSource() {
}
interface CallBack { interface CallBack {
fun loadContentFinish(bookChapter: BookChapter, content: String) fun loadContentFinish(bookChapter: BookChapter, content: String)

@ -474,4 +474,5 @@
<string name="dsm_start"><![CDATA[<]]></string> <string name="dsm_start"><![CDATA[<]]></string>
<string name="dsm_end"><![CDATA[>]]></string> <string name="dsm_end"><![CDATA[>]]></string>
<string name="reading">阅读</string> <string name="reading">阅读</string>
<string name="load_toc_error">加载目录失败</string>
</resources> </resources>

Loading…
Cancel
Save