Migration now opens manga on long click

This commit is contained in:
inorichi 2018-01-15 20:22:07 +01:00
parent 233dbec4b3
commit b499b87f8c
4 changed files with 24 additions and 1 deletions

View File

@ -22,6 +22,7 @@ class CatalogueSearchCardAdapter(controller: CatalogueSearchController) :
*/ */
interface OnMangaClickListener { interface OnMangaClickListener {
fun onMangaClick(manga: Manga) fun onMangaClick(manga: Manga)
fun onMangaLongClick(manga: Manga)
} }
} }

View File

@ -19,6 +19,13 @@ class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter)
adapter.mangaClickListener.onMangaClick(item.manga) adapter.mangaClickListener.onMangaClick(item.manga)
} }
} }
itemView.setOnLongClickListener {
val item = adapter.getItem(adapterPosition)
if (item != null) {
adapter.mangaClickListener.onMangaLongClick(item.manga)
}
true
}
} }
fun bind(manga: Manga) { fun bind(manga: Manga) {

View File

@ -25,7 +25,7 @@ open class CatalogueSearchController(protected val initialQuery: String? = null)
/** /**
* Adapter containing search results grouped by lang. * Adapter containing search results grouped by lang.
*/ */
private var adapter: CatalogueSearchAdapter? = null protected var adapter: CatalogueSearchAdapter? = null
/** /**
* Called when controller is initialized. * Called when controller is initialized.
@ -73,6 +73,16 @@ open class CatalogueSearchController(protected val initialQuery: String? = null)
router.pushController(MangaController(manga, true).withFadeTransaction()) router.pushController(MangaController(manga, true).withFadeTransaction())
} }
/**
* Called when manga in global search is long clicked.
*
* @param manga clicked item containing manga information.
*/
override fun onMangaLongClick(manga: Manga) {
// Delegate to single click by default.
onMangaClick(manga)
}
/** /**
* Adds items to the options menu. * Adds items to the options menu.
* *

View File

@ -59,6 +59,11 @@ class SearchController(
dialog.showDialog(router) dialog.showDialog(router)
} }
override fun onMangaLongClick(manga: Manga) {
// Call parent's default click listener
super.onMangaClick(manga)
}
class MigrationDialog : DialogController() { class MigrationDialog : DialogController() {
private val preferences: PreferencesHelper by injectLazy() private val preferences: PreferencesHelper by injectLazy()