Update to Conductor 3.0.0

This commit is contained in:
arkon 2021-07-03 12:50:10 -04:00
parent 438bad9649
commit 01a1a9ebab
13 changed files with 23 additions and 23 deletions

View File

@ -246,11 +246,10 @@ dependencies {
implementation("com.afollestad.material-dialogs:datetime:$materialDialogsVersion")
// Conductor
implementation("com.bluelinelabs:conductor:2.1.5")
implementation("com.bluelinelabs:conductor-support:2.1.5") {
exclude(group = "com.android.support")
}
implementation("com.github.tachiyomiorg:conductor-support-preference:2.0.1")
val conductorVersion = "3.0.0"
implementation("com.bluelinelabs:conductor:$conductorVersion")
implementation("com.bluelinelabs:conductor-viewpager:$conductorVersion")
implementation("com.github.tachiyomiorg:conductor-support-preference:$conductorVersion")
// FlowBinding
val flowbindingVersion = "1.0.0"

View File

@ -10,14 +10,12 @@ import androidx.viewbinding.ViewBinding
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.RestoreViewOnCreateController
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
import timber.log.Timber
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
RestoreViewOnCreateController(bundle) {
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) : Controller(bundle) {
protected lateinit var binding: VB
private set

View File

@ -5,7 +5,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bluelinelabs.conductor.RestoreViewOnCreateController
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
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]
*/
abstract class DialogController : RestoreViewOnCreateController {
abstract class DialogController : Controller {
protected var dialog: Dialog? = null
private set

View File

@ -9,7 +9,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
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.tabs.TabLayout
import com.jakewharton.rxrelay.PublishRelay

View File

@ -136,7 +136,7 @@ open class ExtensionController :
}
searchView.queryTextChanges()
.filter { router.backstack.lastOrNull()?.controller() == this }
.filter { router.backstack.lastOrNull()?.controller == this }
.onEach {
query = it.toString()
drawExtensions()

View File

@ -26,7 +26,7 @@ class SourceSearchController(
override fun onItemClick(view: View, position: Int): Boolean {
val item = adapter?.getItem(position) as? SourceItem ?: return false
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 =
SearchController.MigrationDialog(oldManga, newManga, this)
dialog.targetController = searchController

View File

@ -261,7 +261,7 @@ open class BrowseSourceController(bundle: Bundle) :
searchItem.fixExpand(
onExpand = { invalidateMenuOnExpand() },
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)
} else {
nonSubmittedQuery = ""

View File

@ -8,6 +8,7 @@ import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.isLocal
class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) :
DialogController(bundle) where T : Controller, T : DeleteLibraryMangasDialog.Listener {
@ -20,11 +21,14 @@ class DeleteLibraryMangasDialog<T>(bundle: Bundle? = null) :
}
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val canDeleteChapters = mangas.any { !it.isLocal() }
return MaterialDialog(activity!!)
.title(R.string.action_remove)
.listItemsMultiChoice(
R.array.delete_selected_mangas,
initialSelection = intArrayOf(0)
res = R.array.delete_selected_mangas,
disabledIndices = intArrayOf(1).takeUnless { canDeleteChapters },
initialSelection = intArrayOf(0),
) { _, selections, _ ->
val deleteFromLibrary = 0 in selections
val deleteChapters = 1 in selections

View File

@ -600,7 +600,7 @@ class LibraryController(
override fun onSearchViewQueryTextChange(newText: String?) {
// 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 ?: ""
performSearch()
}

View File

@ -219,7 +219,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
}
)
syncActivityViewWithController(router.backstack.lastOrNull()?.controller())
syncActivityViewWithController(router.backstack.lastOrNull()?.controller)
if (savedInstanceState == null) {
// Reset Incognito Mode on relaunch
@ -247,7 +247,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
if (!it) {
val fg = router.backstack.last().controller()
val fg = router.backstack.last().controller
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
router.popToRoot()
}

View File

@ -614,7 +614,7 @@ class MangaController :
return
}
when (val previousController = router.backstack[router.backstackSize - 2].controller()) {
when (val previousController = router.backstack[router.backstackSize - 2].controller) {
is LibraryController -> {
router.handleBack()
previousController.search(query)

View File

@ -194,7 +194,7 @@ class HistoryController :
searchView.clearFocus()
}
searchView.queryTextChanges()
.filter { router.backstack.lastOrNull()?.controller() == this }
.filter { router.backstack.lastOrNull()?.controller == this }
.onEach {
query = it.toString()
presenter.updateList(query)

View File

@ -71,8 +71,7 @@ class SettingsTrackingController :
trackManager.komga.loginNoop()
updatePreference(trackManager.komga.id)
}
}
preferenceCategory {
infoPreference(R.string.tracking_info)
}
}