Replace visInvisIf helper with isInvisible

This commit is contained in:
Jays2Kings 2021-04-26 01:46:28 -04:00
parent 18111be272
commit 7dbd6a4128
5 changed files with 14 additions and 20 deletions

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.isInvisible
import androidx.core.view.isVisible
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
@ -14,7 +15,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx
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 kotlin.math.max
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
@ -74,7 +74,7 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
binding.settingsScrollView.paddingTop + binding.settingsScrollView.paddingBottom
binding.closeButton.isVisible = isScrollable
// making the view gone somehow breaks the layout so lets make it invisible
binding.pill.visInvisIf(!isScrollable)
binding.pill.isInvisible = isScrollable
}
setOnDismissListener {
@ -104,16 +104,14 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
}
)
binding.setAsDefaultSort.visInvisIf(
defPref != presenter.manga.sortDescending() &&
presenter.manga.usesLocalSort()
)
binding.setAsDefaultSort.isInvisible = defPref == presenter.manga.sortDescending() ||
!presenter.manga.usesLocalSort()
binding.sortGroup.setOnCheckedChangeListener { _, checkedId ->
presenter.setSortOrder(checkedId == R.id.sort_newest)
binding.setAsDefaultSort.visInvisIf(
defPref != presenter.manga.sortDescending() &&
presenter.manga.usesLocalSort()
)
binding.setAsDefaultSort.isInvisible = (
defPref == presenter.manga.sortDescending() ||
!presenter.manga.usesLocalSort()
)
}
binding.setAsDefaultSort.setOnClickListener {

View File

@ -25,6 +25,7 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.view.GestureDetectorCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.afollestad.materialdialogs.MaterialDialog
@ -93,7 +94,6 @@ import eu.kanade.tachiyomi.util.view.popupMenu
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.visInvisIf
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
@ -257,7 +257,7 @@ class ReaderActivity :
lastShiftDoubleState = savedInstanceState.get(SHIFT_DOUBLE_PAGES) as? Boolean
indexPageToShift = savedInstanceState.get(SHIFTED_PAGE_INDEX) as? Int
indexChapterToShift = savedInstanceState.get(SHIFTED_CHAP_INDEX) as? Long
binding.readerNav.root.visInvisIf(menuVisible)
binding.readerNav.root.isInvisible = !menuVisible
} else {
binding.readerNav.root.invisible()
}

View File

@ -4,6 +4,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.core.content.ContextCompat
import androidx.core.view.isInvisible
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.tabs.TabLayout
import eu.kanade.tachiyomi.R
@ -14,7 +15,6 @@ import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.collapse
import eu.kanade.tachiyomi.util.view.expand
import eu.kanade.tachiyomi.util.view.isCollapsed
import eu.kanade.tachiyomi.util.view.visInvisIf
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
@ -99,7 +99,7 @@ class TabbedReaderSettingsSheet(
binding.tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
window?.setDimAmount(if (tab?.position == filterTabIndex) 0f else ogDim)
readerActivity.binding.appBar.visInvisIf(tab?.position != filterTabIndex)
readerActivity.binding.appBar.isInvisible = tab?.position == filterTabIndex
if (tab?.position == 2) {
sheetBehavior.skipCollapsed = false
sheetBehavior.peekHeight = 110.dpToPx

View File

@ -6,6 +6,7 @@ import android.content.res.ColorStateList
import android.util.AttributeSet
import android.view.View
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
@ -25,7 +26,6 @@ import eu.kanade.tachiyomi.util.system.Themes
import eu.kanade.tachiyomi.util.system.appDelegateNightMode
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.isInNightMode
import eu.kanade.tachiyomi.util.view.visInvisIf
import uy.kohesive.injekt.injectLazy
class ThemePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
@ -146,7 +146,7 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
binding.themeNameText.setText(item.theme.nameRes)
binding.checkbox.isVisible = item.isSelected
binding.themeSelected.visInvisIf(item.isSelected)
binding.themeSelected.isInvisible = !item.isSelected
if (binding.checkbox.isVisible) {
val themeMatchesApp = if (context.isInNightMode()) {

View File

@ -114,10 +114,6 @@ inline fun View.gone() {
visibility = View.GONE
}
inline fun View.visInvisIf(show: Boolean) {
visibility = if (show) View.VISIBLE else View.INVISIBLE
}
inline val View.marginTop: Int
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0