修改书籍被删除时逻辑

old
zlj 5 years ago
parent 10ad6bcd46
commit 241776fbcb
  1. 3
      app/src/main/java/com/novel/read/activity/NovelReadActivity.kt
  2. 11
      app/src/main/java/com/novel/read/fragment/BookFragment.kt

@ -80,7 +80,7 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
private val isRegistered = false private val isRegistered = false
private lateinit var mCollBook: CollBookBean private lateinit var mCollBook: CollBookBean
private var mBookId: String = "" private lateinit var mBookId: String
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
private val mHandler = object : Handler() { private val mHandler = object : Handler() {
@ -174,6 +174,7 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
} else { } else {
AccountManager.getInstance().getBookArticle(mBookId, "2", "1", "10000") AccountManager.getInstance().getBookArticle(mBookId, "2", "1", "10000")
} }
} }
override fun initData() { override fun initData() {

@ -128,11 +128,12 @@ class BookFragment : NovelBaseFragment() {
tv_delete.setOnClickListener { tv_delete.setOnClickListener {
val deleteList = mAdapter.selectList val deleteList = mAdapter.selectList
for (i in deleteList.indices) { val iterator = deleteList.iterator()
if (deleteList[i].isSaved) { while (iterator.hasNext()) {
val count = deleteList[i].delete() val collBookBean = iterator.next()
LitePal.deleteAll(BookRecordBean::class.java, "bookId=?", mList[i].id) if (collBookBean.isSaved) {
Log.e("count", "setOnClick: $count") collBookBean.delete()
LitePal.deleteAll(BookRecordBean::class.java, "bookId=?", collBookBean.id)
} }
} }
activity!!.showToast(getString(R.string.delete_success)) activity!!.showToast(getString(R.string.delete_success))

Loading…
Cancel
Save