|
|
|
@ -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) |
|
|
|
|