Replace deprecated adapterPosition with bindingAdapterPosition

This commit is contained in:
arkon 2020-04-22 09:17:23 -04:00
parent 02207f6cfd
commit c967308859
11 changed files with 21 additions and 21 deletions

View file

@ -81,11 +81,11 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
private fun showPopupMenu(view: View) { private fun showPopupMenu(view: View) {
view.popupMenu(R.menu.download_single, { 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 = 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 true
}) })
} }

View file

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

View file

@ -18,12 +18,12 @@ 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) }
track_set.setOnClickListener { listener.onSetClick(adapterPosition) } track_set.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
track_title.setOnClickListener { listener.onSetClick(adapterPosition) } track_title.setOnClickListener { listener.onSetClick(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) }
track_score.setOnClickListener { listener.onScoreClick(adapterPosition) } track_score.setOnClickListener { listener.onScoreClick(bindingAdapterPosition) }
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")

View file

@ -29,7 +29,7 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
source_latest.gone() source_latest.gone()
source_browse.setText(R.string.select) source_browse.setText(R.string.select)
source_browse.setOnClickListener { source_browse.setOnClickListener {
adapter.selectClickListener?.onSelectClick(adapterPosition) adapter.selectClickListener?.onSelectClick(bindingAdapterPosition)
} }
} }

View file

@ -37,7 +37,7 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter)
init { init {
manga_cover.setOnClickListener { manga_cover.setOnClickListener {
adapter.coverClickListener.onCoverClick(adapterPosition) adapter.coverClickListener.onCoverClick(bindingAdapterPosition)
} }
} }

View file

@ -28,11 +28,11 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
init { init {
source_browse.setOnClickListener { source_browse.setOnClickListener {
adapter.browseClickListener.onBrowseClick(adapterPosition) adapter.browseClickListener.onBrowseClick(bindingAdapterPosition)
} }
source_latest.setOnClickListener { source_latest.setOnClickListener {
adapter.latestClickListener.onLatestClick(adapterPosition) adapter.latestClickListener.onLatestClick(bindingAdapterPosition)
} }
} }

View file

@ -446,7 +446,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? SourceItem val item = adapter.getItem(holder.bindingAdapterPosition) as? SourceItem
if (item != null && item.manga.id!! == manga.id!!) { if (item != null && item.manga.id!! == manga.id!!) {
return holder as SourceHolder return holder as SourceHolder
} }

View file

@ -48,7 +48,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: RecyclerView.ViewHolder, outState: Bundle) { private fun saveHolderState(holder: 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)
@ -60,7 +60,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
* @param holder The holder to restore. * @param holder The holder to restore.
*/ */
private fun restoreHolderState(holder: RecyclerView.ViewHolder) { private fun restoreHolderState(holder: 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

@ -17,13 +17,13 @@ class GlobalSearchCardHolder(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(bindingAdapterPosition)
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(bindingAdapterPosition)
if (item != null) { if (item != null) {
adapter.mangaClickListener.onMangaLongClick(item.manga) adapter.mangaClickListener.onMangaLongClick(item.manga)
} }

View file

@ -163,7 +163,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.bindingAdapterPosition)
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

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