mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 16:01:48 +01:00
Replace visInvisIf helper with isInvisible
This commit is contained in:
parent
18111be272
commit
7dbd6a4128
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga.chapter
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
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.invisible
|
||||||
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
import eu.kanade.tachiyomi.util.view.setBottomEdge
|
||||||
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
import eu.kanade.tachiyomi.util.view.setEdgeToEdge
|
||||||
import eu.kanade.tachiyomi.util.view.visInvisIf
|
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
|
class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetDialog
|
||||||
@ -74,7 +74,7 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
|
|||||||
binding.settingsScrollView.paddingTop + binding.settingsScrollView.paddingBottom
|
binding.settingsScrollView.paddingTop + binding.settingsScrollView.paddingBottom
|
||||||
binding.closeButton.isVisible = isScrollable
|
binding.closeButton.isVisible = isScrollable
|
||||||
// making the view gone somehow breaks the layout so lets make it invisible
|
// making the view gone somehow breaks the layout so lets make it invisible
|
||||||
binding.pill.visInvisIf(!isScrollable)
|
binding.pill.isInvisible = isScrollable
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnDismissListener {
|
setOnDismissListener {
|
||||||
@ -104,15 +104,13 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.setAsDefaultSort.visInvisIf(
|
binding.setAsDefaultSort.isInvisible = defPref == presenter.manga.sortDescending() ||
|
||||||
defPref != presenter.manga.sortDescending() &&
|
!presenter.manga.usesLocalSort()
|
||||||
presenter.manga.usesLocalSort()
|
|
||||||
)
|
|
||||||
binding.sortGroup.setOnCheckedChangeListener { _, checkedId ->
|
binding.sortGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||||
presenter.setSortOrder(checkedId == R.id.sort_newest)
|
presenter.setSortOrder(checkedId == R.id.sort_newest)
|
||||||
binding.setAsDefaultSort.visInvisIf(
|
binding.setAsDefaultSort.isInvisible = (
|
||||||
defPref != presenter.manga.sortDescending() &&
|
defPref == presenter.manga.sortDescending() ||
|
||||||
presenter.manga.usesLocalSort()
|
!presenter.manga.usesLocalSort()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.core.view.GestureDetectorCompat
|
import androidx.core.view.GestureDetectorCompat
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
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.snack
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
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.util.view.visible
|
||||||
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
|
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
|
||||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||||
@ -257,7 +257,7 @@ class ReaderActivity :
|
|||||||
lastShiftDoubleState = savedInstanceState.get(SHIFT_DOUBLE_PAGES) as? Boolean
|
lastShiftDoubleState = savedInstanceState.get(SHIFT_DOUBLE_PAGES) as? Boolean
|
||||||
indexPageToShift = savedInstanceState.get(SHIFTED_PAGE_INDEX) as? Int
|
indexPageToShift = savedInstanceState.get(SHIFTED_PAGE_INDEX) as? Int
|
||||||
indexChapterToShift = savedInstanceState.get(SHIFTED_CHAP_INDEX) as? Long
|
indexChapterToShift = savedInstanceState.get(SHIFTED_CHAP_INDEX) as? Long
|
||||||
binding.readerNav.root.visInvisIf(menuVisible)
|
binding.readerNav.root.isInvisible = !menuVisible
|
||||||
} else {
|
} else {
|
||||||
binding.readerNav.root.invisible()
|
binding.readerNav.root.invisible()
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isInvisible
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import eu.kanade.tachiyomi.R
|
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.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
import eu.kanade.tachiyomi.util.view.isCollapsed
|
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.util.view.visible
|
||||||
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class TabbedReaderSettingsSheet(
|
|||||||
binding.tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
binding.tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||||
window?.setDimAmount(if (tab?.position == filterTabIndex) 0f else ogDim)
|
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) {
|
if (tab?.position == 2) {
|
||||||
sheetBehavior.skipCollapsed = false
|
sheetBehavior.skipCollapsed = false
|
||||||
sheetBehavior.peekHeight = 110.dpToPx
|
sheetBehavior.peekHeight = 110.dpToPx
|
||||||
|
@ -6,6 +6,7 @@ import android.content.res.ColorStateList
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceViewHolder
|
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.appDelegateNightMode
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.isInNightMode
|
import eu.kanade.tachiyomi.util.system.isInNightMode
|
||||||
import eu.kanade.tachiyomi.util.view.visInvisIf
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class ThemePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
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.themeNameText.setText(item.theme.nameRes)
|
||||||
|
|
||||||
binding.checkbox.isVisible = item.isSelected
|
binding.checkbox.isVisible = item.isSelected
|
||||||
binding.themeSelected.visInvisIf(item.isSelected)
|
binding.themeSelected.isInvisible = !item.isSelected
|
||||||
|
|
||||||
if (binding.checkbox.isVisible) {
|
if (binding.checkbox.isVisible) {
|
||||||
val themeMatchesApp = if (context.isInNightMode()) {
|
val themeMatchesApp = if (context.isInNightMode()) {
|
||||||
|
@ -114,10 +114,6 @@ inline fun View.gone() {
|
|||||||
visibility = View.GONE
|
visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun View.visInvisIf(show: Boolean) {
|
|
||||||
visibility = if (show) View.VISIBLE else View.INVISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
inline val View.marginTop: Int
|
inline val View.marginTop: Int
|
||||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0
|
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user