mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:05:22 +01:00
Removing deprecated use of adapterPosition
This commit is contained in:
parent
8556aba3ca
commit
4df422d2e0
@ -91,7 +91,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
||||
)
|
||||
)
|
||||
reorder.setOnClickListener {
|
||||
adapter.categoryItemListener.onItemDelete(adapterPosition)
|
||||
adapter.categoryItemListener.onItemDelete(flexibleAdapterPosition)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -117,7 +117,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleVie
|
||||
private fun submitChanges() {
|
||||
if (edit_text.visibility == View.VISIBLE) {
|
||||
if (adapter.categoryItemListener
|
||||
.onCategoryRename(adapterPosition, edit_text.text.toString())
|
||||
.onCategoryRename(flexibleAdapterPosition, edit_text.text.toString())
|
||||
) {
|
||||
isEditing(false)
|
||||
edit_text.inputType = InputType.TYPE_NULL
|
||||
|
@ -52,7 +52,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
||||
notifyDownloadedPages()
|
||||
}
|
||||
|
||||
migration_menu.visibleIf(adapterPosition != 0 || adapterPosition != adapter.itemCount - 1)
|
||||
migration_menu.visibleIf(flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1)
|
||||
migration_menu.setVectorCompat(
|
||||
R.drawable.ic_more_vert_24dp,
|
||||
view.context
|
||||
@ -85,7 +85,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
||||
}
|
||||
|
||||
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
|
||||
val popup = PopupMenu(view.context, view)
|
||||
@ -95,13 +95,13 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
||||
|
||||
val download = item.download
|
||||
|
||||
popup.menu.findItem(R.id.move_to_top).isVisible = adapterPosition != 0
|
||||
popup.menu.findItem(R.id.move_to_bottom).isVisible = adapterPosition != adapter
|
||||
popup.menu.findItem(R.id.move_to_top).isVisible = flexibleAdapterPosition != 0
|
||||
popup.menu.findItem(R.id.move_to_bottom).isVisible = flexibleAdapterPosition != adapter
|
||||
.itemCount - 1
|
||||
|
||||
// Set a listener so we are notified if a menu item is clicked
|
||||
popup.setOnMenuItemClickListener { menuItem ->
|
||||
adapter.downloadItemListener.onMenuItemClick(adapterPosition, menuItem)
|
||||
adapter.downloadItemListener.onMenuItemClick(flexibleAdapterPosition, menuItem)
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class ExtensionHolder(view: View, val adapter: ExtensionAdapter) :
|
||||
|
||||
init {
|
||||
ext_button.setOnClickListener {
|
||||
adapter.buttonClickListener.onButtonClick(adapterPosition)
|
||||
adapter.buttonClickListener.onButtonClick(flexibleAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ class LibraryController(
|
||||
}
|
||||
|
||||
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
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) {
|
||||
if (lastItemPosition != null &&
|
||||
|
@ -68,9 +68,9 @@ class LibraryGridHolder(
|
||||
if (item.manga.thumbnail_url == null) cover_thumbnail.clear()
|
||||
else {
|
||||
if (cover_thumbnail.height == 0) {
|
||||
val oldPos = adapterPosition
|
||||
val oldPos = flexibleAdapterPosition
|
||||
adapter.recyclerView.post {
|
||||
if (oldPos == adapterPosition) {
|
||||
if (oldPos == flexibleAdapterPosition) {
|
||||
setCover(item.manga)
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ class LibraryGridHolder(
|
||||
}
|
||||
|
||||
private fun playButtonClicked() {
|
||||
adapter.libraryListener.startReading(adapterPosition)
|
||||
adapter.libraryListener.startReading(flexibleAdapterPosition)
|
||||
}
|
||||
|
||||
override fun onActionStateChanged(position: Int, actionState: Int) {
|
||||
|
@ -43,8 +43,8 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
category_header_layout.setOnClickListener { toggleCategory() }
|
||||
updateButton.setOnClickListener { addCategoryToUpdate() }
|
||||
sectionText.setOnLongClickListener {
|
||||
val category = (adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category
|
||||
adapter.libraryListener.manageCategory(adapterPosition)
|
||||
val category = (adapter.getItem(flexibleAdapterPosition) as? LibraryHeaderItem)?.category
|
||||
adapter.libraryListener.manageCategory(flexibleAdapterPosition)
|
||||
category?.isDynamic == false
|
||||
}
|
||||
sectionText.setOnClickListener { toggleCategory() }
|
||||
@ -54,7 +54,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
}
|
||||
|
||||
private fun toggleCategory() {
|
||||
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
||||
adapter.libraryListener.toggleCategoryVisibility(flexibleAdapterPosition)
|
||||
val tutorial = Injekt.get<PreferencesHelper>().shownLongPressCategoryTutorial()
|
||||
if (!tutorial.get()) {
|
||||
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() {
|
||||
if (adapter.libraryListener.updateCategory(adapterPosition)) {
|
||||
if (adapter.libraryListener.updateCategory(flexibleAdapterPosition)) {
|
||||
catProgress.visible()
|
||||
updateButton.invisible()
|
||||
}
|
||||
@ -159,7 +159,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
|
||||
private fun showCatSortOptions() {
|
||||
val category =
|
||||
(adapter.getItem(adapterPosition) as? LibraryHeaderItem)?.category ?: return
|
||||
(adapter.getItem(flexibleAdapterPosition) as? LibraryHeaderItem)?.category ?: return
|
||||
adapter.controller.activity?.let { activity ->
|
||||
val items = mutableListOf(
|
||||
MaterialMenuSheet.MenuSheetItem(
|
||||
@ -210,7 +210,7 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
sortingMode
|
||||
) { sheet, 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 drawableRes = getSortRes(item, isAscending)
|
||||
sheet.setDrawable(item, drawableRes)
|
||||
@ -261,11 +261,11 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd
|
||||
}
|
||||
|
||||
private fun selectAll() {
|
||||
adapter.libraryListener.selectAll(adapterPosition)
|
||||
adapter.libraryListener.selectAll(flexibleAdapterPosition)
|
||||
}
|
||||
|
||||
fun setSelection() {
|
||||
val allSelected = adapter.libraryListener.allSelected(adapterPosition)
|
||||
val allSelected = adapter.libraryListener.allSelected(flexibleAdapterPosition)
|
||||
val drawable = ContextCompat.getDrawable(
|
||||
contentView.context,
|
||||
if (allSelected) R.drawable.ic_check_circle_24dp else R.drawable.ic_radio_button_unchecked_24dp
|
||||
|
@ -67,7 +67,7 @@ class SearchGlobalItem : AbstractFlexibleItem<SearchGlobalItem.Holder>() {
|
||||
width = MATCH_PARENT
|
||||
}
|
||||
button.setOnClickListener {
|
||||
val query = (adapter.getItem(adapterPosition) as SearchGlobalItem).string
|
||||
val query = (adapter.getItem(flexibleAdapterPosition) as SearchGlobalItem).string
|
||||
(adapter as? LibraryCategoryAdapter)?.libraryListener?.globalSearch(query)
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ open class BaseChapterHolder(
|
||||
}
|
||||
|
||||
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) {
|
||||
adapter.baseDelegate.downloadChapter(adapterPosition)
|
||||
adapter.baseDelegate.downloadChapter(flexibleAdapterPosition)
|
||||
} else {
|
||||
download_button.post {
|
||||
// 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
|
||||
popup.setOnMenuItemClickListener { item ->
|
||||
when (item.itemId) {
|
||||
R.id.action_delete -> adapter.baseDelegate.downloadChapter(adapterPosition)
|
||||
R.id.action_start -> adapter.baseDelegate.startDownloadNow(adapterPosition)
|
||||
R.id.action_delete -> adapter.baseDelegate.downloadChapter(flexibleAdapterPosition)
|
||||
R.id.action_start -> adapter.baseDelegate.startDownloadNow(flexibleAdapterPosition)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class ChapterHolder(
|
||||
|
||||
init {
|
||||
download_button.setOnLongClickListener {
|
||||
adapter.delegate.startDownloadRange(adapterPosition)
|
||||
adapter.delegate.startDownloadRange(flexibleAdapterPosition)
|
||||
true
|
||||
}
|
||||
}
|
||||
@ -92,13 +92,13 @@ class ChapterHolder(
|
||||
chapter_scanlator.text = statuses.joinToString(" • ")
|
||||
|
||||
val status = when {
|
||||
adapter.isSelected(adapterPosition) -> Download.CHECKED
|
||||
adapter.isSelected(flexibleAdapterPosition) -> Download.CHECKED
|
||||
else -> item.status
|
||||
}
|
||||
|
||||
notifyStatus(status, item.isLocked, item.progress)
|
||||
resetFrontView()
|
||||
if (adapterPosition == 1) {
|
||||
if (flexibleAdapterPosition == 1) {
|
||||
if (!adapter.hasShownSwipeTut.get()) showSlideAnimation()
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ class ChapterHolder(
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -22,15 +22,15 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
|
||||
|
||||
init {
|
||||
val listener = adapter.rowClickListener
|
||||
logo_container.setOnClickListener { listener.onLogoClick(adapterPosition) }
|
||||
add_tracking.setOnClickListener { listener.onSetClick(adapterPosition) }
|
||||
track_title.setOnClickListener { listener.onSetClick(adapterPosition) }
|
||||
track_remove.setOnClickListener { listener.onRemoveClick(adapterPosition) }
|
||||
track_status.setOnClickListener { listener.onStatusClick(adapterPosition) }
|
||||
track_chapters.setOnClickListener { listener.onChaptersClick(adapterPosition) }
|
||||
score_container.setOnClickListener { listener.onScoreClick(adapterPosition) }
|
||||
track_start_date.setOnClickListener { listener.onStartDateClick(adapterPosition) }
|
||||
track_finish_date.setOnClickListener { listener.onFinishDateClick(adapterPosition) }
|
||||
logo_container.setOnClickListener { listener.onLogoClick(bindingAdapterPosition) }
|
||||
add_tracking.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
|
||||
track_title.setOnClickListener { listener.onSetClick(bindingAdapterPosition) }
|
||||
track_remove.setOnClickListener { listener.onRemoveClick(bindingAdapterPosition) }
|
||||
track_status.setOnClickListener { listener.onStatusClick(bindingAdapterPosition) }
|
||||
track_chapters.setOnClickListener { listener.onChaptersClick(bindingAdapterPosition) }
|
||||
score_container.setOnClickListener { listener.onScoreClick(bindingAdapterPosition) }
|
||||
track_start_date.setOnClickListener { listener.onStartDateClick(bindingAdapterPosition) }
|
||||
track_finish_date.setOnClickListener { listener.onFinishDateClick(bindingAdapterPosition) }
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
@ -12,7 +12,7 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
|
||||
|
||||
init {
|
||||
migration_all.setOnClickListener {
|
||||
adapter.allClickListener?.onAllClick(adapterPosition)
|
||||
adapter.allClickListener?.onAllClick(flexibleAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class MigrationProcessHolder(
|
||||
// correctly positioned. The reason being that the view may change position before the
|
||||
// PopupMenu is shown.
|
||||
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) {
|
||||
@ -176,7 +176,7 @@ class MigrationProcessHolder(
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
popup.setOnMenuItemClickListener { menuItem ->
|
||||
adapter.menuItemListener.onMenuItemClick(adapterPosition, menuItem)
|
||||
adapter.menuItemListener.onMenuItemClick(flexibleAdapterPosition, menuItem)
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
||||
|
||||
init {
|
||||
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() {
|
||||
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(adapterPosition) }
|
||||
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
|
||||
}
|
||||
|
||||
override fun getFrontView(): View {
|
||||
|
@ -26,15 +26,15 @@ class RecentlyReadHolder(
|
||||
|
||||
init {
|
||||
remove.setOnClickListener {
|
||||
adapter.removeClickListener.onRemoveClick(adapterPosition)
|
||||
adapter.removeClickListener.onRemoveClick(flexibleAdapterPosition)
|
||||
}
|
||||
|
||||
resume.setOnClickListener {
|
||||
adapter.resumeClickListener.onResumeClick(adapterPosition)
|
||||
adapter.resumeClickListener.onResumeClick(flexibleAdapterPosition)
|
||||
}
|
||||
|
||||
cover.setOnClickListener {
|
||||
adapter.coverClickListener.onCoverClick(adapterPosition)
|
||||
adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class RecentMangaHolder(
|
||||
) : BaseChapterHolder(view, adapter) {
|
||||
|
||||
init {
|
||||
card_layout?.setOnClickListener { adapter.delegate.onCoverClick(adapterPosition) }
|
||||
card_layout?.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
|
||||
}
|
||||
|
||||
fun bind(recentsType: Int) {
|
||||
@ -80,19 +80,19 @@ class RecentMangaHolder(
|
||||
cover_thumbnail.loadLibraryManga(item.mch.manga)
|
||||
}
|
||||
notifyStatus(
|
||||
if (adapter.isSelected(adapterPosition)) Download.CHECKED else item.status,
|
||||
if (adapter.isSelected(flexibleAdapterPosition)) Download.CHECKED else item.status,
|
||||
item.progress
|
||||
)
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,10 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
|
||||
|
||||
init {
|
||||
source_pin.setOnClickListener {
|
||||
adapter.sourceListener.onPinClick(adapterPosition)
|
||||
adapter.sourceListener.onPinClick(flexibleAdapterPosition)
|
||||
}
|
||||
source_latest.setOnClickListener {
|
||||
adapter.sourceListener.onLatestClick(adapterPosition)
|
||||
adapter.sourceListener.onLatestClick(flexibleAdapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
val adapter = adapter ?: return null
|
||||
|
||||
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!!) {
|
||||
return holder as BrowseSourceHolder
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
||||
* @param outState The bundle where the state is saved.
|
||||
*/
|
||||
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>()
|
||||
holder.itemView.saveHierarchyState(holderState)
|
||||
outState.putSparseParcelableArray(key, holderState)
|
||||
@ -59,7 +59,7 @@ class GlobalSearchAdapter(val controller: GlobalSearchController) :
|
||||
* @param holder The holder to restore.
|
||||
*/
|
||||
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)
|
||||
if (holderState != null) {
|
||||
holder.itemView.restoreHierarchyState(holderState)
|
||||
|
@ -181,7 +181,7 @@ open class GlobalSearchController(
|
||||
val adapter = adapter ?: return null
|
||||
|
||||
adapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = adapter.getItem(holder.adapterPosition)
|
||||
val item = adapter.getItem(holder.flexibleAdapterPosition)
|
||||
if (item != null && source.id == item.source.id) {
|
||||
return holder as GlobalSearchHolder
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
||||
*/
|
||||
private fun getHolder(manga: Manga): GlobalSearchMangaHolder? {
|
||||
mangaAdapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = mangaAdapter.getItem(holder.adapterPosition)
|
||||
val item = mangaAdapter.getItem(holder.flexibleAdapterPosition)
|
||||
if (item != null && item.manga.id!! == manga.id!!) {
|
||||
return holder as GlobalSearchMangaHolder
|
||||
}
|
||||
|
@ -17,13 +17,13 @@ class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
||||
init {
|
||||
// Call onMangaClickListener when item is pressed.
|
||||
itemView.setOnClickListener {
|
||||
val item = adapter.getItem(adapterPosition)
|
||||
val item = adapter.getItem(flexibleAdapterPosition)
|
||||
if (item != null) {
|
||||
adapter.mangaClickListener.onMangaClick(item.manga)
|
||||
}
|
||||
}
|
||||
itemView.setOnLongClickListener {
|
||||
val item = adapter.getItem(adapterPosition)
|
||||
val item = adapter.getItem(flexibleAdapterPosition)
|
||||
if (item != null) {
|
||||
adapter.mangaClickListener.onMangaLongClick(item.manga)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user