Removing deprecated use of adapterPosition

This commit is contained in:
Jays2Kings 2021-03-26 15:21:18 -04:00
parent 8556aba3ca
commit 4df422d2e0
21 changed files with 60 additions and 60 deletions

View File

@ -91,7 +91,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
) )
) )
reorder.setOnClickListener { reorder.setOnClickListener {
adapter.categoryItemListener.onItemDelete(adapterPosition) adapter.categoryItemListener.onItemDelete(flexibleAdapterPosition)
} }
} }
} else { } else {
@ -117,7 +117,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
private fun submitChanges() { private fun submitChanges() {
if (edit_text.visibility == View.VISIBLE) { if (edit_text.visibility == View.VISIBLE) {
if (adapter.categoryItemListener if (adapter.categoryItemListener
.onCategoryRename(adapterPosition, edit_text.text.toString()) .onCategoryRename(flexibleAdapterPosition, edit_text.text.toString())
) { ) {
isEditing(false) isEditing(false)
edit_text.inputType = InputType.TYPE_NULL edit_text.inputType = InputType.TYPE_NULL

View File

@ -52,7 +52,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
notifyDownloadedPages() notifyDownloadedPages()
} }
migration_menu.visibleIf(adapterPosition != 0 || adapterPosition != adapter.itemCount - 1) migration_menu.visibleIf(flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1)
migration_menu.setVectorCompat( migration_menu.setVectorCompat(
R.drawable.ic_more_vert_24dp, R.drawable.ic_more_vert_24dp,
view.context view.context
@ -85,7 +85,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
} }
private fun showPopupMenu(view: View) { private fun showPopupMenu(view: View) {
val item = adapter.getItem(adapterPosition) ?: return val item = adapter.getItem(flexibleAdapterPosition) ?: return
// Create a PopupMenu, giving it the clicked view for an anchor // Create a PopupMenu, giving it the clicked view for an anchor
val popup = PopupMenu(view.context, view) val popup = PopupMenu(view.context, view)
@ -95,13 +95,13 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
val download = item.download val download = item.download
popup.menu.findItem(R.id.move_to_top).isVisible = adapterPosition != 0 popup.menu.findItem(R.id.move_to_top).isVisible = flexibleAdapterPosition != 0
popup.menu.findItem(R.id.move_to_bottom).isVisible = adapterPosition != adapter popup.menu.findItem(R.id.move_to_bottom).isVisible = flexibleAdapterPosition != adapter
.itemCount - 1 .itemCount - 1
// Set a listener so we are notified if a menu item is clicked // Set a listener so we are notified if a menu item is clicked
popup.setOnMenuItemClickListener { menuItem -> popup.setOnMenuItemClickListener { menuItem ->
adapter.downloadItemListener.onMenuItemClick(adapterPosition, menuItem) adapter.downloadItemListener.onMenuItemClick(flexibleAdapterPosition, menuItem)
true true
} }

View File

@ -26,7 +26,7 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
init { init {
ext_button.setOnClickListener { ext_button.setOnClickListener {
adapter.buttonClickListener.onButtonClick(adapterPosition) adapter.buttonClickListener.onButtonClick(flexibleAdapterPosition)
} }
} }

View File

@ -1168,7 +1168,7 @@ class LibraryController(
} }
override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) { override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
val position = viewHolder?.adapterPosition ?: return val position = viewHolder?.bindingAdapterPosition ?: return
swipe_refresh.isEnabled = actionState != ItemTouchHelper.ACTION_STATE_DRAG swipe_refresh.isEnabled = actionState != ItemTouchHelper.ACTION_STATE_DRAG
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
if (lastItemPosition != null && if (lastItemPosition != null &&

View File

@ -68,9 +68,9 @@ class LibraryGridHolder(
if (item.manga.thumbnail_url == null) cover_thumbnail.clear() if (item.manga.thumbnail_url == null) cover_thumbnail.clear()
else { else {
if (cover_thumbnail.height == 0) { if (cover_thumbnail.height == 0) {
val oldPos = adapterPosition val oldPos = flexibleAdapterPosition
adapter.recyclerView.post { adapter.recyclerView.post {
if (oldPos == adapterPosition) { if (oldPos == flexibleAdapterPosition) {
setCover(item.manga) setCover(item.manga)
} }
} }
@ -89,7 +89,7 @@ class LibraryGridHolder(
} }
private fun playButtonClicked() { private fun playButtonClicked() {
adapter.libraryListener.startReading(adapterPosition) adapter.libraryListener.startReading(flexibleAdapterPosition)
} }
override fun onActionStateChanged(position: Int, actionState: Int) { override fun onActionStateChanged(position: Int, actionState: Int) {

View File

@ -43,8 +43,8 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
category_header_layout.setOnClickListener { toggleCategory() } category_header_layout.setOnClickListener { toggleCategory() }
updateButton.setOnClickListener { addCategoryToUpdate() } updateButton.setOnClickListener { addCategoryToUpdate() }
sectionText.setOnLongClickListener { sectionText.setOnLongClickListener {
val category = (adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category val category = (adapter.getItem(flexibleAdapterPosition) as? LibraryHeaderItem)?.category
adapter.libraryListener.manageCategory(adapterPosition) adapter.libraryListener.manageCategory(flexibleAdapterPosition)
category?.isDynamic == false category?.isDynamic == false
} }
sectionText.setOnClickListener { toggleCategory() } sectionText.setOnClickListener { toggleCategory() }
@ -54,7 +54,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
} }
private fun toggleCategory() { private fun toggleCategory() {
adapter.libraryListener.toggleCategoryVisibility(adapterPosition) adapter.libraryListener.toggleCategoryVisibility(flexibleAdapterPosition)
val tutorial = Injekt.get<PreferencesHelper>().shownLongPressCategoryTutorial() val tutorial = Injekt.get<PreferencesHelper>().shownLongPressCategoryTutorial()
if (!tutorial.get()) { if (!tutorial.get()) {
ViewTooltip.on(itemView.context as? Activity, sectionText).autoHide(true, 5000L) ViewTooltip.on(itemView.context as? Activity, sectionText).autoHide(true, 5000L)
@ -151,7 +151,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
} }
private fun addCategoryToUpdate() { private fun addCategoryToUpdate() {
if (adapter.libraryListener.updateCategory(adapterPosition)) { if (adapter.libraryListener.updateCategory(flexibleAdapterPosition)) {
catProgress.visible() catProgress.visible()
updateButton.invisible() updateButton.invisible()
} }
@ -159,7 +159,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
private fun showCatSortOptions() { private fun showCatSortOptions() {
val category = val category =
(adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category ?: return (adapter.getItem(flexibleAdapterPosition) as? LibraryHeaderItem)?.category ?: return
adapter.controller.activity?.let { activity -> adapter.controller.activity?.let { activity ->
val items = mutableListOf( val items = mutableListOf(
MaterialMenuSheet.MenuSheetItem( MaterialMenuSheet.MenuSheetItem(
@ -210,7 +210,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
sortingMode sortingMode
) { sheet, item -> ) { sheet, item ->
onCatSortClicked(category, item) onCatSortClicked(category, item)
val nCategory = (adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category val nCategory = (adapter.getItem(flexibleAdapterPosition) as? LibraryHeaderItem)?.category
val isAscending = nCategory?.isAscending() ?: false val isAscending = nCategory?.isAscending() ?: false
val drawableRes = getSortRes(item, isAscending) val drawableRes = getSortRes(item, isAscending)
sheet.setDrawable(item, drawableRes) sheet.setDrawable(item, drawableRes)
@ -261,11 +261,11 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
} }
private fun selectAll() { private fun selectAll() {
adapter.libraryListener.selectAll(adapterPosition) adapter.libraryListener.selectAll(flexibleAdapterPosition)
} }
fun setSelection() { fun setSelection() {
val allSelected = adapter.libraryListener.allSelected(adapterPosition) val allSelected = adapter.libraryListener.allSelected(flexibleAdapterPosition)
val drawable = ContextCompat.getDrawable( val drawable = ContextCompat.getDrawable(
contentView.context, contentView.context,
if (allSelected) R.drawable.ic_check_circle_24dp else R.drawable.ic_radio_button_unchecked_24dp if (allSelected) R.drawable.ic_check_circle_24dp else R.drawable.ic_radio_button_unchecked_24dp

View File

@ -67,7 +67,7 @@ class SearchGlobalItem : AbstractFlexibleItem<SearchGlobalItem.Holder>() {
width = MATCH_PARENT width = MATCH_PARENT
} }
button.setOnClickListener { button.setOnClickListener {
val query = (adapter.getItem(adapterPosition) as SearchGlobalItem).string val query = (adapter.getItem(flexibleAdapterPosition) as SearchGlobalItem).string
(adapter as? LibraryCategoryAdapter)?.libraryListener?.globalSearch(query) (adapter as? LibraryCategoryAdapter)?.libraryListener?.globalSearch(query)
} }
} }

View File

@ -17,9 +17,9 @@ open class BaseChapterHolder(
} }
private fun downloadOrRemoveMenu() { private fun downloadOrRemoveMenu() {
val chapter = adapter.getItem(adapterPosition) as? BaseChapterItem<*, *> ?: return val chapter = adapter.getItem(flexibleAdapterPosition) as? BaseChapterItem<*, *> ?: return
if (chapter.status == Download.NOT_DOWNLOADED || chapter.status == Download.ERROR) { if (chapter.status == Download.NOT_DOWNLOADED || chapter.status == Download.ERROR) {
adapter.baseDelegate.downloadChapter(adapterPosition) adapter.baseDelegate.downloadChapter(flexibleAdapterPosition)
} else { } else {
download_button.post { download_button.post {
// Create a PopupMenu, giving it the clicked view for an anchor // Create a PopupMenu, giving it the clicked view for an anchor
@ -38,8 +38,8 @@ open class BaseChapterHolder(
// Set a listener so we are notified if a menu item is clicked // Set a listener so we are notified if a menu item is clicked
popup.setOnMenuItemClickListener { item -> popup.setOnMenuItemClickListener { item ->
when (item.itemId) { when (item.itemId) {
R.id.action_delete -> adapter.baseDelegate.downloadChapter(adapterPosition) R.id.action_delete -> adapter.baseDelegate.downloadChapter(flexibleAdapterPosition)
R.id.action_start -> adapter.baseDelegate.startDownloadNow(adapterPosition) R.id.action_start -> adapter.baseDelegate.startDownloadNow(flexibleAdapterPosition)
} }
true true
} }

View File

@ -28,7 +28,7 @@ class ChapterHolder(
init { init {
download_button.setOnLongClickListener { download_button.setOnLongClickListener {
adapter.delegate.startDownloadRange(adapterPosition) adapter.delegate.startDownloadRange(flexibleAdapterPosition)
true true
} }
} }
@ -92,13 +92,13 @@ class ChapterHolder(
chapter_scanlator.text = statuses.joinToString("") chapter_scanlator.text = statuses.joinToString("")
val status = when { val status = when {
adapter.isSelected(adapterPosition) -> Download.CHECKED adapter.isSelected(flexibleAdapterPosition) -> Download.CHECKED
else -> item.status else -> item.status
} }
notifyStatus(status, item.isLocked, item.progress) notifyStatus(status, item.isLocked, item.progress)
resetFrontView() resetFrontView()
if (adapterPosition == 1) { if (flexibleAdapterPosition == 1) {
if (!adapter.hasShownSwipeTut.get()) showSlideAnimation() if (!adapter.hasShownSwipeTut.get()) showSlideAnimation()
} }
} }
@ -147,7 +147,7 @@ class ChapterHolder(
} }
private fun resetFrontView() { private fun resetFrontView() {
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(adapterPosition) } if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
} }
fun notifyStatus(status: Int, locked: Boolean, progress: Int) = with(download_button) { fun notifyStatus(status: Int, locked: Boolean, progress: Int) = with(download_button) {

View File

@ -22,15 +22,15 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
init { init {
val listener = adapter.rowClickListener val listener = adapter.rowClickListener
logo_container.setOnClickListener { listener.onLogoClick(adapterPosition) } logo_container.setOnClickListener { listener.onLogoClick(bindingAdapterPosition) }
add_tracking.setOnClickListener { listener.onSetClick(adapterPosition) } add_tracking.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
track_title.setOnClickListener { listener.onSetClick(adapterPosition) } track_title.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
track_remove.setOnClickListener { listener.onRemoveClick(adapterPosition) } track_remove.setOnClickListener { listener.onRemoveClick(bindingAdapterPosition) }
track_status.setOnClickListener { listener.onStatusClick(adapterPosition) } track_status.setOnClickListener { listener.onStatusClick(bindingAdapterPosition) }
track_chapters.setOnClickListener { listener.onChaptersClick(adapterPosition) } track_chapters.setOnClickListener { listener.onChaptersClick(bindingAdapterPosition) }
score_container.setOnClickListener { listener.onScoreClick(adapterPosition) } score_container.setOnClickListener { listener.onScoreClick(bindingAdapterPosition) }
track_start_date.setOnClickListener { listener.onStartDateClick(adapterPosition) } track_start_date.setOnClickListener { listener.onStartDateClick(bindingAdapterPosition) }
track_finish_date.setOnClickListener { listener.onFinishDateClick(adapterPosition) } track_finish_date.setOnClickListener { listener.onFinishDateClick(bindingAdapterPosition) }
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")

View File

@ -12,7 +12,7 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
init { init {
migration_all.setOnClickListener { migration_all.setOnClickListener {
adapter.allClickListener?.onAllClick(adapterPosition) adapter.allClickListener?.onAllClick(flexibleAdapterPosition)
} }
} }

View File

@ -42,7 +42,7 @@ class MigrationProcessHolder(
// correctly positioned. The reason being that the view may change position before the // correctly positioned. The reason being that the view may change position before the
// PopupMenu is shown. // PopupMenu is shown.
migration_menu.setOnClickListener { it.post { showPopupMenu(it) } } migration_menu.setOnClickListener { it.post { showPopupMenu(it) } }
skip_manga.setOnClickListener { it.post { adapter.removeManga(adapterPosition) } } skip_manga.setOnClickListener { it.post { adapter.removeManga(flexibleAdapterPosition) } }
} }
fun bind(item: MigrationProcessItem) { fun bind(item: MigrationProcessItem) {
@ -176,7 +176,7 @@ class MigrationProcessHolder(
} }
private fun showPopupMenu(view: View) { private fun showPopupMenu(view: View) {
val item = adapter.getItem(adapterPosition) ?: return val item = adapter.getItem(flexibleAdapterPosition) ?: return
// Create a PopupMenu, giving it the clicked view for an anchor // Create a PopupMenu, giving it the clicked view for an anchor
val popup = PopupMenu(view.context, view) val popup = PopupMenu(view.context, view)
@ -195,7 +195,7 @@ class MigrationProcessHolder(
// Set a listener so we are notified if a menu item is clicked // Set a listener so we are notified if a menu item is clicked
popup.setOnMenuItemClickListener { menuItem -> popup.setOnMenuItemClickListener { menuItem ->
adapter.menuItemListener.onMenuItemClick(adapterPosition, menuItem) adapter.menuItemListener.onMenuItemClick(flexibleAdapterPosition, menuItem)
true true
} }

View File

@ -43,7 +43,7 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
init { init {
manga_cover.setOnClickListener { manga_cover.setOnClickListener {
adapter.coverClickListener.onCoverClick(adapterPosition) adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
} }
} }
@ -89,7 +89,7 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
} }
private fun resetFrontView() { private fun resetFrontView() {
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(adapterPosition) } if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
} }
override fun getFrontView(): View { override fun getFrontView(): View {

View File

@ -26,15 +26,15 @@ class RecentlyReadHolder(
init { init {
remove.setOnClickListener { remove.setOnClickListener {
adapter.removeClickListener.onRemoveClick(adapterPosition) adapter.removeClickListener.onRemoveClick(flexibleAdapterPosition)
} }
resume.setOnClickListener { resume.setOnClickListener {
adapter.resumeClickListener.onResumeClick(adapterPosition) adapter.resumeClickListener.onResumeClick(flexibleAdapterPosition)
} }
cover.setOnClickListener { cover.setOnClickListener {
adapter.coverClickListener.onCoverClick(adapterPosition) adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
} }
} }

View File

@ -19,7 +19,7 @@ class RecentMangaHolder(
) : BaseChapterHolder(view, adapter) { ) : BaseChapterHolder(view, adapter) {
init { init {
card_layout?.setOnClickListener { adapter.delegate.onCoverClick(adapterPosition) } card_layout?.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
} }
fun bind(recentsType: Int) { fun bind(recentsType: Int) {
@ -80,19 +80,19 @@ class RecentMangaHolder(
cover_thumbnail.loadLibraryManga(item.mch.manga) cover_thumbnail.loadLibraryManga(item.mch.manga)
} }
notifyStatus( notifyStatus(
if (adapter.isSelected(adapterPosition)) Download.CHECKED else item.status, if (adapter.isSelected(flexibleAdapterPosition)) Download.CHECKED else item.status,
item.progress item.progress
) )
resetFrontView() resetFrontView()
} }
private fun resetFrontView() { private fun resetFrontView() {
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(adapterPosition) } if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
} }
override fun onLongClick(view: View?): Boolean { override fun onLongClick(view: View?): Boolean {
super.onLongClick(view) super.onLongClick(view)
val item = adapter.getItem(adapterPosition) as? RecentMangaItem ?: return false val item = adapter.getItem(flexibleAdapterPosition) as? RecentMangaItem ?: return false
return item.mch.history.id != null return item.mch.history.id != null
} }

View File

@ -16,10 +16,10 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
init { init {
source_pin.setOnClickListener { source_pin.setOnClickListener {
adapter.sourceListener.onPinClick(adapterPosition) adapter.sourceListener.onPinClick(flexibleAdapterPosition)
} }
source_latest.setOnClickListener { source_latest.setOnClickListener {
adapter.sourceListener.onLatestClick(adapterPosition) adapter.sourceListener.onLatestClick(flexibleAdapterPosition)
} }
} }

View File

@ -528,7 +528,7 @@ open class BrowseSourceController(bundle: Bundle) :
val adapter = adapter ?: return null val adapter = adapter ?: return null
adapter.allBoundViewHolders.forEach { holder -> adapter.allBoundViewHolders.forEach { holder ->
val item = adapter.getItem(holder.adapterPosition) as? BrowseSourceItem val item = adapter.getItem(holder.flexibleAdapterPosition) as? BrowseSourceItem
if (item != null && item.manga.id!! == manga.id!!) { if (item != null && item.manga.id!! == manga.id!!) {
return holder as BrowseSourceHolder return holder as BrowseSourceHolder
} }

View File

@ -47,7 +47,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
* @param outState The bundle where the state is saved. * @param outState The bundle where the state is saved.
*/ */
private fun saveHolderState(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, outState: Bundle) { private fun saveHolderState(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, outState: Bundle) {
val key = "holder_${holder.adapterPosition}" val key = "holder_${holder.bindingAdapterPosition}"
val holderState = SparseArray<Parcelable>() val holderState = SparseArray<Parcelable>()
holder.itemView.saveHierarchyState(holderState) holder.itemView.saveHierarchyState(holderState)
outState.putSparseParcelableArray(key, holderState) outState.putSparseParcelableArray(key, holderState)
@ -59,7 +59,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
* @param holder The holder to restore. * @param holder The holder to restore.
*/ */
private fun restoreHolderState(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder) { private fun restoreHolderState(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder) {
val key = "holder_${holder.adapterPosition}" val key = "holder_${holder.bindingAdapterPosition}"
val holderState = bundle.getSparseParcelableArray<Parcelable>(key) val holderState = bundle.getSparseParcelableArray<Parcelable>(key)
if (holderState != null) { if (holderState != null) {
holder.itemView.restoreHierarchyState(holderState) holder.itemView.restoreHierarchyState(holderState)

View File

@ -181,7 +181,7 @@ open class GlobalSearchController(
val adapter = adapter ?: return null val adapter = adapter ?: return null
adapter.allBoundViewHolders.forEach { holder -> adapter.allBoundViewHolders.forEach { holder ->
val item = adapter.getItem(holder.adapterPosition) val item = adapter.getItem(holder.flexibleAdapterPosition)
if (item != null && source.id == item.source.id) { if (item != null && source.id == item.source.id) {
return holder as GlobalSearchHolder return holder as GlobalSearchHolder
} }

View File

@ -83,7 +83,7 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
*/ */
private fun getHolder(manga: Manga): GlobalSearchMangaHolder? { private fun getHolder(manga: Manga): GlobalSearchMangaHolder? {
mangaAdapter.allBoundViewHolders.forEach { holder -> mangaAdapter.allBoundViewHolders.forEach { holder ->
val item = mangaAdapter.getItem(holder.adapterPosition) val item = mangaAdapter.getItem(holder.flexibleAdapterPosition)
if (item != null && item.manga.id!! == manga.id!!) { if (item != null && item.manga.id!! == manga.id!!) {
return holder as GlobalSearchMangaHolder return holder as GlobalSearchMangaHolder
} }

View File

@ -17,13 +17,13 @@ class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
init { init {
// Call onMangaClickListener when item is pressed. // Call onMangaClickListener when item is pressed.
itemView.setOnClickListener { itemView.setOnClickListener {
val item = adapter.getItem(adapterPosition) val item = adapter.getItem(flexibleAdapterPosition)
if (item != null) { if (item != null) {
adapter.mangaClickListener.onMangaClick(item.manga) adapter.mangaClickListener.onMangaClick(item.manga)
} }
} }
itemView.setOnLongClickListener { itemView.setOnLongClickListener {
val item = adapter.getItem(adapterPosition) val item = adapter.getItem(flexibleAdapterPosition)
if (item != null) { if (item != null) {
adapter.mangaClickListener.onMangaLongClick(item.manga) adapter.mangaClickListener.onMangaLongClick(item.manga)
} }