|
|
@ -3,15 +3,19 @@ package io.legado.app.ui.book.bookmark |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.activity.viewModels |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
|
|
|
|
import io.legado.app.data.entities.Bookmark |
|
|
|
import io.legado.app.databinding.ActivityAllBookmarkBinding |
|
|
|
import io.legado.app.databinding.ActivityAllBookmarkBinding |
|
|
|
|
|
|
|
import io.legado.app.utils.showDialogFragment |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
|
|
|
|
|
|
|
|
class AllBookmarkActivity : VMBaseActivity<ActivityAllBookmarkBinding, AllBookmarkViewModel>() { |
|
|
|
class AllBookmarkActivity : VMBaseActivity<ActivityAllBookmarkBinding, AllBookmarkViewModel>(), |
|
|
|
|
|
|
|
BookmarkAdapter.Callback, |
|
|
|
|
|
|
|
BookmarkDialog.Callback { |
|
|
|
|
|
|
|
|
|
|
|
override val viewModel by viewModels<AllBookmarkViewModel>() |
|
|
|
override val viewModel by viewModels<AllBookmarkViewModel>() |
|
|
|
override val binding by viewBinding(ActivityAllBookmarkBinding::inflate) |
|
|
|
override val binding by viewBinding(ActivityAllBookmarkBinding::inflate) |
|
|
|
private val adapter by lazy { |
|
|
|
private val adapter by lazy { |
|
|
|
BookmarkAdapter(this) |
|
|
|
BookmarkAdapter(this, this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
@ -26,5 +30,18 @@ class AllBookmarkActivity : VMBaseActivity<ActivityAllBookmarkBinding, AllBookma |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onItemClick(bookmark: Bookmark, position: Int) { |
|
|
|
|
|
|
|
showDialogFragment(BookmarkDialog(bookmark, position)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun upBookmark(pos: Int, bookmark: Bookmark) { |
|
|
|
|
|
|
|
adapter.setItem(pos, bookmark) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun deleteBookmark(pos: Int) { |
|
|
|
|
|
|
|
adapter.getItem(pos)?.let { |
|
|
|
|
|
|
|
viewModel.deleteBookmark(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
adapter.removeItem(pos) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |