mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Update to Conductor 3.0.0
This commit is contained in:
parent
438bad9649
commit
01a1a9ebab
@ -246,11 +246,10 @@ dependencies {
|
|||||||
implementation("com.afollestad.material-dialogs:datetime:$materialDialogsVersion")
|
implementation("com.afollestad.material-dialogs:datetime:$materialDialogsVersion")
|
||||||
|
|
||||||
// Conductor
|
// Conductor
|
||||||
implementation("com.bluelinelabs:conductor:2.1.5")
|
val conductorVersion = "3.0.0"
|
||||||
implementation("com.bluelinelabs:conductor-support:2.1.5") {
|
implementation("com.bluelinelabs:conductor:$conductorVersion")
|
||||||
exclude(group = "com.android.support")
|
implementation("com.bluelinelabs:conductor-viewpager:$conductorVersion")
|
||||||
}
|
implementation("com.github.tachiyomiorg:conductor-support-preference:$conductorVersion")
|
||||||
implementation("com.github.tachiyomiorg:conductor-support-preference:2.0.1")
|
|
||||||
|
|
||||||
// FlowBinding
|
// FlowBinding
|
||||||
val flowbindingVersion = "1.0.0"
|
val flowbindingVersion = "1.0.0"
|
||||||
|
@ -10,14 +10,12 @@ import androidx.viewbinding.ViewBinding
|
|||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
|
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) : Controller(bundle) {
|
||||||
RestoreViewOnCreateController(bundle) {
|
|
||||||
|
|
||||||
protected lateinit var binding: VB
|
protected lateinit var binding: VB
|
||||||
private set
|
private set
|
||||||
|
@ -5,7 +5,7 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.bluelinelabs.conductor.Router
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
||||||
@ -16,7 +16,7 @@ import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
|||||||
*
|
*
|
||||||
* Implementations should override this class and implement [.onCreateDialog] to create a custom dialog, such as an [android.app.AlertDialog]
|
* Implementations should override this class and implement [.onCreateDialog] to create a custom dialog, such as an [android.app.AlertDialog]
|
||||||
*/
|
*/
|
||||||
abstract class DialogController : RestoreViewOnCreateController {
|
abstract class DialogController : Controller {
|
||||||
|
|
||||||
protected var dialog: Dialog? = null
|
protected var dialog: Dialog? = null
|
||||||
private set
|
private set
|
||||||
|
@ -9,7 +9,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
|
|||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.bluelinelabs.conductor.Router
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.support.RouterPagerAdapter
|
import com.bluelinelabs.conductor.viewpager.RouterPagerAdapter
|
||||||
import com.google.android.material.badge.BadgeDrawable
|
import com.google.android.material.badge.BadgeDrawable
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
|
@ -136,7 +136,7 @@ open class ExtensionController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchView.queryTextChanges()
|
searchView.queryTextChanges()
|
||||||
.filter { router.backstack.lastOrNull()?.controller() == this }
|
.filter { router.backstack.lastOrNull()?.controller == this }
|
||||||
.onEach {
|
.onEach {
|
||||||
query = it.toString()
|
query = it.toString()
|
||||||
drawExtensions()
|
drawExtensions()
|
||||||
|
@ -26,7 +26,7 @@ class SourceSearchController(
|
|||||||
override fun onItemClick(view: View, position: Int): Boolean {
|
override fun onItemClick(view: View, position: Int): Boolean {
|
||||||
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
||||||
newManga = item.manga
|
newManga = item.manga
|
||||||
val searchController = router.backstack.findLast { it.controller().javaClass == SearchController::class.java }?.controller() as SearchController?
|
val searchController = router.backstack.findLast { it.controller.javaClass == SearchController::class.java }?.controller as SearchController?
|
||||||
val dialog =
|
val dialog =
|
||||||
SearchController.MigrationDialog(oldManga, newManga, this)
|
SearchController.MigrationDialog(oldManga, newManga, this)
|
||||||
dialog.targetController = searchController
|
dialog.targetController = searchController
|
||||||
|
@ -261,7 +261,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
searchItem.fixExpand(
|
searchItem.fixExpand(
|
||||||
onExpand = { invalidateMenuOnExpand() },
|
onExpand = { invalidateMenuOnExpand() },
|
||||||
onCollapse = {
|
onCollapse = {
|
||||||
if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller() is GlobalSearchController) {
|
if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller is GlobalSearchController) {
|
||||||
router.popController(this)
|
router.popController(this)
|
||||||
} else {
|
} else {
|
||||||
nonSubmittedQuery = ""
|
nonSubmittedQuery = ""
|
||||||
|
@ -8,6 +8,7 @@ import com.bluelinelabs.conductor.Controller
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
|
import eu.kanade.tachiyomi.util.isLocal
|
||||||
|
|
||||||
class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) :
|
class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) :
|
||||||
DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener {
|
DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener {
|
||||||
@ -20,11 +21,14 @@ class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||||
|
val canDeleteChapters = mangas.any { !it.isLocal() }
|
||||||
|
|
||||||
return MaterialDialog(activity!!)
|
return MaterialDialog(activity!!)
|
||||||
.title(R.string.action_remove)
|
.title(R.string.action_remove)
|
||||||
.listItemsMultiChoice(
|
.listItemsMultiChoice(
|
||||||
R.array.delete_selected_mangas,
|
res = R.array.delete_selected_mangas,
|
||||||
initialSelection = intArrayOf(0)
|
disabledIndices = intArrayOf(1).takeUnless { canDeleteChapters },
|
||||||
|
initialSelection = intArrayOf(0),
|
||||||
) { _, selections, _ ->
|
) { _, selections, _ ->
|
||||||
val deleteFromLibrary = 0 in selections
|
val deleteFromLibrary = 0 in selections
|
||||||
val deleteChapters = 1 in selections
|
val deleteChapters = 1 in selections
|
||||||
|
@ -600,7 +600,7 @@ class LibraryController(
|
|||||||
|
|
||||||
override fun onSearchViewQueryTextChange(newText: String?) {
|
override fun onSearchViewQueryTextChange(newText: String?) {
|
||||||
// Ignore events if this controller isn't at the top to avoid query being reset
|
// Ignore events if this controller isn't at the top to avoid query being reset
|
||||||
if (router.backstack.lastOrNull()?.controller() == this) {
|
if (router.backstack.lastOrNull()?.controller == this) {
|
||||||
presenter.query = newText ?: ""
|
presenter.query = newText ?: ""
|
||||||
performSearch()
|
performSearch()
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
syncActivityViewWithController(router.backstack.lastOrNull()?.controller())
|
syncActivityViewWithController(router.backstack.lastOrNull()?.controller)
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
// Reset Incognito Mode on relaunch
|
// Reset Incognito Mode on relaunch
|
||||||
@ -247,7 +247,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
|
|
||||||
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
|
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
|
||||||
if (!it) {
|
if (!it) {
|
||||||
val fg = router.backstack.last().controller()
|
val fg = router.backstack.last().controller
|
||||||
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
|
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
|
||||||
router.popToRoot()
|
router.popToRoot()
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ class MangaController :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
when (val previousController = router.backstack[router.backstackSize - 2].controller()) {
|
when (val previousController = router.backstack[router.backstackSize - 2].controller) {
|
||||||
is LibraryController -> {
|
is LibraryController -> {
|
||||||
router.handleBack()
|
router.handleBack()
|
||||||
previousController.search(query)
|
previousController.search(query)
|
||||||
|
@ -194,7 +194,7 @@ class HistoryController :
|
|||||||
searchView.clearFocus()
|
searchView.clearFocus()
|
||||||
}
|
}
|
||||||
searchView.queryTextChanges()
|
searchView.queryTextChanges()
|
||||||
.filter { router.backstack.lastOrNull()?.controller() == this }
|
.filter { router.backstack.lastOrNull()?.controller == this }
|
||||||
.onEach {
|
.onEach {
|
||||||
query = it.toString()
|
query = it.toString()
|
||||||
presenter.updateList(query)
|
presenter.updateList(query)
|
||||||
|
@ -71,8 +71,7 @@ class SettingsTrackingController :
|
|||||||
trackManager.komga.loginNoop()
|
trackManager.komga.loginNoop()
|
||||||
updatePreference(trackManager.komga.id)
|
updatePreference(trackManager.komga.id)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
preferenceCategory {
|
|
||||||
infoPreference(R.string.tracking_info)
|
infoPreference(R.string.tracking_info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user