mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 00:59:24 +01:00
Replace more Kotlin synthetics
This commit is contained in:
parent
019a0f31c7
commit
66e3fa7df8
@ -23,7 +23,7 @@ import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
|||||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionController
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionController
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesController
|
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
||||||
import kotlinx.android.synthetic.main.main_activity.tabs
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class BrowseController :
|
class BrowseController :
|
||||||
@ -74,7 +74,7 @@ class BrowseController :
|
|||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
if (type.isEnter) {
|
if (type.isEnter) {
|
||||||
activity?.tabs?.apply {
|
(activity as? MainActivity)?.binding?.tabs?.apply {
|
||||||
setupWithViewPager(binding.pager)
|
setupWithViewPager(binding.pager)
|
||||||
|
|
||||||
// Show badge on tab for extension updates
|
// Show badge on tab for extension updates
|
||||||
@ -96,7 +96,7 @@ class BrowseController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setExtensionUpdateBadge() {
|
fun setExtensionUpdateBadge() {
|
||||||
activity?.tabs?.apply {
|
(activity as? MainActivity)?.binding?.tabs?.apply {
|
||||||
val updates = preferences.extensionUpdatesCount().get()
|
val updates = preferences.extensionUpdatesCount().get()
|
||||||
if (updates > 0) {
|
if (updates > 0) {
|
||||||
val badge: BadgeDrawable? = getTabAt(1)?.orCreateBadge
|
val badge: BadgeDrawable? = getTabAt(1)?.orCreateBadge
|
||||||
|
@ -36,6 +36,7 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding
|
import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
||||||
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.system.connectivityManager
|
import eu.kanade.tachiyomi.util.system.connectivityManager
|
||||||
@ -46,7 +47,6 @@ import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
|||||||
import eu.kanade.tachiyomi.util.view.snack
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import eu.kanade.tachiyomi.widget.EmptyView
|
import eu.kanade.tachiyomi.widget.EmptyView
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
@ -398,7 +398,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
|
|
||||||
binding.emptyView.show(message, actions)
|
binding.emptyView.show(message, actions)
|
||||||
} else {
|
} else {
|
||||||
snack = activity!!.root_coordinator?.snack(message, Snackbar.LENGTH_INDEFINITE) {
|
snack = (activity as? MainActivity)?.binding?.rootCoordinator?.snack(message, Snackbar.LENGTH_INDEFINITE) {
|
||||||
setAction(R.string.action_retry, retryAction)
|
setAction(R.string.action_retry, retryAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ import eu.kanade.tachiyomi.databinding.CategoriesControllerBinding
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.FabController
|
import eu.kanade.tachiyomi.ui.base.controller.FabController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding
|
import eu.kanade.tachiyomi.ui.base.controller.applyBottomInsetPadding
|
||||||
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
@ -201,7 +201,7 @@ class CategoryController :
|
|||||||
undoHelper = UndoHelper(adapter, this)
|
undoHelper = UndoHelper(adapter, this)
|
||||||
undoHelper?.start(
|
undoHelper?.start(
|
||||||
adapter.selectedPositions,
|
adapter.selectedPositions,
|
||||||
activity!!.root_coordinator,
|
(activity as? MainActivity)?.binding?.rootCoordinator!!,
|
||||||
R.string.snack_categories_deleted,
|
R.string.snack_categories_deleted,
|
||||||
R.string.action_undo,
|
R.string.action_undo,
|
||||||
3000
|
3000
|
||||||
|
@ -36,7 +36,6 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
|
|||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import kotlinx.android.synthetic.main.main_activity.tabs
|
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
@ -206,7 +205,7 @@ class LibraryController(
|
|||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
if (type.isEnter) {
|
if (type.isEnter) {
|
||||||
activity?.tabs?.setupWithViewPager(binding.libraryPager)
|
(activity as? MainActivity)?.binding?.tabs?.setupWithViewPager(binding.libraryPager)
|
||||||
presenter.subscribeLibrary()
|
presenter.subscribeLibrary()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,7 +276,7 @@ class LibraryController(
|
|||||||
// Delay the scroll position to allow the view to be properly measured.
|
// Delay the scroll position to allow the view to be properly measured.
|
||||||
view.post {
|
view.post {
|
||||||
if (isAttached) {
|
if (isAttached) {
|
||||||
activity?.tabs?.setScrollPosition(binding.libraryPager.currentItem, 0f, true)
|
(activity as? MainActivity)?.binding?.tabs?.setScrollPosition(binding.libraryPager.currentItem, 0f, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,6 @@ import eu.kanade.tachiyomi.util.system.toast
|
|||||||
import eu.kanade.tachiyomi.util.view.getCoordinates
|
import eu.kanade.tachiyomi.util.view.getCoordinates
|
||||||
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||||
import eu.kanade.tachiyomi.util.view.snack
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
|
||||||
import kotlinx.android.synthetic.main.main_activity.toolbar
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
@ -262,7 +260,7 @@ class MangaController :
|
|||||||
else -> min(binding.recycler.computeVerticalScrollOffset(), 255)
|
else -> min(binding.recycler.computeVerticalScrollOffset(), 255)
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.toolbar?.setTitleTextColor(
|
(activity as? MainActivity)?.binding?.toolbar?.setTitleTextColor(
|
||||||
Color.argb(
|
Color.argb(
|
||||||
calculatedAlpha,
|
calculatedAlpha,
|
||||||
toolbarTextColor.red,
|
toolbarTextColor.red,
|
||||||
@ -506,7 +504,7 @@ class MangaController :
|
|||||||
private fun toggleFavorite() {
|
private fun toggleFavorite() {
|
||||||
val isNowFavorite = presenter.toggleFavorite()
|
val isNowFavorite = presenter.toggleFavorite()
|
||||||
if (activity != null && !isNowFavorite && presenter.hasDownloads()) {
|
if (activity != null && !isNowFavorite && presenter.hasDownloads()) {
|
||||||
activity!!.root_coordinator?.snack(activity!!.getString(R.string.delete_downloads_for_manga)) {
|
(activity as? MainActivity)?.binding?.rootCoordinator?.snack(activity!!.getString(R.string.delete_downloads_for_manga)) {
|
||||||
setAction(R.string.action_delete) {
|
setAction(R.string.action_delete) {
|
||||||
presenter.deleteDownloads()
|
presenter.deleteDownloads()
|
||||||
}
|
}
|
||||||
@ -907,7 +905,7 @@ class MangaController :
|
|||||||
val manga = presenter.manga
|
val manga = presenter.manga
|
||||||
presenter.downloadChapters(chapters)
|
presenter.downloadChapters(chapters)
|
||||||
if (view != null && !manga.favorite) {
|
if (view != null && !manga.favorite) {
|
||||||
addSnackbar = activity!!.root_coordinator?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
|
addSnackbar = (activity as? MainActivity)?.binding?.rootCoordinator?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
|
||||||
setAction(R.string.action_add) {
|
setAction(R.string.action_add) {
|
||||||
addToLibrary(manga)
|
addToLibrary(manga)
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
|||||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||||
import kotlinx.android.synthetic.main.pref_library_columns.view.landscape_columns
|
import eu.kanade.tachiyomi.widget.MinMaxNumberPicker
|
||||||
import kotlinx.android.synthetic.main.pref_library_columns.view.portrait_columns
|
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -244,7 +243,7 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onViewCreated(view: View) {
|
fun onViewCreated(view: View) {
|
||||||
with(view.portrait_columns) {
|
with(view.findViewById(R.id.portrait_columns) as MinMaxNumberPicker) {
|
||||||
displayedValues = arrayOf(context.getString(R.string.default_columns)) +
|
displayedValues = arrayOf(context.getString(R.string.default_columns)) +
|
||||||
IntRange(1, 10).map(Int::toString)
|
IntRange(1, 10).map(Int::toString)
|
||||||
value = portrait
|
value = portrait
|
||||||
@ -253,7 +252,7 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
portrait = newValue
|
portrait = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with(view.landscape_columns) {
|
with(view.findViewById(R.id.landscape_columns) as MinMaxNumberPicker) {
|
||||||
displayedValues = arrayOf(context.getString(R.string.default_columns)) +
|
displayedValues = arrayOf(context.getString(R.string.default_columns)) +
|
||||||
IntRange(1, 10).map(Int::toString)
|
IntRange(1, 10).map(Int::toString)
|
||||||
value = landscape
|
value = landscape
|
||||||
|
@ -2,10 +2,10 @@ package eu.kanade.tachiyomi.widget.preference
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.widget.ImageView
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import kotlinx.android.synthetic.main.pref_widget_imageview.view.image_view
|
|
||||||
|
|
||||||
class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
Preference(context, attrs) {
|
Preference(context, attrs) {
|
||||||
@ -17,7 +17,7 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||||
super.onBindViewHolder(holder)
|
super.onBindViewHolder(holder)
|
||||||
|
|
||||||
holder.itemView.image_view.setImageResource(
|
(holder.findViewById(R.id.image_view) as ImageView).setImageResource(
|
||||||
if (getPersistedString("").isNullOrEmpty()) {
|
if (getPersistedString("").isNullOrEmpty()) {
|
||||||
android.R.color.transparent
|
android.R.color.transparent
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,6 @@ import android.view.View
|
|||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import kotlinx.android.synthetic.main.pref_settings.view.button
|
|
||||||
|
|
||||||
class SwitchSettingsPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class SwitchSettingsPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
SwitchPreferenceCompat(context, attrs) {
|
SwitchPreferenceCompat(context, attrs) {
|
||||||
@ -20,7 +19,7 @@ class SwitchSettingsPreference @JvmOverloads constructor(context: Context, attrs
|
|||||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||||
super.onBindViewHolder(holder)
|
super.onBindViewHolder(holder)
|
||||||
|
|
||||||
holder.itemView.button.setOnClickListener {
|
holder.findViewById(R.id.button).setOnClickListener {
|
||||||
onSettingsClick?.onClick(it)
|
onSettingsClick?.onClick(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user