From 18111be27275b108d7675ff8b3b863b6b4a3e942 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 26 Apr 2021 01:39:09 -0400 Subject: [PATCH] Removing isVisible/visibleIf helper methods for androidx.core.view --- .../tachiyomi/ui/base/MaterialMenuSheet.kt | 9 ++++---- .../ui/category/ManageCategoryDialog.kt | 3 +-- .../tachiyomi/ui/download/DownloadHolder.kt | 4 ++-- .../tachiyomi/ui/library/LibraryBadge.kt | 21 +++++++++---------- .../tachiyomi/ui/library/LibraryController.kt | 13 ++++++------ .../tachiyomi/ui/library/LibraryGridHolder.kt | 4 ++-- .../ui/library/LibraryHeaderHolder.kt | 12 +++++------ .../tachiyomi/ui/library/LibraryListHolder.kt | 4 ++-- .../ui/library/filter/FilterTagGroup.kt | 6 +++--- .../kanade/tachiyomi/ui/main/MainActivity.kt | 7 +++---- .../tachiyomi/ui/manga/EditMangaDialog.kt | 3 +-- .../tachiyomi/ui/manga/MangaHeaderHolder.kt | 19 ++++++++--------- .../ui/manga/chapter/ChapterHolder.kt | 9 ++++---- .../manga/chapter/ChaptersSortBottomSheet.kt | 4 ++-- .../tachiyomi/ui/manga/track/TrackHolder.kt | 12 +++++------ .../ui/reader/settings/ReaderPagedView.kt | 5 ++--- .../viewer/webtoon/WebtoonTransitionHolder.kt | 4 ++-- .../source/browse/BrowseSourceController.kt | 4 ++-- .../global_search/GlobalSearchMangaHolder.kt | 6 +++--- .../util/view/ControllerExtensions.kt | 2 +- .../tachiyomi/util/view/ViewExtensions.kt | 8 ------- 21 files changed, 71 insertions(+), 88 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt index 3b3ed2839e..3803bd8bf8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialMenuSheet.kt @@ -10,6 +10,7 @@ import android.view.ViewGroup import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R @@ -19,11 +20,9 @@ import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.hasSideNavBar import eu.kanade.tachiyomi.util.system.isInNightMode import eu.kanade.tachiyomi.util.view.expand -import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.setBottomEdge import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.updateLayoutParams -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.widget.MenuSheetItemView @SuppressLint("InflateParams") @@ -63,7 +62,7 @@ open class MaterialMenuSheet( } } - binding.divider.visibleIf(showDivider) + binding.divider.isVisible = showDivider var currentIndex: Int? = null items.forEachIndexed { index, item -> val view = @@ -104,7 +103,7 @@ open class MaterialMenuSheet( setBottomEdge(binding.menuLayout, activity) - binding.titleLayout.visibleIf(title != null) + binding.titleLayout.isVisible = title != null binding.toolbarTitle.text = title currentIndex?.let { @@ -129,7 +128,7 @@ open class MaterialMenuSheet( elevationAnimator?.start() } elevate(binding.menuScrollView.canScrollVertically(-1)) - if (binding.titleLayout.isVisible()) { + if (binding.titleLayout.isVisible) { binding.menuScrollView.setOnScrollChangeListener { _: View?, _: Int, _: Int, _: Int, _: Int -> val notAtTop = binding.menuScrollView.canScrollVertically(-1) if (notAtTop != isElevated) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt index 78ff159465..422ae218a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt @@ -21,7 +21,6 @@ import eu.kanade.tachiyomi.databinding.MangaCategoryDialogBinding import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.withFadeTransaction import uy.kohesive.injekt.injectLazy @@ -175,7 +174,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) : shouldShow: Boolean ) { val updateCategories = categories.get() - box.visibleIf(updateCategories.isNotEmpty() && shouldShow) + box.isVisible = updateCategories.isNotEmpty() && shouldShow if (updateCategories.isNotEmpty() && shouldShow) box.isChecked = updateCategories.any { category?.id == it.toIntOrNull() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt index b282e194ea..d92e759b6d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt @@ -2,13 +2,13 @@ package eu.kanade.tachiyomi.ui.download import android.view.View import androidx.appcompat.widget.PopupMenu +import androidx.core.view.isVisible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.databinding.DownloadItemBinding import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.setVectorCompat -import eu.kanade.tachiyomi.util.view.visibleIf /** * Class used to hold the data of a download. @@ -53,7 +53,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) : notifyDownloadedPages() } - binding.downloadMenu.visibleIf(flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1) + binding.downloadMenu.isVisible = flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1 binding.downloadMenu.setVectorCompat( R.drawable.ic_more_vert_24dp, view.context diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt index 26e0a9da01..4f2201f789 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.library import android.content.Context import android.util.AttributeSet +import androidx.core.view.isVisible import com.google.android.material.card.MaterialCardView import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.UnreadDownloadBadgeBinding @@ -10,9 +11,7 @@ import eu.kanade.tachiyomi.util.system.contextCompatColor import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.gone -import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.updatePaddingRelative -import eu.kanade.tachiyomi.util.view.visibleIf class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : MaterialCardView(context, attrs) { @@ -32,8 +31,8 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS } else context.getResourceColor(R.attr.colorAccent) with(binding.unreadText) { - visibleIf(unread > 0 || unread == -1 || showTotalChapters) - if (!isVisible()) { + isVisible = unread > 0 || unread == -1 || showTotalChapters + if (!isVisible) { return@with } text = if (unread == -1) "0" else unread.toString() @@ -50,8 +49,8 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS // Update the download count or local status and its visibility. with(binding.downloadText) { - visibleIf(downloads == -2 || downloads > 0) - if (!isVisible()) { return@with } + isVisible = downloads == -2 || downloads > 0 + if (!isVisible) { return@with } text = if (downloads == -2) { resources.getString(R.string.local) } else { @@ -67,13 +66,13 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS } // Show the badge card if unread or downloads exists - visibleIf(binding.downloadText.isVisible() || binding.unreadText.isVisible()) + isVisible = binding.downloadText.isVisible || binding.unreadText.isVisible // Show the angles divider if both unread and downloads exists - binding.unreadAngle.visibleIf(binding.downloadText.isVisible() && binding.unreadText.isVisible()) + binding.unreadAngle.isVisible = binding.downloadText.isVisible && binding.unreadText.isVisible binding.unreadAngle.setColorFilter(unreadBadgeBackground) - if (binding.unreadAngle.isVisible()) { + if (binding.unreadAngle.isVisible) { binding.downloadText.updatePaddingRelative(end = 8.dpToPx) binding.unreadText.updatePaddingRelative(start = 2.dpToPx) } else { @@ -87,10 +86,10 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS } fun setInLibrary(inLibrary: Boolean) { - this.visibleIf(inLibrary) + this.isVisible = inLibrary binding.unreadAngle.gone() binding.unreadText.updatePaddingRelative(start = 5.dpToPx) - binding.unreadText.visibleIf(inLibrary) + binding.unreadText.isVisible = inLibrary binding.unreadText.text = resources.getText(R.string.in_library) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 53785cb731..cec81f7b86 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -26,6 +26,7 @@ import androidx.appcompat.view.ActionMode import androidx.appcompat.widget.SearchView import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.view.GestureDetectorCompat +import androidx.core.view.isVisible import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.ItemTouchHelper @@ -90,7 +91,6 @@ import eu.kanade.tachiyomi.util.view.hide import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.isExpanded import eu.kanade.tachiyomi.util.view.isHidden -import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.scrollViewWith import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener import eu.kanade.tachiyomi.util.view.setStyle @@ -99,7 +99,6 @@ import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.withFadeTransaction import eu.kanade.tachiyomi.widget.EndAnimatorListener import kotlinx.coroutines.CoroutineScope @@ -342,7 +341,7 @@ class LibraryController( } fun showMiniBar() { - binding.headerCard.visibleIf(showCategoryInTitle) + binding.headerCard.isVisible = showCategoryInTitle setSubtitle() } @@ -709,8 +708,8 @@ class LibraryController( } fun hideHopper(hide: Boolean) { - binding.categoryHopperFrame.visibleIf(!hide) - binding.jumperCategoryText.visibleIf(!hide) + binding.categoryHopperFrame.isVisible = !hide + binding.jumperCategoryText.isVisible = !hide } private fun jumpToNextCategory(next: Boolean) { @@ -784,7 +783,7 @@ class LibraryController( } private fun anchorView(): View { - return if (binding.categoryHopperFrame.isVisible()) { + return if (binding.categoryHopperFrame.isVisible) { binding.categoryHopperFrame } else { binding.filterBottomSheet.filterBottomSheet @@ -939,7 +938,7 @@ class LibraryController( setActiveCategory() } - binding.categoryHopperFrame.visibleIf(!singleCategory && !preferences.hideHopper().get()) + binding.categoryHopperFrame.isVisible = !singleCategory && !preferences.hideHopper().get() adapter.isLongPressDragEnabled = canDrag() binding.categoryRecycler.setCategories(presenter.categories) with(binding.filterBottomSheet.root) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt index cf1066ec9c..5821a72b95 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGridHolder.kt @@ -4,6 +4,7 @@ import android.app.Activity import android.view.Gravity import android.view.View import android.widget.FrameLayout +import androidx.core.view.isVisible import coil.api.clear import coil.size.Precision import coil.size.Scale @@ -11,7 +12,6 @@ import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga import eu.kanade.tachiyomi.databinding.MangaGridItemBinding import eu.kanade.tachiyomi.util.view.gone -import eu.kanade.tachiyomi.util.view.visibleIf /** * Class used to hold the displayed data of a manga in the library, like the cover or the title. @@ -55,7 +55,7 @@ class LibraryGridHolder( */ override fun onSetValues(item: LibraryItem) { // Update the title and subtitle of the manga. - binding.constraintLayout.visibleIf(!item.manga.isBlank()) + binding.constraintLayout.isVisible = !item.manga.isBlank() binding.title.text = item.manga.title binding.subtitle.text = item.manga.author?.trim() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt index e48e4a4d92..cc83db55ec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt @@ -6,6 +6,7 @@ import android.util.TypedValue import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat +import androidx.core.view.isVisible import com.github.florent37.viewtooltip.ViewTooltip import eu.davidea.flexibleadapter.SelectableAdapter import eu.kanade.tachiyomi.R @@ -22,7 +23,6 @@ import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -106,8 +106,8 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd ) when { adapter.mode == SelectableAdapter.Mode.MULTI -> { - binding.checkbox.visibleIf(!category.isHidden) - binding.collapseArrow.visibleIf(category.isHidden && !adapter.isSingleCategory) + binding.checkbox.isVisible = !category.isHidden + binding.collapseArrow.isVisible = category.isHidden && !adapter.isSingleCategory binding.updateButton.gone() binding.catProgress.gone() setSelection() @@ -119,16 +119,16 @@ class LibraryHeaderHolder(val view: View, private val adapter: LibraryCategoryAd binding.updateButton.gone() } LibraryUpdateService.categoryInQueue(category.id) -> { - binding.collapseArrow.visibleIf(!adapter.isSingleCategory) + binding.collapseArrow.isVisible = !adapter.isSingleCategory binding.checkbox.gone() binding.catProgress.visible() binding.updateButton.invisible() } else -> { - binding.collapseArrow.visibleIf(!adapter.isSingleCategory) + binding.collapseArrow.isVisible = !adapter.isSingleCategory binding.catProgress.gone() binding.checkbox.gone() - binding.updateButton.visibleIf(!adapter.isSingleCategory) + binding.updateButton.isVisible = !adapter.isSingleCategory } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt index 230037f59f..d6ef26e060 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.library import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import coil.api.clear import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga @@ -10,7 +11,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf /** * Class used to hold the displayed data of a manga in the library, like the cover or the binding.title. @@ -69,7 +69,7 @@ class LibraryListHolder( binding.subtitle.text = item.manga.author?.trim() binding.title.post { if (binding.title.text == item.manga.title) { - binding.subtitle.visibleIf(binding.title.lineCount == 1 && !item.manga.author.isNullOrBlank()) + binding.subtitle.isVisible = binding.title.lineCount == 1 && !item.manga.author.isNullOrBlank() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt index 6553c13ff7..8404a78a25 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt @@ -5,6 +5,7 @@ import android.util.AttributeSet import android.view.View import android.view.ViewGroup import android.widget.LinearLayout +import androidx.core.view.isVisible import com.f2prateek.rx.preferences.Preference import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.getOrDefault @@ -13,7 +14,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout (context, attrs) { @@ -69,8 +69,8 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute val extras = (extra.toList() + listOf(null, null, null)).take(separators.size) extras.forEachIndexed { index, text -> buttons[index + 1].text = text - separators[index].visibleIf(text != null) - buttons[index + 1].visibleIf(text != null) + separators[index].isVisible = text != null + buttons[index + 1].isVisible = text != null } itemCount = buttons.count { !it.text.isNullOrBlank() } this.root = root diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index d54c9808a3..2fde846785 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -75,7 +75,6 @@ import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.updatePadding -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.withFadeTransaction import eu.kanade.tachiyomi.widget.EndAnimatorListener import kotlinx.coroutines.Dispatchers @@ -251,7 +250,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi top = insets.systemWindowInsetTop ) binding.bottomNav.updatePadding(bottom = insets.systemWindowInsetBottom) - binding.bottomView.visibleIf(insets.systemWindowInsetBottom > 0) + binding.bottomView.isVisible = insets.systemWindowInsetBottom > 0 binding.bottomView.updateLayoutParams { height = insets.systemWindowInsetBottom } @@ -283,7 +282,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi binding.cardToolbar.menu.findItem(R.id.action_search)?.expandActionView() } - binding.bottomNav.visibleIf(!hideBottomNav) + binding.bottomNav.isVisible = !hideBottomNav binding.bottomView.visibility = if (hideBottomNav) View.GONE else binding.bottomView.visibility binding.bottomNav.alpha = if (hideBottomNav) 0f else 1f router.addChangeListener( @@ -746,7 +745,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi } alphaAnimation.addListener( EndAnimatorListener { - binding.bottomNav.visibleIf(!hideBottomNav) + binding.bottomNav.isVisible = !hideBottomNav binding.bottomView.visibility = if (hideBottomNav) View.GONE else binding.bottomView.visibility } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt index 93e2621b11..4561412fcb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt @@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.lang.chop -import eu.kanade.tachiyomi.util.view.visibleIf import me.gujun.android.taggroup.TagGroup import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -145,7 +144,7 @@ class EditMangaDialog : DialogController { R.string.reset_tags } ) - binding.resetCover.visibleIf(!isLocal) + binding.resetCover.isVisible = !isLocal binding.resetCover.setOnClickListener { binding.mangaCover.loadAny( manga, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 02a8ad27ec..0d6748f9e3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -8,6 +8,7 @@ import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.core.graphics.ColorUtils +import androidx.core.view.isVisible import coil.api.loadAny import coil.request.CachePolicy import com.google.android.material.button.MaterialButton @@ -21,11 +22,9 @@ import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.isLTR import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.invisible -import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.resetStrokeColor import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf @SuppressLint("ClickableViewAccessibility") class MangaHeaderHolder( @@ -48,7 +47,7 @@ class MangaHeaderHolder( } binding.moreButton.setOnClickListener { expandDesc() } binding.mangaSummary.setOnClickListener { - if (binding.moreButton.isVisible()) { + if (binding.moreButton.isVisible) { expandDesc() } else if (!hadSelection) { collapseDesc() @@ -158,10 +157,10 @@ class MangaHeaderHolder( binding.mangaSummary.post { binding.mangaSummary if (binding.subItemGroup.visibility != View.GONE) { - if ((binding.mangaSummary.lineCount < 3 && manga.genre.isNullOrBlank()) || binding.lessButton.isVisible()) { + if ((binding.mangaSummary.lineCount < 3 && manga.genre.isNullOrBlank()) || binding.lessButton.isVisible) { binding.mangaSummary.setTextIsSelectable(true) binding.moreButtonGroup.gone() - showMoreButton = binding.lessButton.isVisible() + showMoreButton = binding.lessButton.isVisible } else { binding.moreButtonGroup.visible() } @@ -200,7 +199,7 @@ class MangaHeaderHolder( val tracked = presenter.isTracked() && !item.isLocked with(binding.trackButton) { - visibleIf(presenter.hasTrackers()) + isVisible = presenter.hasTrackers() text = itemView.context.getString( if (tracked) R.string.tracked else R.string.tracking @@ -215,8 +214,8 @@ class MangaHeaderHolder( with(binding.startReadingButton) { val nextChapter = presenter.getNextUnreadChapter() - visibleIf(presenter.chapters.isNotEmpty() && !item.isLocked && !adapter.hasFilter()) - showReadingButton = isVisible() + isVisible = presenter.chapters.isNotEmpty() && !item.isLocked && !adapter.hasFilter() + showReadingButton = isVisible isEnabled = (nextChapter != null) text = if (nextChapter != null) { val number = adapter.decimalFormat.format(nextChapter.chapter_number.toDouble()) @@ -243,7 +242,7 @@ class MangaHeaderHolder( height = adapter.delegate.topCoverHeight() } - binding.mangaStatus.visibleIf(manga.status != 0) + binding.mangaStatus.isVisible = manga.status != 0 binding.mangaStatus.text = ( itemView.context.getString( when (manga.status) { @@ -353,7 +352,7 @@ class MangaHeaderHolder( binding.mangaGenresTags.visible() } } - binding.startReadingButton.visibleIf(showReadingButton) + binding.startReadingButton.isVisible = showReadingButton } override fun onLongClick(view: View?): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index c0db4958d9..b24d4ff9ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter import android.animation.AnimatorSet import android.animation.ObjectAnimator import android.view.View +import androidx.core.view.isVisible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download @@ -12,9 +13,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaDetailsAdapter import eu.kanade.tachiyomi.util.chapter.ChapterUtil import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.gone -import eu.kanade.tachiyomi.util.view.isVisible import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.widget.EndAnimatorListener import eu.kanade.tachiyomi.widget.StartAnimatorListener @@ -45,7 +44,7 @@ class ChapterHolder( } localSource = manga.source == LocalSource.ID - binding.downloadButton.downloadButton.visibleIf(!localSource && !isLocked) + binding.downloadButton.downloadButton.isVisible = !localSource && !isLocked ChapterUtil.setTextViewForChapter(binding.chapterTitle, item, hideStatus = isLocked) @@ -115,7 +114,7 @@ class ChapterHolder( anim2.duration = 600 anim2.startDelay = 500 anim2.addUpdateListener { - if (binding.leftView.isVisible() && binding.frontView.translationX <= 0) { + if (binding.leftView.isVisible && binding.frontView.translationX <= 0) { binding.leftView.gone() binding.rightView.visible() } @@ -157,7 +156,7 @@ class ChapterHolder( gone() return } - visibleIf(!localSource) + isVisible = !localSource setDownloadStatus(status, progress, animated) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt index bbbc2a8a46..64e4e7242d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSortBottomSheet.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter import android.os.Bundle import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import eu.kanade.tachiyomi.R @@ -14,7 +15,6 @@ import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.setBottomEdge import eu.kanade.tachiyomi.util.view.setEdgeToEdge import eu.kanade.tachiyomi.util.view.visInvisIf -import eu.kanade.tachiyomi.util.view.visibleIf import kotlin.math.max class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog @@ -72,7 +72,7 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD val isScrollable = binding.settingsScrollView.height < binding.sortLayout.height + binding.settingsScrollView.paddingTop + binding.settingsScrollView.paddingBottom - binding.closeButton.visibleIf(isScrollable) + binding.closeButton.isVisible = isScrollable // making the view gone somehow breaks the layout so lets make it invisible binding.pill.visInvisIf(!isScrollable) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt index e9ee08b42e..04c60e00f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt @@ -3,13 +3,13 @@ package eu.kanade.tachiyomi.ui.manga.track import android.annotation.SuppressLint import android.view.View import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.isVisible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.TrackItemBinding import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder import eu.kanade.tachiyomi.util.view.updateLayoutParams -import eu.kanade.tachiyomi.util.view.visibleIf import uy.kohesive.injekt.injectLazy import java.text.DateFormat @@ -44,8 +44,8 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) { } val serviceName = binding.trackLogo.context.getString(item.service.nameRes()) binding.trackLogo.contentDescription = serviceName - binding.trackGroup.visibleIf(track != null) - binding.addTracking.visibleIf(track == null) + binding.trackGroup.isVisible = track != null + binding.addTracking.isVisible = track == null if (track != null) { binding.trackTitle.text = track.title with(binding.trackChapters) { @@ -70,7 +70,7 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) { else binding.trackStatus.text = item.service.getStatus(track.status) binding.trackScore.text = if (track.score == 0f) "-" else item.service.displayScore(track) binding.trackScore.setCompoundDrawablesWithIntrinsicBounds(0, 0, starIcon(track), 0) - binding.dateGroup.visibleIf(item.service.supportsReadingDates) + binding.dateGroup.isVisible = item.service.supportsReadingDates if (item.service.supportsReadingDates) { binding.trackStartDate.text = if (track.started_reading_date != 0L) dateFormat.format(track.started_reading_date) else "-" @@ -90,7 +90,7 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) { } fun setProgress(enabled: Boolean) { - binding.progress.visibleIf(enabled) - binding.trackLogo.visibleIf(!enabled) + binding.progress.isVisible = enabled + binding.trackLogo.isVisible = !enabled } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt index 6190b1d3c4..37599c0390 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt @@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.viewer.pager.PageLayout import eu.kanade.tachiyomi.util.bindToPreference import eu.kanade.tachiyomi.util.lang.addBetaTag -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.widget.BaseReaderSettingsView class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : @@ -76,14 +75,14 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu binding.pagerNav, binding.pagerInvert, binding.pageLayout - ).forEach { it.visibleIf(show) } + ).forEach { it.isVisible = show } listOf( binding.cropBordersWebtoon, binding.webtoonSidePadding, binding.webtoonEnableZoomOut, binding.webtoonNav, binding.webtoonInvert - ).forEach { it.visibleIf(!show) } + ).forEach { it.isVisible = !show } val isFullFit = when (preferences.imageScaleType().get()) { SubsamplingScaleImageView.SCALE_TYPE_FIT_HEIGHT, SubsamplingScaleImageView.SCALE_TYPE_SMART_FIT, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt index b8cf668876..50fc1bcf38 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt @@ -13,11 +13,11 @@ import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatTextView +import androidx.core.view.isVisible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.util.system.dpToPx -import eu.kanade.tachiyomi.util.view.visibleIf import rx.Subscription import rx.android.schedulers.AndroidSchedulers @@ -154,7 +154,7 @@ class WebtoonTransitionHolder( is ReaderChapter.State.Error -> setError(state.error, transition) is ReaderChapter.State.Loaded -> setLoaded() } - pagesContainer.visibleIf(pagesContainer.childCount > 0) + pagesContainer.isVisible = pagesContainer.childCount > 0 } addSubscription(statusSubscription) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt index a5e865f0dd..1d8f8d3abb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt @@ -8,6 +8,7 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.SearchView +import androidx.core.view.isVisible import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -41,7 +42,6 @@ import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.util.view.withFadeTransaction import eu.kanade.tachiyomi.widget.AutofitRecyclerView import eu.kanade.tachiyomi.widget.EmptyView @@ -128,7 +128,7 @@ open class BrowseSourceController(bundle: Bundle) : adapter = FlexibleAdapter(null, this) setupRecycler(view) - binding.fab.visibleIf(presenter.sourceFilters.isNotEmpty()) + binding.fab.isVisible = presenter.sourceFilters.isNotEmpty() binding.fab.setOnClickListener { showFilters() } binding.progress.visible() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchMangaHolder.kt index ebe44ff293..f3e69fc75f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/global_search/GlobalSearchMangaHolder.kt @@ -1,15 +1,15 @@ package eu.kanade.tachiyomi.ui.source.global_search import android.view.View +import androidx.core.view.isVisible import coil.Coil import coil.api.clear import coil.request.CachePolicy import coil.request.LoadRequest import eu.kanade.tachiyomi.data.database.models.Manga -import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder -import eu.kanade.tachiyomi.util.view.visibleIf import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget import eu.kanade.tachiyomi.databinding.SourceGlobalSearchControllerCardItemBinding +import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) : BaseFlexibleViewHolder(view, adapter) { @@ -31,7 +31,7 @@ class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) : fun bind(manga: Manga) { binding.title.text = manga.title - binding.favoriteButton.visibleIf(manga.favorite) + binding.favoriteButton.isVisible = manga.favorite setImage(manga) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt index cbfebae19a..073fcf6f02 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt @@ -359,7 +359,7 @@ fun Controller.scrollViewWith( 0f ) val tabBar = activityBinding!!.bottomNav - if (tabBar.isVisible() && isInView) { + if (tabBar.isVisible && isInView) { if (preferences.hideBottomNavOnScroll().get()) { tabBar.translationY += dy tabBar.translationY = MathUtils.clamp( diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 0aa64debdd..12b9721828 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -114,14 +114,6 @@ inline fun View.gone() { visibility = View.GONE } -inline fun View.isVisible(): Boolean { - return visibility == View.VISIBLE -} - -inline fun View.visibleIf(show: Boolean) { - visibility = if (show) View.VISIBLE else View.GONE -} - inline fun View.visInvisIf(show: Boolean) { visibility = if (show) View.VISIBLE else View.INVISIBLE }