Change catalogue hiding dialog to accommodate more options in the future
This commit is contained in:
parent
5276e25b22
commit
849cb4208f
3 changed files with 17 additions and 39 deletions
|
@ -10,6 +10,9 @@ import android.view.MenuItem
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
|
@ -60,8 +63,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||
CatalogueAdapter.OnBrowseClickListener,
|
||||
RootSearchInterface,
|
||||
BottomSheetController,
|
||||
CatalogueAdapter.OnLatestClickListener,
|
||||
HideCatalogueDialog.Listener {
|
||||
CatalogueAdapter.OnLatestClickListener {
|
||||
|
||||
/**
|
||||
* Application preferences.
|
||||
|
@ -254,15 +256,22 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||
}
|
||||
|
||||
override fun onItemLongClick(position: Int) {
|
||||
val activity = activity ?: return
|
||||
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||
val source = item.source
|
||||
|
||||
val dialog = HideCatalogueDialog(source)
|
||||
dialog.targetController = this@CatalogueController
|
||||
dialog.showDialog(router)
|
||||
MaterialDialog(activity)
|
||||
.title(text = item.source.name)
|
||||
.listItems(items = listOf(activity.getString(R.string.hide)),
|
||||
waitForPositiveButton = false, selection = { _, index, _ ->
|
||||
when (index) {
|
||||
0 -> {
|
||||
hideCatalogue(item.source)
|
||||
}
|
||||
}
|
||||
}).show()
|
||||
}
|
||||
|
||||
override fun hideCatalogueDialogClosed(source: Source) {
|
||||
private fun hideCatalogue(source: Source) {
|
||||
val current = preferences.hiddenCatalogues().getOrDefault()
|
||||
preferences.hiddenCatalogues().set(current + source.id.toString())
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package eu.kanade.tachiyomi.ui.catalogue
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class HideCatalogueDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
private val source = Injekt.get<SourceManager>().get(args.getLong("key"))!!
|
||||
|
||||
constructor(source: Source) : this(Bundle().apply { putLong("key", source.id) })
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog(activity!!)
|
||||
.title(text = activity!!.getString(R.string.hide_question, source.name))
|
||||
.positiveButton(android.R.string.ok) {
|
||||
(targetController as? Listener)?.hideCatalogueDialogClosed(source)
|
||||
}
|
||||
.negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun hideCatalogueDialogClosed(source: Source)
|
||||
}
|
||||
}
|
|
@ -630,7 +630,7 @@
|
|||
<string name="filter">Filter</string>
|
||||
<string name="forward">Forward</string>
|
||||
<string name="free">Free</string>
|
||||
<string name="hide_question">Hide %1$s?</string>
|
||||
<string name="hide">Hide</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
<string name="install">Install</string>
|
||||
<string name="left">Left</string>
|
||||
|
|
Reference in a new issue