Binding Migration Controllers

with this, we are DONE with synthetic.

I am free.....

after one last commit
This commit is contained in:
Jays2Kings 2021-03-29 23:30:31 -04:00
parent 46287f88a1
commit 419e4832ea
3 changed files with 23 additions and 29 deletions

View File

@ -15,7 +15,6 @@ import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.util.system.await
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.scrollViewWith
import kotlinx.android.synthetic.main.migration_controller.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import rx.schedulers.Schedulers
@ -50,12 +49,12 @@ class MigrationController :
override fun onViewCreated(view: View) {
super.onViewCreated(view)
scrollViewWith(migration_recycler, padBottom = true)
scrollViewWith(binding.migrationRecycler, padBottom = true)
adapter = FlexibleAdapter(null, this)
migration_recycler.layoutManager =
binding.migrationRecycler.layoutManager =
androidx.recyclerview.widget.LinearLayoutManager(view.context)
migration_recycler.adapter = adapter
binding.migrationRecycler.adapter = adapter
}
override fun onDestroyView(view: View) {
@ -81,7 +80,7 @@ class MigrationController :
title = resources?.getString(R.string.source_migration)
if (adapter !is SourceAdapter) {
adapter = SourceAdapter(this)
migration_recycler.adapter = adapter
binding.migrationRecycler.adapter = adapter
}
adapter?.updateDataSet(state.sourcesWithManga)
} else {
@ -89,12 +88,12 @@ class MigrationController :
title = state.selectedSource.toString()
if (adapter !is MangaAdapter) {
adapter = MangaAdapter(this)
migration_recycler.adapter = adapter
binding.migrationRecycler.adapter = adapter
}
adapter?.updateDataSet(state.mangaForSource, true)
/*if (switching) launchUI {
migration_recycler.alpha = 0f
migration_recycler.animate().alpha(1f).setStartDelay(100).setDuration(200).start()
binding.migrationRecycler.alpha = 0f
binding.migrationRecycler.animate().alpha(1f).setStartDelay(100).setDuration(200).start()
}*/
}
}

View File

@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.util.view.marginBottom
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.util.view.withFadeTransaction
import kotlinx.android.synthetic.main.pre_migration_controller.*
import uy.kohesive.injekt.injectLazy
class PreMigrationController(bundle: Bundle? = null) :
@ -52,37 +51,35 @@ class PreMigrationController(bundle: Bundle? = null) :
override fun createBinding(inflater: LayoutInflater) = PreMigrationControllerBinding.inflate(inflater)
override fun onViewCreated(view: View) {
super.onViewCreated(view)
liftAppbarWith(recycler)
liftAppbarWith(binding.recycler)
val ourAdapter = adapter ?: MigrationSourceAdapter(
getEnabledSources().map { MigrationSourceItem(it, isEnabled(it.id.toString())) },
this
)
adapter = ourAdapter
recycler.layoutManager = LinearLayoutManager(view.context)
recycler.setHasFixedSize(true)
recycler.adapter = ourAdapter
binding.recycler.layoutManager = LinearLayoutManager(view.context)
binding.recycler.setHasFixedSize(true)
binding.recycler.adapter = ourAdapter
ourAdapter.itemTouchHelperCallback = null // Reset adapter touch adapter to fix drag after rotation
ourAdapter.isHandleDragEnabled = true
dialog = null
val fabBaseMarginBottom = fab?.marginBottom ?: 0
recycler.doOnApplyWindowInsets { v, insets, padding ->
val fabBaseMarginBottom = binding.fab.marginBottom
binding.recycler.doOnApplyWindowInsets { v, insets, padding ->
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
binding.fab.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
}
v.post {
// offset the recycler by the fab's inset + some inset on top
// offset the binding.recycler by the binding.fab's inset + some inset on top
v.updatePaddingRelative(
bottom = insets.systemWindowInsetBottom + (
fab?.marginBottom
?: 0
) + (fab?.height ?: 0)
bottom = insets.systemWindowInsetBottom + binding.fab.marginBottom +
(binding.fab.height)
)
}
}
fab.setOnClickListener {
binding.fab.setOnClickListener {
if (dialog?.isShowing != true) {
dialog = MigrationBottomSheetDialog(activity!!, this)
dialog?.show()

View File

@ -35,7 +35,6 @@ import eu.kanade.tachiyomi.ui.migration.MigrationMangaDialog
import eu.kanade.tachiyomi.ui.migration.SearchController
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
import eu.kanade.tachiyomi.util.system.await
import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
@ -43,7 +42,6 @@ import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
import eu.kanade.tachiyomi.util.view.liftAppbarWith
import eu.kanade.tachiyomi.util.view.withFadeTransaction
import kotlinx.android.synthetic.main.migration_list_controller.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -96,7 +94,7 @@ class MigrationListController(bundle: Bundle? = null) :
override fun onViewCreated(view: View) {
super.onViewCreated(view)
liftAppbarWith(recycler)
liftAppbarWith(binding.recycler)
setTitle()
val config = this.config ?: return
@ -110,10 +108,10 @@ class MigrationListController(bundle: Bundle? = null) :
adapter = MigrationProcessAdapter(this)
recycler.adapter = adapter
recycler.layoutManager = LinearLayoutManager(view.context)
recycler.setHasFixedSize(true)
recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
binding.recycler.adapter = adapter
binding.recycler.layoutManager = LinearLayoutManager(view.context)
binding.recycler.setHasFixedSize(true)
binding.recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
adapter?.updateDataSet(newMigratingManga.map { it.toModal() })