Removing isVisible/visibleIf helper methods for androidx.core.view

This commit is contained in:
Jays2Kings 2021-04-26 01:39:09 -04:00
parent 20f8fac479
commit 18111be272
21 changed files with 71 additions and 88 deletions

View File

@ -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) {

View File

@ -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() }
}

View File

@ -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

View File

@ -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)
}
}

View File

@ -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) {

View File

@ -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()

View File

@ -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
}
}
}

View File

@ -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()
}
}

View File

@ -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<String?>(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

View File

@ -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<MainActivityBinding>(), 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<ViewGroup.LayoutParams> {
height = insets.systemWindowInsetBottom
}
@ -283,7 +282,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), 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<MainActivityBinding>(), DownloadServiceLi
}
alphaAnimation.addListener(
EndAnimatorListener {
binding.bottomNav.visibleIf(!hideBottomNav)
binding.bottomNav.isVisible = !hideBottomNav
binding.bottomView.visibility =
if (hideBottomNav) View.GONE else binding.bottomView.visibility
}

View File

@ -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,

View File

@ -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 {

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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
}
}

View File

@ -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,

View File

@ -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)

View File

@ -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()
}

View File

@ -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)
}

View File

@ -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(

View File

@ -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
}