pull/1006/head
gedoor 4 years ago
parent 8666ca06af
commit 229e37acc3
  1. 20
      app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 9
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  4. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt

@ -14,7 +14,10 @@ import io.legado.app.data.entities.ReadRecordShow
import io.legado.app.databinding.ActivityReadRecordBinding
import io.legado.app.databinding.ItemReadRecordBinding
import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.utils.cnCompare
import io.legado.app.utils.startActivity
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
@ -111,6 +114,23 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
override fun registerListener(holder: ItemViewHolder, binding: ItemReadRecordBinding) {
binding.apply {
root.setOnClickListener {
val item = getItem(holder.layoutPosition) ?: return@setOnClickListener
launch {
val book = withContext(IO) {
appDb.bookDao.findByName(item.bookName).firstOrNull()
}
if (book == null) {
startActivity<SearchActivity> {
putExtra("key", item.bookName)
}
} else {
startActivity<ReadBookActivity> {
putExtra("bookUrl", book.bookUrl)
}
}
}
}
tvRemove.setOnClickListener {
getItem(holder.layoutPosition)?.let { item ->
sureDelAlert(item)

@ -22,7 +22,6 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.databinding.ActivityBookInfoBinding
import io.legado.app.help.BlurTransformation
import io.legado.app.help.ImageLoader
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.bottomBackground
@ -361,7 +360,6 @@ class BookInfoActivity :
Intent(this, ReadBookActivity::class.java)
.putExtra("bookUrl", book.bookUrl)
.putExtra("inBookshelf", viewModel.inBookshelf)
.putExtra("key", IntentDataHelp.putData(book))
)
}
}

@ -10,7 +10,6 @@ import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookProgress
import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.help.IntentDataHelp
import io.legado.app.help.storage.BookWebDav
import io.legado.app.model.localBook.LocalBook
import io.legado.app.model.webBook.PreciseSearch
@ -30,9 +29,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun initData(intent: Intent) {
execute {
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
IntentDataHelp.getData<Book>(intent.getStringExtra("key"))?.let {
initBook(it)
} ?: intent.getStringExtra("bookUrl")?.let {
intent.getStringExtra("bookUrl")?.let {
appDb.bookDao.getBook(it)?.let { book ->
initBook(book)
}
@ -40,9 +37,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
initBook(it)
}
}.onFinally {
if (ReadBook.inBookshelf) {
ReadBook.saveRead()
}
ReadBook.saveRead()
}
}

@ -18,7 +18,6 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
import io.legado.app.databinding.FragmentBooksBinding
import io.legado.app.help.AppConfig
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.audio.AudioPlayActivity
@ -149,7 +148,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
}
else -> startActivity<ReadBookActivity> {
putExtra("bookUrl", book.bookUrl)
putExtra("key", IntentDataHelp.putData(book))
}
}
}

Loading…
Cancel
Save