mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
Replace deprecated adapterPosition with bindingAdapterPosition
This commit is contained in:
parent
02207f6cfd
commit
c967308859
@ -81,11 +81,11 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
||||
|
||||
private fun showPopupMenu(view: View) {
|
||||
view.popupMenu(R.menu.download_single, {
|
||||
findItem(R.id.move_to_top).isVisible = adapterPosition != 0
|
||||
findItem(R.id.move_to_top).isVisible = bindingAdapterPosition != 0
|
||||
findItem(R.id.move_to_bottom).isVisible =
|
||||
adapterPosition != adapter.itemCount - 1
|
||||
bindingAdapterPosition != adapter.itemCount - 1
|
||||
}, {
|
||||
adapter.downloadItemListener.onMenuItemClick(adapterPosition, this)
|
||||
adapter.downloadItemListener.onMenuItemClick(bindingAdapterPosition, this)
|
||||
true
|
||||
})
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ExtensionHolder(view: View, override val adapter: ExtensionAdapter) :
|
||||
|
||||
init {
|
||||
ext_button.setOnClickListener {
|
||||
adapter.buttonClickListener.onButtonClick(adapterPosition)
|
||||
adapter.buttonClickListener.onButtonClick(bindingAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,12 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
|
||||
init {
|
||||
val listener = adapter.rowClickListener
|
||||
|
||||
logo_container.setOnClickListener { listener.onLogoClick(adapterPosition) }
|
||||
track_set.setOnClickListener { listener.onSetClick(adapterPosition) }
|
||||
track_title.setOnClickListener { listener.onSetClick(adapterPosition) }
|
||||
track_status.setOnClickListener { listener.onStatusClick(adapterPosition) }
|
||||
track_chapters.setOnClickListener { listener.onChaptersClick(adapterPosition) }
|
||||
track_score.setOnClickListener { listener.onScoreClick(adapterPosition) }
|
||||
logo_container.setOnClickListener { listener.onLogoClick(bindingAdapterPosition) }
|
||||
track_set.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
|
||||
track_title.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
|
||||
track_status.setOnClickListener { listener.onStatusClick(bindingAdapterPosition) }
|
||||
track_chapters.setOnClickListener { listener.onChaptersClick(bindingAdapterPosition) }
|
||||
track_score.setOnClickListener { listener.onScoreClick(bindingAdapterPosition) }
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
@ -29,7 +29,7 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
|
||||
source_latest.gone()
|
||||
source_browse.setText(R.string.select)
|
||||
source_browse.setOnClickListener {
|
||||
adapter.selectClickListener?.onSelectClick(adapterPosition)
|
||||
adapter.selectClickListener?.onSelectClick(bindingAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter)
|
||||
|
||||
init {
|
||||
manga_cover.setOnClickListener {
|
||||
adapter.coverClickListener.onCoverClick(adapterPosition)
|
||||
adapter.coverClickListener.onCoverClick(bindingAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
|
||||
|
||||
init {
|
||||
source_browse.setOnClickListener {
|
||||
adapter.browseClickListener.onBrowseClick(adapterPosition)
|
||||
adapter.browseClickListener.onBrowseClick(bindingAdapterPosition)
|
||||
}
|
||||
|
||||
source_latest.setOnClickListener {
|
||||
adapter.latestClickListener.onLatestClick(adapterPosition)
|
||||
adapter.latestClickListener.onLatestClick(bindingAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
val adapter = adapter ?: return null
|
||||
|
||||
adapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = adapter.getItem(holder.adapterPosition) as? SourceItem
|
||||
val item = adapter.getItem(holder.bindingAdapterPosition) as? SourceItem
|
||||
if (item != null && item.manga.id!! == manga.id!!) {
|
||||
return holder as SourceHolder
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
||||
* @param outState The bundle where the state is saved.
|
||||
*/
|
||||
private fun saveHolderState(holder: RecyclerView.ViewHolder, outState: Bundle) {
|
||||
val key = "holder_${holder.adapterPosition}"
|
||||
val key = "holder_${holder.bindingAdapterPosition}"
|
||||
val holderState = SparseArray<Parcelable>()
|
||||
holder.itemView.saveHierarchyState(holderState)
|
||||
outState.putSparseParcelableArray(key, holderState)
|
||||
@ -60,7 +60,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
||||
* @param holder The holder to restore.
|
||||
*/
|
||||
private fun restoreHolderState(holder: RecyclerView.ViewHolder) {
|
||||
val key = "holder_${holder.adapterPosition}"
|
||||
val key = "holder_${holder.bindingAdapterPosition}"
|
||||
val holderState = bundle.getSparseParcelableArray<Parcelable>(key)
|
||||
if (holderState != null) {
|
||||
holder.itemView.restoreHierarchyState(holderState)
|
||||
|
@ -17,13 +17,13 @@ class GlobalSearchCardHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
||||
init {
|
||||
// Call onMangaClickListener when item is pressed.
|
||||
itemView.setOnClickListener {
|
||||
val item = adapter.getItem(adapterPosition)
|
||||
val item = adapter.getItem(bindingAdapterPosition)
|
||||
if (item != null) {
|
||||
adapter.mangaClickListener.onMangaClick(item.manga)
|
||||
}
|
||||
}
|
||||
itemView.setOnLongClickListener {
|
||||
val item = adapter.getItem(adapterPosition)
|
||||
val item = adapter.getItem(bindingAdapterPosition)
|
||||
if (item != null) {
|
||||
adapter.mangaClickListener.onMangaLongClick(item.manga)
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ open class GlobalSearchController(
|
||||
val adapter = adapter ?: return null
|
||||
|
||||
adapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = adapter.getItem(holder.adapterPosition)
|
||||
val item = adapter.getItem(holder.bindingAdapterPosition)
|
||||
if (item != null && source.id == item.source.id) {
|
||||
return holder as GlobalSearchHolder
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
||||
*/
|
||||
private fun getHolder(manga: Manga): GlobalSearchCardHolder? {
|
||||
mangaAdapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = mangaAdapter.getItem(holder.adapterPosition)
|
||||
val item = mangaAdapter.getItem(holder.bindingAdapterPosition)
|
||||
if (item != null && item.manga.id!! == manga.id!!) {
|
||||
return holder as GlobalSearchCardHolder
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user