Replace custom visibility extension functions

This commit is contained in:
arkon 2020-07-25 11:55:47 -04:00
parent bdc441a5be
commit 9e51d82154
33 changed files with 187 additions and 230 deletions

View File

@ -3,12 +3,12 @@ package eu.kanade.tachiyomi.ui.browse.extension.details
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.ExtensionDetailHeaderBinding import eu.kanade.tachiyomi.databinding.ExtensionDetailHeaderBinding
import eu.kanade.tachiyomi.ui.browse.extension.getApplicationIcon import eu.kanade.tachiyomi.ui.browse.extension.getApplicationIcon
import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -49,12 +49,12 @@ class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPrese
.launchIn(scope) .launchIn(scope)
if (extension.isObsolete) { if (extension.isObsolete) {
binding.extensionWarningBanner.visible() binding.extensionWarningBanner.isVisible = true
binding.extensionWarningBanner.setText(R.string.obsolete_extension_message) binding.extensionWarningBanner.setText(R.string.obsolete_extension_message)
} }
if (extension.isUnofficial) { if (extension.isUnofficial) {
binding.extensionWarningBanner.visible() binding.extensionWarningBanner.isVisible = true
binding.extensionWarningBanner.setText(R.string.unofficial_extension_message) binding.extensionWarningBanner.setText(R.string.unofficial_extension_message)
} }
} }

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.migration.search
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import androidx.core.view.isVisible
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice import com.afollestad.materialdialogs.list.listItemsMultiChoice
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@ -11,8 +12,6 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
class SearchController( class SearchController(
@ -69,9 +68,9 @@ class SearchController(
fun renderIsReplacingManga(isReplacingManga: Boolean) { fun renderIsReplacingManga(isReplacingManga: Boolean) {
if (isReplacingManga) { if (isReplacingManga) {
binding.progress.visible() binding.progress.isVisible = true
} else { } else {
binding.progress.gone() binding.progress.isVisible = false
router.popController(this) router.popController(this)
} }
} }

View File

@ -1,10 +1,10 @@
package eu.kanade.tachiyomi.ui.browse.migration.sources package eu.kanade.tachiyomi.ui.browse.migration.sources
import android.view.View import android.view.View
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.source.icon import eu.kanade.tachiyomi.source.icon
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder
import eu.kanade.tachiyomi.util.view.gone
import io.github.mthli.slice.Slice import io.github.mthli.slice.Slice
import kotlinx.android.synthetic.main.source_main_controller_card_item.card import kotlinx.android.synthetic.main.source_main_controller_card_item.card
import kotlinx.android.synthetic.main.source_main_controller_card_item.image import kotlinx.android.synthetic.main.source_main_controller_card_item.image
@ -24,8 +24,8 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
get() = card get() = card
init { init {
source_latest.gone() source_latest.isVisible = false
source_browse.gone() source_browse.isVisible = false
} }
fun bind(item: SourceItem) { fun bind(item: SourceItem) {

View File

@ -1,13 +1,12 @@
package eu.kanade.tachiyomi.ui.browse.source package eu.kanade.tachiyomi.ui.browse.source
import android.view.View import android.view.View
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.icon import eu.kanade.tachiyomi.source.icon
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import io.github.mthli.slice.Slice import io.github.mthli.slice.Slice
import kotlinx.android.synthetic.main.source_main_controller_card_item.card import kotlinx.android.synthetic.main.source_main_controller_card_item.card
import kotlinx.android.synthetic.main.source_main_controller_card_item.image import kotlinx.android.synthetic.main.source_main_controller_card_item.image
@ -53,10 +52,6 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
} }
source_browse.setText(R.string.browse) source_browse.setText(R.string.browse)
if (source.supportsLatest) { source_latest.isVisible = source.supportsLatest
source_latest.visible()
} else {
source_latest.gone()
}
} }
} }

View File

@ -9,6 +9,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.view.isVisible
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -40,11 +41,9 @@ import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.connectivityManager import eu.kanade.tachiyomi.util.system.connectivityManager
import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
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 eu.kanade.tachiyomi.util.view.visible
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.coroutines.Job import kotlinx.coroutines.Job
@ -141,7 +140,7 @@ open class BrowseSourceController(bundle: Bundle) :
adapter = FlexibleAdapter(null, this) adapter = FlexibleAdapter(null, this)
setupRecycler(view) setupRecycler(view)
binding.progress.visible() binding.progress.isVisible = true
} }
open fun initFilterSheet() { open fun initFilterSheet() {
@ -167,19 +166,19 @@ open class BrowseSourceController(bundle: Bundle) :
filterSheet?.setFilters(presenter.filterItems) filterSheet?.setFilters(presenter.filterItems)
// TODO: [ExtendedFloatingActionButton] hide/show methods don't work properly // TODO: [ExtendedFloatingActionButton] hide/show methods don't work properly
filterSheet?.setOnShowListener { actionFab?.gone() } filterSheet?.setOnShowListener { actionFab?.isVisible = false }
filterSheet?.setOnDismissListener { actionFab?.visible() } filterSheet?.setOnDismissListener { actionFab?.isVisible = true }
actionFab?.setOnClickListener { filterSheet?.show() } actionFab?.setOnClickListener { filterSheet?.show() }
actionFab?.visible() actionFab?.isVisible = true
} }
override fun configureFab(fab: ExtendedFloatingActionButton) { override fun configureFab(fab: ExtendedFloatingActionButton) {
actionFab = fab actionFab = fab
// Controlled by initFilterSheet() // Controlled by initFilterSheet()
fab.gone() fab.isVisible = false
fab.setText(R.string.action_filter) fab.setText(R.string.action_filter)
fab.setIconResource(R.drawable.ic_filter_list_24dp) fab.setIconResource(R.drawable.ic_filter_list_24dp)
@ -515,7 +514,7 @@ open class BrowseSourceController(bundle: Bundle) :
*/ */
private fun showProgressBar() { private fun showProgressBar() {
binding.emptyView.hide() binding.emptyView.hide()
binding.progress.visible() binding.progress.isVisible = true
snack?.dismiss() snack?.dismiss()
snack = null snack = null
} }
@ -525,7 +524,7 @@ open class BrowseSourceController(bundle: Bundle) :
*/ */
private fun hideProgressBar() { private fun hideProgressBar() {
binding.emptyView.hide() binding.emptyView.hide()
binding.progress.gone() binding.progress.isVisible = false
} }
/** /**

View File

@ -3,14 +3,13 @@ package eu.kanade.tachiyomi.ui.browse.source.browse
import android.view.View import android.view.View
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView import android.widget.TextView
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
class ProgressItem : AbstractFlexibleItem<ProgressItem.Holder>() { class ProgressItem : AbstractFlexibleItem<ProgressItem.Holder>() {
@ -25,17 +24,17 @@ class ProgressItem : AbstractFlexibleItem<ProgressItem.Holder>() {
} }
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: List<Any?>) { override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: List<Any?>) {
holder.progressBar.gone() holder.progressBar.isVisible = false
holder.progressMessage.gone() holder.progressMessage.isVisible = false
if (!adapter.isEndlessScrollEnabled) { if (!adapter.isEndlessScrollEnabled) {
loadMore = false loadMore = false
} }
if (loadMore) { if (loadMore) {
holder.progressBar.visible() holder.progressBar.isVisible = true
} else { } else {
holder.progressMessage.visible() holder.progressMessage.isVisible = true
} }
} }

View File

@ -1,11 +1,10 @@
package eu.kanade.tachiyomi.ui.browse.source.globalsearch package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.view.View import android.view.View
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.global_search_controller_card.no_results_found import kotlinx.android.synthetic.main.global_search_controller_card.no_results_found
import kotlinx.android.synthetic.main.global_search_controller_card.progress import kotlinx.android.synthetic.main.global_search_controller_card.progress
import kotlinx.android.synthetic.main.global_search_controller_card.recycler import kotlinx.android.synthetic.main.global_search_controller_card.recycler
@ -58,15 +57,15 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
when { when {
results == null -> { results == null -> {
progress.visible() progress.isVisible = true
showResultsHolder() showResultsHolder()
} }
results.isEmpty() -> { results.isEmpty() -> {
progress.gone() progress.isVisible = false
showNoResults() showNoResults()
} }
else -> { else -> {
progress.gone() progress.isVisible = false
showResultsHolder() showResultsHolder()
} }
} }
@ -103,12 +102,12 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
} }
private fun showResultsHolder() { private fun showResultsHolder() {
no_results_found.gone() no_results_found.isVisible = false
source_card.visible() source_card.isVisible = true
} }
private fun showNoResults() { private fun showNoResults() {
no_results_found.visible() no_results_found.isVisible = true
source_card.gone() source_card.isVisible = false
} }
} }

View File

@ -6,6 +6,7 @@ import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
@ -16,9 +17,7 @@ import eu.kanade.tachiyomi.databinding.DownloadControllerBinding
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
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.util.view.gone
import eu.kanade.tachiyomi.util.view.shrinkOnScroll import eu.kanade.tachiyomi.util.view.shrinkOnScroll
import eu.kanade.tachiyomi.util.view.visible
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -284,11 +283,11 @@ class DownloadController :
private fun setInformationView() { private fun setInformationView() {
if (presenter.downloadQueue.isEmpty()) { if (presenter.downloadQueue.isEmpty()) {
binding.emptyView.show(R.string.information_no_downloads) binding.emptyView.show(R.string.information_no_downloads)
actionFab?.gone() actionFab?.isVisible = false
} else { } else {
binding.emptyView.hide() binding.emptyView.hide()
actionFab?.apply { actionFab?.apply {
visible() isVisible = true
setText( setText(
if (isRunning) { if (isRunning) {

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
import android.view.View import android.view.View
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
@ -8,7 +9,6 @@ import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_comfortable_grid_item.badges import kotlinx.android.synthetic.main.source_comfortable_grid_item.badges
import kotlinx.android.synthetic.main.source_comfortable_grid_item.card import kotlinx.android.synthetic.main.source_comfortable_grid_item.card
import kotlinx.android.synthetic.main.source_comfortable_grid_item.download_text import kotlinx.android.synthetic.main.source_comfortable_grid_item.download_text
@ -46,16 +46,16 @@ class LibraryComfortableGridHolder(
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(unread_text) { with(unread_text) {
visibleIf { item.unreadCount > 0 } isVisible = item.unreadCount > 0
text = item.unreadCount.toString() text = item.unreadCount.toString()
} }
// Update the download count and its visibility. // Update the download count and its visibility.
with(download_text) { with(download_text) {
visibleIf { item.downloadCount > 0 } isVisible = item.downloadCount > 0
text = item.downloadCount.toString() text = item.downloadCount.toString()
} }
// set local visibility if its local manga // set local visibility if its local manga
local_text.visibleIf { item.manga.isLocal() } local_text.isVisible = item.manga.isLocal()
// For rounded corners // For rounded corners
card.clipToOutline = true card.clipToOutline = true

View File

@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
import android.view.View import android.view.View
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_compact_grid_item.badges import kotlinx.android.synthetic.main.source_compact_grid_item.badges
import kotlinx.android.synthetic.main.source_compact_grid_item.card import kotlinx.android.synthetic.main.source_compact_grid_item.card
import kotlinx.android.synthetic.main.source_compact_grid_item.download_text import kotlinx.android.synthetic.main.source_compact_grid_item.download_text
@ -44,16 +44,16 @@ open class LibraryCompactGridHolder(
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(unread_text) { with(unread_text) {
visibleIf { item.unreadCount > 0 } isVisible = item.unreadCount > 0
text = item.unreadCount.toString() text = item.unreadCount.toString()
} }
// Update the download count and its visibility. // Update the download count and its visibility.
with(download_text) { with(download_text) {
visibleIf { item.downloadCount > 0 } isVisible = item.downloadCount > 0
text = item.downloadCount.toString() text = item.downloadCount.toString()
} }
// set local visibility if its local manga // set local visibility if its local manga
local_text.visibleIf { item.manga.isLocal() } local_text.isVisible = item.manga.isLocal()
// For rounded corners // For rounded corners
card.clipToOutline = true card.clipToOutline = true

View File

@ -12,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode import androidx.appcompat.view.ActionMode
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.isVisible
import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType import com.bluelinelabs.conductor.ControllerChangeType
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
@ -36,8 +37,6 @@ import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight
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 eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.main_activity.tabs import kotlinx.android.synthetic.main.main_activity.tabs
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.drop
@ -195,7 +194,7 @@ class LibraryController(
} }
if (preferences.downloadedOnly().get()) { if (preferences.downloadedOnly().get()) {
binding.downloadedOnly.visible() binding.downloadedOnly.isVisible = true
} }
binding.btnGlobalSearch.clicks() binding.btnGlobalSearch.clicks()
@ -402,11 +401,11 @@ class LibraryController(
private fun performSearch() { private fun performSearch() {
searchRelay.call(query) searchRelay.call(query)
if (!query.isNullOrEmpty()) { if (!query.isNullOrEmpty()) {
binding.btnGlobalSearch.visible() binding.btnGlobalSearch.isVisible = true
binding.btnGlobalSearch.text = binding.btnGlobalSearch.text =
resources?.getString(R.string.action_global_search_query, query) resources?.getString(R.string.action_global_search_query, query)
} else { } else {
binding.btnGlobalSearch.gone() binding.btnGlobalSearch.isVisible = false
} }
} }

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.library package eu.kanade.tachiyomi.ui.library
import android.view.View import android.view.View
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners import com.bumptech.glide.load.resource.bitmap.RoundedCorners
@ -10,7 +11,6 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.isLocal
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.source_list_item.badges import kotlinx.android.synthetic.main.source_list_item.badges
import kotlinx.android.synthetic.main.source_list_item.download_text import kotlinx.android.synthetic.main.source_list_item.download_text
import kotlinx.android.synthetic.main.source_list_item.local_text import kotlinx.android.synthetic.main.source_list_item.local_text
@ -48,16 +48,16 @@ class LibraryListHolder(
// Update the unread count and its visibility. // Update the unread count and its visibility.
with(unread_text) { with(unread_text) {
visibleIf { item.unreadCount > 0 } isVisible = item.unreadCount > 0
text = item.unreadCount.toString() text = item.unreadCount.toString()
} }
// Update the download count and its visibility. // Update the download count and its visibility.
with(download_text) { with(download_text) {
visibleIf { item.downloadCount > 0 } isVisible = item.downloadCount > 0
text = "${item.downloadCount}" text = "${item.downloadCount}"
} }
// show local text badge if local manga // show local text badge if local manga
local_text.visibleIf { item.manga.isLocal() } local_text.isVisible = item.manga.isLocal()
// Create thumbnail onclick to simulate long click // Create thumbnail onclick to simulate long click
thumbnail.setOnClickListener { thumbnail.setOnClickListener {

View File

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.isVisible
import com.bluelinelabs.conductor.Conductor import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeHandler
@ -43,9 +44,7 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.util.view.visible
import java.util.Date import java.util.Date
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.main_activity.appbar import kotlinx.android.synthetic.main.main_activity.appbar
@ -349,11 +348,11 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
} }
if (from is FabController) { if (from is FabController) {
binding.rootFab.gone() binding.rootFab.isVisible = false
from.cleanupFab(binding.rootFab) from.cleanupFab(binding.rootFab)
} }
if (to is FabController) { if (to is FabController) {
binding.rootFab.visible() binding.rootFab.isVisible = true
to.configureFab(binding.rootFab) to.configureFab(binding.rootFab)
} }

View File

@ -14,6 +14,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode import androidx.appcompat.view.ActionMode
import androidx.core.view.isVisible
import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -65,10 +66,8 @@ import eu.kanade.tachiyomi.util.hasCustomCover
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 eu.kanade.tachiyomi.util.view.getCoordinates import eu.kanade.tachiyomi.util.view.getCoordinates
import eu.kanade.tachiyomi.util.view.gone
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 eu.kanade.tachiyomi.util.view.visible
import kotlin.math.min import kotlin.math.min
import kotlinx.android.synthetic.main.main_activity.root_coordinator import kotlinx.android.synthetic.main.main_activity.root_coordinator
import kotlinx.android.synthetic.main.main_activity.toolbar import kotlinx.android.synthetic.main.main_activity.toolbar
@ -316,7 +315,7 @@ class MangaController :
if (view == null) return if (view == null) return
// Check if animation view is visible // Check if animation view is visible
if (binding.revealView.visibility == View.VISIBLE) { if (binding.revealView.isVisible) {
// Show the unreveal effect // Show the unreveal effect
actionFab?.getCoordinates()?.let { coordinates -> actionFab?.getCoordinates()?.let { coordinates ->
binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920) binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920)
@ -804,7 +803,7 @@ class MangaController :
// Hide FAB to avoid interfering with the bottom action toolbar // Hide FAB to avoid interfering with the bottom action toolbar
// actionFab?.hide() // actionFab?.hide()
actionFab?.gone() actionFab?.isVisible = false
} }
return false return false
} }
@ -839,7 +838,7 @@ class MangaController :
// TODO: there seems to be a bug in MaterialComponents where the [ExtendedFloatingActionButton] // TODO: there seems to be a bug in MaterialComponents where the [ExtendedFloatingActionButton]
// fails to show up properly // fails to show up properly
// actionFab?.show() // actionFab?.show()
actionFab?.visible() actionFab?.isVisible = true
} }
override fun onDetach(view: View) { override fun onDetach(view: View) {

View File

@ -4,11 +4,11 @@ import android.text.SpannableString
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan import android.text.style.ForegroundColorSpan
import android.view.View import android.view.View
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.view.visibleIf
import java.util.Date import java.util.Date
import kotlinx.android.synthetic.main.chapters_item.bookmark_icon import kotlinx.android.synthetic.main.chapters_item.bookmark_icon
import kotlinx.android.synthetic.main.chapters_item.chapter_description import kotlinx.android.synthetic.main.chapters_item.chapter_description
@ -40,7 +40,7 @@ class ChapterHolder(
chapter_title.setTextColor(chapterColor) chapter_title.setTextColor(chapterColor)
chapter_description.setTextColor(chapterColor) chapter_description.setTextColor(chapterColor)
bookmark_icon.visibleIf { chapter.bookmark } bookmark_icon.isVisible = chapter.bookmark
val descriptions = mutableListOf<CharSequence>() val descriptions = mutableListOf<CharSequence>()

View File

@ -22,11 +22,8 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.setChips import eu.kanade.tachiyomi.util.view.setChips
import eu.kanade.tachiyomi.util.view.setTooltip import eu.kanade.tachiyomi.util.view.setTooltip
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
@ -105,7 +102,7 @@ class MangaInfoHeaderAdapter(
with(binding.btnTracking) { with(binding.btnTracking) {
if (trackManager.hasLoggedServices()) { if (trackManager.hasLoggedServices()) {
visible() isVisible = true
if (trackCount > 0) { if (trackCount > 0) {
setIconResource(R.drawable.ic_done_24dp) setIconResource(R.drawable.ic_done_24dp)
@ -121,18 +118,18 @@ class MangaInfoHeaderAdapter(
.onEach { controller.onTrackingClick() } .onEach { controller.onTrackingClick() }
.launchIn(scope) .launchIn(scope)
} else { } else {
gone() isVisible = false
} }
} }
if (controller.presenter.source is HttpSource) { if (controller.presenter.source is HttpSource) {
binding.btnWebview.visible() binding.btnWebview.isVisible = true
binding.btnWebview.clicks() binding.btnWebview.clicks()
.onEach { controller.openMangaInWebView() } .onEach { controller.openMangaInWebView() }
.launchIn(scope) .launchIn(scope)
binding.btnWebview.setTooltip(R.string.action_open_in_web_view) binding.btnWebview.setTooltip(R.string.action_open_in_web_view)
binding.btnShare.visible() binding.btnShare.isVisible = true
binding.btnShare.clicks() binding.btnShare.clicks()
.onEach { controller.shareManga() } .onEach { controller.shareManga() }
.launchIn(scope) .launchIn(scope)
@ -291,7 +288,7 @@ class MangaInfoHeaderAdapter(
binding.mangaGenresTagsCompactChips.setChips(manga.getGenres(), controller::performSearch) binding.mangaGenresTagsCompactChips.setChips(manga.getGenres(), controller::performSearch)
binding.mangaGenresTagsFullChips.setChips(manga.getGenres(), controller::performSearch) binding.mangaGenresTagsFullChips.setChips(manga.getGenres(), controller::performSearch)
} else { } else {
binding.mangaGenresTagsWrapper.gone() binding.mangaGenresTagsWrapper.isVisible = false
} }
// Handle showing more or less info // Handle showing more or less info
@ -308,10 +305,10 @@ class MangaInfoHeaderAdapter(
} }
private fun showMangaInfo(visible: Boolean) { private fun showMangaInfo(visible: Boolean) {
binding.mangaSummaryLabel.visibleIf { visible } binding.mangaSummaryLabel.isVisible = visible
binding.mangaSummary.visibleIf { visible } binding.mangaSummary.isVisible = visible
binding.mangaGenresTagsWrapper.visibleIf { visible } binding.mangaGenresTagsWrapper.isVisible = visible
binding.mangaInfoToggle.visibleIf { visible } binding.mangaInfoToggle.isVisible = visible
} }
private fun toggleMangaInfo(context: Context) { private fun toggleMangaInfo(context: Context) {
@ -348,8 +345,8 @@ class MangaInfoHeaderAdapter(
} }
} }
binding.mangaGenresTagsCompact.visibleIf { isExpanded } binding.mangaGenresTagsCompact.isVisible = isExpanded
binding.mangaGenresTagsFullChips.visibleIf { !isExpanded } binding.mangaGenresTagsFullChips.isVisible = !isExpanded
} }
/** /**

View File

@ -1,11 +1,10 @@
package eu.kanade.tachiyomi.ui.manga.track package eu.kanade.tachiyomi.ui.manga.track
import android.annotation.SuppressLint import android.annotation.SuppressLint
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.TrackItemBinding import eu.kanade.tachiyomi.databinding.TrackItemBinding
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visibleIf
import java.text.DateFormat import java.text.DateFormat
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -40,10 +39,10 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
binding.trackLogo.setImageResource(item.service.getLogo()) binding.trackLogo.setImageResource(item.service.getLogo())
binding.logoContainer.setBackgroundColor(item.service.getLogoColor()) binding.logoContainer.setBackgroundColor(item.service.getLogoColor())
binding.trackSet.visibleIf { track == null } binding.trackSet.isVisible = track == null
binding.trackTitle.visibleIf { track != null } binding.trackTitle.isVisible = track != null
binding.trackDetails.visibleIf { track != null } binding.trackDetails.isVisible = track != null
if (track != null) { if (track != null) {
binding.trackTitle.text = track.title binding.trackTitle.text = track.title
binding.trackChapters.text = "${track.last_chapter_read}/" + binding.trackChapters.text = "${track.last_chapter_read}/" +
@ -57,10 +56,10 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
binding.trackFinishDate.text = binding.trackFinishDate.text =
if (track.finished_reading_date != 0L) dateFormat.format(track.finished_reading_date) else "-" if (track.finished_reading_date != 0L) dateFormat.format(track.finished_reading_date) else "-"
} else { } else {
binding.bottomDivider.gone() binding.bottomDivider.isVisible = false
binding.vertDivider3.gone() binding.vertDivider3.isVisible = false
binding.trackStartDate.gone() binding.trackStartDate.isVisible = false
binding.trackFinishDate.gone() binding.trackFinishDate.isVisible = false
} }
} }
} }

View File

@ -4,11 +4,11 @@ import android.content.Context
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.inflate import eu.kanade.tachiyomi.util.view.inflate
import kotlinx.android.synthetic.main.track_search_item.view.track_search_cover import kotlinx.android.synthetic.main.track_search_item.view.track_search_cover
import kotlinx.android.synthetic.main.track_search_item.view.track_search_start import kotlinx.android.synthetic.main.track_search_item.view.track_search_start
@ -62,22 +62,22 @@ class TrackSearchAdapter(context: Context) :
} }
if (track.publishing_status.isBlank()) { if (track.publishing_status.isBlank()) {
view.track_search_status.gone() view.track_search_status.isVisible = false
view.track_search_status_result.gone() view.track_search_status_result.isVisible = false
} else { } else {
view.track_search_status_result.text = track.publishing_status.capitalize() view.track_search_status_result.text = track.publishing_status.capitalize()
} }
if (track.publishing_type.isBlank()) { if (track.publishing_type.isBlank()) {
view.track_search_type.gone() view.track_search_type.isVisible = false
view.track_search_type_result.gone() view.track_search_type_result.isVisible = false
} else { } else {
view.track_search_type_result.text = track.publishing_type.capitalize() view.track_search_type_result.text = track.publishing_type.capitalize()
} }
if (track.start_date.isBlank()) { if (track.start_date.isBlank()) {
view.track_search_start.gone() view.track_search_start.isVisible = false
view.track_search_start_result.gone() view.track_search_start_result.isVisible = false
} else { } else {
view.track_search_start_result.text = track.start_date view.track_search_start_result.text = track.start_date
} }

View File

@ -3,6 +3,8 @@ package eu.kanade.tachiyomi.ui.manga.track
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.customView
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@ -11,8 +13,6 @@ import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.TrackService
import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.visible
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.track_search_dialog.view.progress import kotlinx.android.synthetic.main.track_search_dialog.view.progress
import kotlinx.android.synthetic.main.track_search_dialog.view.track_search import kotlinx.android.synthetic.main.track_search_dialog.view.track_search
@ -108,23 +108,23 @@ class TrackSearchDialog : DialogController {
private fun search(query: String) { private fun search(query: String) {
val view = dialogView ?: return val view = dialogView ?: return
view.progress.visible() view.progress.isVisible = true
view.track_search_list.invisible() view.track_search_list.isInvisible = true
trackController.presenter.search(query, service) trackController.presenter.search(query, service)
} }
fun onSearchResults(results: List<TrackSearch>) { fun onSearchResults(results: List<TrackSearch>) {
selectedItem = null selectedItem = null
val view = dialogView ?: return val view = dialogView ?: return
view.progress.invisible() view.progress.isInvisible = true
view.track_search_list.visible() view.track_search_list.isVisible = true
adapter?.setItems(results) adapter?.setItems(results)
} }
fun onSearchResultsError() { fun onSearchResultsError() {
val view = dialogView ?: return val view = dialogView ?: return
view.progress.visible() view.progress.isVisible = true
view.track_search_list.invisible() view.track_search_list.isInvisible = true
adapter?.setItems(emptyList()) adapter?.setItems(emptyList())
} }

View File

@ -21,6 +21,7 @@ import android.view.animation.Animation
import android.view.animation.AnimationUtils import android.view.animation.AnimationUtils
import android.widget.SeekBar import android.widget.SeekBar
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@ -47,12 +48,10 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.system.GLUtil import eu.kanade.tachiyomi.util.system.GLUtil
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.defaultBar import eu.kanade.tachiyomi.util.view.defaultBar
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.hideBar import eu.kanade.tachiyomi.util.view.hideBar
import eu.kanade.tachiyomi.util.view.isDefaultBar import eu.kanade.tachiyomi.util.view.isDefaultBar
import eu.kanade.tachiyomi.util.view.showBar import eu.kanade.tachiyomi.util.view.showBar
import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.snack
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
import java.io.File import java.io.File
@ -339,7 +338,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
} else { } else {
resetDefaultMenuAndBar() resetDefaultMenuAndBar()
} }
binding.readerMenu.visible() binding.readerMenu.isVisible = true
if (animate) { if (animate) {
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top)
@ -369,7 +368,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top) val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top)
toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationEnd(animation: Animation) { override fun onAnimationEnd(animation: Animation) {
binding.readerMenu.gone() binding.readerMenu.isVisible = false
} }
}) })
binding.toolbar.startAnimation(toolbarAnimation) binding.toolbar.startAnimation(toolbarAnimation)
@ -422,7 +421,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
binding.pageSeekbar.isRTL = newViewer is R2LPagerViewer binding.pageSeekbar.isRTL = newViewer is R2LPagerViewer
binding.pleaseWait.visible() binding.pleaseWait.isVisible = true
binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long)) binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long))
} }
@ -436,7 +435,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
* method to the current viewer, but also set the subtitle on the toolbar. * method to the current viewer, but also set the subtitle on the toolbar.
*/ */
fun setChapters(viewerChapters: ViewerChapters) { fun setChapters(viewerChapters: ViewerChapters) {
binding.pleaseWait.gone() binding.pleaseWait.isVisible = false
viewer?.setChapters(viewerChapters) viewer?.setChapters(viewerChapters)
binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name
@ -764,7 +763,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
.onEach { setColorFilterValue(it) } .onEach { setColorFilterValue(it) }
.launchIn(scope) .launchIn(scope)
} else { } else {
binding.colorOverlay.gone() binding.colorOverlay.isVisible = false
} }
} }
@ -790,11 +789,11 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
// Set black overlay visibility. // Set black overlay visibility.
if (value < 0) { if (value < 0) {
binding.brightnessOverlay.visible() binding.brightnessOverlay.isVisible = true
val alpha = (abs(value) * 2.56).toInt() val alpha = (abs(value) * 2.56).toInt()
binding.brightnessOverlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0)) binding.brightnessOverlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0))
} else { } else {
binding.brightnessOverlay.gone() binding.brightnessOverlay.isVisible = false
} }
} }
@ -802,7 +801,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
* Sets the color filter [value]. * Sets the color filter [value].
*/ */
private fun setColorFilterValue(value: Int) { private fun setColorFilterValue(value: Int) {
binding.colorOverlay.visible() binding.colorOverlay.isVisible = true
binding.colorOverlay.setFilterColor(value, preferences.colorFilterMode().get()) binding.colorOverlay.setFilterColor(value, preferences.colorFilterMode().get())
} }
} }

View File

@ -4,6 +4,8 @@ import android.os.Bundle
import android.widget.CompoundButton import android.widget.CompoundButton
import android.widget.Spinner import android.widget.Spinner
import androidx.annotation.ArrayRes import androidx.annotation.ArrayRes
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.core.widget.NestedScrollView import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.tfcporciuncula.flow.Preference import com.tfcporciuncula.flow.Preference
@ -12,9 +14,6 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.ReaderSettingsSheetBinding import eu.kanade.tachiyomi.databinding.ReaderSettingsSheetBinding
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -80,8 +79,8 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
* Init the preferences for the pager reader. * Init the preferences for the pager reader.
*/ */
private fun initPagerPreferences() { private fun initPagerPreferences() {
binding.webtoonPrefsGroup.invisible() binding.webtoonPrefsGroup.isInvisible = true
binding.pagerPrefsGroup.visible() binding.pagerPrefsGroup.isVisible = true
binding.scaleType.bindToPreference(preferences.imageScaleType(), 1) binding.scaleType.bindToPreference(preferences.imageScaleType(), 1)
binding.zoomStart.bindToPreference(preferences.zoomStart(), 1) binding.zoomStart.bindToPreference(preferences.zoomStart(), 1)
@ -91,8 +90,8 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
* Init the preferences for the webtoon reader. * Init the preferences for the webtoon reader.
*/ */
private fun initWebtoonPreferences() { private fun initWebtoonPreferences() {
binding.pagerPrefsGroup.invisible() binding.pagerPrefsGroup.isInvisible = true
binding.webtoonPrefsGroup.visible() binding.webtoonPrefsGroup.isVisible = true
binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values) binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
} }
@ -102,7 +101,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
*/ */
private fun initNavigationPreferences() { private fun initNavigationPreferences() {
if (!preferences.readWithTapping().get()) { if (!preferences.readWithTapping().get()) {
binding.navigationPrefsGroup.gone() binding.navigationPrefsGroup.isVisible = false
} }
binding.tappingInverted.bindToPreference(preferences.readWithTappingInverted()) binding.tappingInverted.bindToPreference(preferences.readWithTappingInverted())

View File

@ -14,9 +14,10 @@ import android.view.animation.Animation
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import android.view.animation.RotateAnimation import android.view.animation.RotateAnimation
import androidx.core.view.isGone
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.gone
import kotlin.math.min import kotlin.math.min
/** /**
@ -154,17 +155,17 @@ class ReaderProgressBar @JvmOverloads constructor(
* Hides this progress bar with an optional fade out if [animate] is true. * Hides this progress bar with an optional fade out if [animate] is true.
*/ */
fun hide(animate: Boolean = false) { fun hide(animate: Boolean = false) {
if (visibility == GONE) return if (isGone) return
if (!animate) { if (!animate) {
gone() isVisible = false
} else { } else {
ObjectAnimator.ofFloat(this, "alpha", 1f, 0f).apply { ObjectAnimator.ofFloat(this, "alpha", 1f, 0f).apply {
interpolator = DecelerateInterpolator() interpolator = DecelerateInterpolator()
duration = 1000 duration = 1000
addListener(object : AnimatorListenerAdapter() { addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) { override fun onAnimationEnd(animation: Animator?) {
gone() isVisible = false
alpha = 1f alpha = 1f
} }

View File

@ -13,6 +13,7 @@ import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.view.isVisible
import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.engine.GlideException
@ -33,8 +34,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.ZoomType
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.ViewPagerAdapter import eu.kanade.tachiyomi.widget.ViewPagerAdapter
import java.io.InputStream import java.io.InputStream
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -196,37 +195,37 @@ class PagerPageHolder(
* Called when the page is queued. * Called when the page is queued.
*/ */
private fun setQueued() { private fun setQueued() {
progressBar.visible() progressBar.isVisible = true
retryButton?.gone() retryButton?.isVisible = false
decodeErrorLayout?.gone() decodeErrorLayout?.isVisible = false
} }
/** /**
* Called when the page is loading. * Called when the page is loading.
*/ */
private fun setLoading() { private fun setLoading() {
progressBar.visible() progressBar.isVisible = true
retryButton?.gone() retryButton?.isVisible = false
decodeErrorLayout?.gone() decodeErrorLayout?.isVisible = false
} }
/** /**
* Called when the page is downloading. * Called when the page is downloading.
*/ */
private fun setDownloading() { private fun setDownloading() {
progressBar.visible() progressBar.isVisible = true
retryButton?.gone() retryButton?.isVisible = false
decodeErrorLayout?.gone() decodeErrorLayout?.isVisible = false
} }
/** /**
* Called when the page is ready. * Called when the page is ready.
*/ */
private fun setImage() { private fun setImage() {
progressBar.visible() progressBar.isVisible = true
progressBar.completeAndFadeOut() progressBar.completeAndFadeOut()
retryButton?.gone() retryButton?.isVisible = false
decodeErrorLayout?.gone() decodeErrorLayout?.isVisible = false
unsubscribeReadImageHeader() unsubscribeReadImageHeader()
val streamFn = page.stream ?: return val streamFn = page.stream ?: return
@ -258,23 +257,23 @@ class PagerPageHolder(
* Called when the page has an error. * Called when the page has an error.
*/ */
private fun setError() { private fun setError() {
progressBar.gone() progressBar.isVisible = false
initRetryButton().visible() initRetryButton().isVisible = true
} }
/** /**
* Called when the image is decoded and going to be displayed. * Called when the image is decoded and going to be displayed.
*/ */
private fun onImageDecoded() { private fun onImageDecoded() {
progressBar.gone() progressBar.isVisible = false
} }
/** /**
* Called when an image fails to decode. * Called when an image fails to decode.
*/ */
private fun onImageDecodeError() { private fun onImageDecodeError() {
progressBar.gone() progressBar.isVisible = false
initDecodeErrorLayout().visible() initDecodeErrorLayout().isVisible = true
} }
/** /**

View File

@ -5,6 +5,8 @@ import android.view.KeyEvent
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewGroup.LayoutParams import android.view.ViewGroup.LayoutParams
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
@ -13,8 +15,6 @@ import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import timber.log.Timber import timber.log.Timber
/** /**
@ -66,7 +66,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
} }
init { init {
pager.gone() // Don't layout the pager yet pager.isVisible = false // Don't layout the pager yet
pager.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) pager.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
pager.offscreenPageLimit = 1 pager.offscreenPageLimit = 1
pager.id = R.id.reader_pager pager.id = R.id.reader_pager
@ -225,11 +225,11 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
adapter.setChapters(chapters, forceTransition) adapter.setChapters(chapters, forceTransition)
// Layout the pager once a chapter is being set // Layout the pager once a chapter is being set
if (pager.visibility == View.GONE) { if (pager.isGone) {
Timber.d("Pager first layout") Timber.d("Pager first layout")
val pages = chapters.currChapter.pages ?: return val pages = chapters.currChapter.pages ?: return
moveToPage(pages[chapters.currChapter.requestedPage]) moveToPage(pages[chapters.currChapter.requestedPage])
pager.visible() pager.isVisible = true
} }
} }

View File

@ -13,6 +13,7 @@ import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import androidx.core.view.isVisible
import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.engine.GlideException
@ -31,8 +32,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import java.io.InputStream import java.io.InputStream
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import rx.Observable import rx.Observable
@ -145,9 +144,9 @@ class WebtoonPageHolder(
removeDecodeErrorLayout() removeDecodeErrorLayout()
subsamplingImageView?.recycle() subsamplingImageView?.recycle()
subsamplingImageView?.gone() subsamplingImageView?.isVisible = false
imageView?.let { GlideApp.with(frame).clear(it) } imageView?.let { GlideApp.with(frame).clear(it) }
imageView?.gone() imageView?.isVisible = false
progressBar.setProgress(0) progressBar.setProgress(0)
} }
@ -238,9 +237,9 @@ class WebtoonPageHolder(
* Called when the page is queued. * Called when the page is queued.
*/ */
private fun setQueued() { private fun setQueued() {
progressContainer.visible() progressContainer.isVisible = true
progressBar.visible() progressBar.isVisible = true
retryContainer?.gone() retryContainer?.isVisible = false
removeDecodeErrorLayout() removeDecodeErrorLayout()
} }
@ -248,9 +247,9 @@ class WebtoonPageHolder(
* Called when the page is loading. * Called when the page is loading.
*/ */
private fun setLoading() { private fun setLoading() {
progressContainer.visible() progressContainer.isVisible = true
progressBar.visible() progressBar.isVisible = true
retryContainer?.gone() retryContainer?.isVisible = false
removeDecodeErrorLayout() removeDecodeErrorLayout()
} }
@ -258,9 +257,9 @@ class WebtoonPageHolder(
* Called when the page is downloading * Called when the page is downloading
*/ */
private fun setDownloading() { private fun setDownloading() {
progressContainer.visible() progressContainer.isVisible = true
progressBar.visible() progressBar.isVisible = true
retryContainer?.gone() retryContainer?.isVisible = false
removeDecodeErrorLayout() removeDecodeErrorLayout()
} }
@ -268,10 +267,10 @@ class WebtoonPageHolder(
* Called when the page is ready. * Called when the page is ready.
*/ */
private fun setImage() { private fun setImage() {
progressContainer.visible() progressContainer.isVisible = true
progressBar.visible() progressBar.isVisible = true
progressBar.completeAndFadeOut() progressBar.completeAndFadeOut()
retryContainer?.gone() retryContainer?.isVisible = false
removeDecodeErrorLayout() removeDecodeErrorLayout()
unsubscribeReadImageHeader() unsubscribeReadImageHeader()
@ -290,11 +289,11 @@ class WebtoonPageHolder(
.doOnNext { isAnimated -> .doOnNext { isAnimated ->
if (!isAnimated) { if (!isAnimated) {
val subsamplingView = initSubsamplingImageView() val subsamplingView = initSubsamplingImageView()
subsamplingView.visible() subsamplingView.isVisible = true
subsamplingView.setImage(ImageSource.inputStream(openStream!!)) subsamplingView.setImage(ImageSource.inputStream(openStream!!))
} else { } else {
val imageView = initImageView() val imageView = initImageView()
imageView.visible() imageView.isVisible = true
imageView.setImage(openStream!!) imageView.setImage(openStream!!)
} }
} }
@ -310,23 +309,23 @@ class WebtoonPageHolder(
* Called when the page has an error. * Called when the page has an error.
*/ */
private fun setError() { private fun setError() {
progressContainer.gone() progressContainer.isVisible = false
initRetryLayout().visible() initRetryLayout().isVisible = true
} }
/** /**
* Called when the image is decoded and going to be displayed. * Called when the image is decoded and going to be displayed.
*/ */
private fun onImageDecoded() { private fun onImageDecoded() {
progressContainer.gone() progressContainer.isVisible = false
} }
/** /**
* Called when the image fails to decode. * Called when the image fails to decode.
*/ */
private fun onImageDecodeError() { private fun onImageDecodeError() {
progressContainer.gone() progressContainer.isVisible = false
initDecodeErrorLayout().visible() initDecodeErrorLayout().isVisible = true
} }
/** /**

View File

@ -12,11 +12,11 @@ import android.widget.ProgressBar
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatTextView import androidx.appcompat.widget.AppCompatTextView
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.view.visibleIf
import rx.Subscription import rx.Subscription
import rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
@ -153,7 +153,7 @@ class WebtoonTransitionHolder(
is ReaderChapter.State.Error -> setError(state.error, transition) is ReaderChapter.State.Error -> setError(state.error, transition)
is ReaderChapter.State.Loaded -> setLoaded() is ReaderChapter.State.Loaded -> setLoaded()
} }
pagesContainer.visibleIf { pagesContainer.childCount > 0 } pagesContainer.isVisible = pagesContainer.childCount > 0
} }
addSubscription(statusSubscription) addSubscription(statusSubscription)

View File

@ -5,6 +5,8 @@ import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.WebtoonLayoutManager import androidx.recyclerview.widget.WebtoonLayoutManager
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
@ -13,8 +15,6 @@ import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlin.math.max import kotlin.math.max
import kotlin.math.min import kotlin.math.min
import rx.subscriptions.CompositeSubscription import rx.subscriptions.CompositeSubscription
@ -66,7 +66,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
val subscriptions = CompositeSubscription() val subscriptions = CompositeSubscription()
init { init {
recycler.gone() // Don't let the recycler layout yet recycler.isVisible = false // Don't let the recycler layout yet
recycler.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT) recycler.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
recycler.itemAnimator = null recycler.itemAnimator = null
recycler.layoutManager = layoutManager recycler.layoutManager = layoutManager
@ -211,11 +211,11 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
val forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition val forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition
adapter.setChapters(chapters, forceTransition) adapter.setChapters(chapters, forceTransition)
if (recycler.visibility == View.GONE) { if (recycler.isGone) {
Timber.d("Recycler first layout") Timber.d("Recycler first layout")
val pages = chapters.currChapter.pages ?: return val pages = chapters.currChapter.pages ?: return
moveToPage(pages[chapters.currChapter.requestedPage]) moveToPage(pages[chapters.currChapter.requestedPage])
recycler.visible() recycler.isVisible = true
} }
} }

View File

@ -12,6 +12,8 @@ import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest import android.webkit.WebResourceRequest
import android.webkit.WebView import android.webkit.WebView
import androidx.core.graphics.ColorUtils import androidx.core.graphics.ColorUtils
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.webkit.WebViewClientCompat import androidx.webkit.WebViewClientCompat
import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@ -24,8 +26,6 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.setDefaultSettings import eu.kanade.tachiyomi.util.system.setDefaultSettings
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import reactivecircus.flowbinding.appcompat.navigationClicks import reactivecircus.flowbinding.appcompat.navigationClicks
@ -83,10 +83,10 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
binding.webview.webChromeClient = object : WebChromeClient() { binding.webview.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView?, newProgress: Int) { override fun onProgressChanged(view: WebView?, newProgress: Int) {
binding.progressBar.visible() binding.progressBar.isVisible = true
binding.progressBar.progress = newProgress binding.progressBar.progress = newProgress
if (newProgress == 100) { if (newProgress == 100) {
binding.progressBar.invisible() binding.progressBar.isInvisible = true
} }
super.onProgressChanged(view, newProgress) super.onProgressChanged(view, newProgress)
} }

View File

@ -68,26 +68,6 @@ fun View.popupMenu(@MenuRes menuRes: Int, initMenu: (Menu.() -> Unit)? = null, o
popup.show() popup.show()
} }
inline fun View.visible() {
visibility = View.VISIBLE
}
inline fun View.invisible() {
visibility = View.INVISIBLE
}
inline fun View.gone() {
visibility = View.GONE
}
inline fun View.visibleIf(block: () -> Boolean) {
visibility = if (block()) View.VISIBLE else View.GONE
}
inline fun View.toggle() {
visibleIf { visibility == View.GONE }
}
/** /**
* Shrink an ExtendedFloatingActionButton when the associated RecyclerView is scrolled down. * Shrink an ExtendedFloatingActionButton when the associated RecyclerView is scrolled down.
* *

View File

@ -9,9 +9,8 @@ import android.widget.FrameLayout
import androidx.annotation.IdRes import androidx.annotation.IdRes
import androidx.annotation.MenuRes import androidx.annotation.MenuRes
import androidx.appcompat.view.ActionMode import androidx.appcompat.view.ActionMode
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.common_action_toolbar.view.common_action_menu import kotlinx.android.synthetic.main.common_action_toolbar.view.common_action_menu
import kotlinx.android.synthetic.main.common_action_toolbar.view.common_action_toolbar import kotlinx.android.synthetic.main.common_action_toolbar.view.common_action_toolbar
@ -50,7 +49,7 @@ class ActionToolbar @JvmOverloads constructor(context: Context, attrs: Attribute
common_action_menu.setOnMenuItemClickListener { listener(it) } common_action_menu.setOnMenuItemClickListener { listener(it) }
} }
common_action_toolbar.visible() common_action_toolbar.isVisible = true
val bottomAnimation = AnimationUtils.loadAnimation(context, R.anim.enter_from_bottom) val bottomAnimation = AnimationUtils.loadAnimation(context, R.anim.enter_from_bottom)
common_action_toolbar.startAnimation(bottomAnimation) common_action_toolbar.startAnimation(bottomAnimation)
} }
@ -62,7 +61,7 @@ class ActionToolbar @JvmOverloads constructor(context: Context, attrs: Attribute
val bottomAnimation = AnimationUtils.loadAnimation(context, R.anim.exit_to_bottom) val bottomAnimation = AnimationUtils.loadAnimation(context, R.anim.exit_to_bottom)
bottomAnimation.setAnimationListener(object : SimpleAnimationListener() { bottomAnimation.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationEnd(animation: Animation) { override fun onAnimationEnd(animation: Animation) {
common_action_toolbar.gone() common_action_toolbar.isVisible = false
} }
}) })
common_action_toolbar.startAnimation(bottomAnimation) common_action_toolbar.startAnimation(bottomAnimation)

View File

@ -6,9 +6,8 @@ import android.widget.LinearLayout
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatButton
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlin.random.Random import kotlin.random.Random
import kotlinx.android.synthetic.main.common_view_empty.view.actions_container import kotlinx.android.synthetic.main.common_view_empty.view.actions_container
import kotlinx.android.synthetic.main.common_view_empty.view.text_face import kotlinx.android.synthetic.main.common_view_empty.view.text_face
@ -25,7 +24,7 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
* Hide the information view * Hide the information view
*/ */
fun hide() { fun hide() {
this.gone() this.isVisible = false
} }
/** /**
@ -57,7 +56,7 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
} }
} }
this.visible() this.isVisible = true
} }
companion object { companion object {

View File

@ -6,8 +6,8 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewAnimationUtils import android.view.ViewAnimationUtils
import eu.kanade.tachiyomi.util.view.invisible import androidx.core.view.isInvisible
import eu.kanade.tachiyomi.util.view.visible import androidx.core.view.isVisible
class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
View(context, attrs) { View(context, attrs) {
@ -21,7 +21,7 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
*/ */
fun hideRevealEffect(centerX: Int, centerY: Int, initialRadius: Int) { fun hideRevealEffect(centerX: Int, centerY: Int, initialRadius: Int) {
// Make the view visible. // Make the view visible.
this.visible() this.isVisible = true
// Create the animation (the final radius is zero). // Create the animation (the final radius is zero).
val anim = ViewAnimationUtils.createCircularReveal( val anim = ViewAnimationUtils.createCircularReveal(
@ -35,7 +35,7 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
anim.addListener(object : AnimatorListenerAdapter() { anim.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) { override fun onAnimationEnd(animation: Animator) {
super.onAnimationEnd(animation) super.onAnimationEnd(animation)
this@RevealAnimationView.invisible() this@RevealAnimationView.isInvisible = true
} }
}) })
@ -52,7 +52,7 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
* @return sdk version lower then 21 * @return sdk version lower then 21
*/ */
fun showRevealEffect(centerX: Int, centerY: Int, listener: Animator.AnimatorListener): Boolean { fun showRevealEffect(centerX: Int, centerY: Int, listener: Animator.AnimatorListener): Boolean {
this.visible() this.isVisible = true
val height = this.height val height = this.height

View File

@ -4,13 +4,12 @@ import android.graphics.drawable.Drawable
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.ImageView.ScaleType import android.widget.ImageView.ScaleType
import androidx.core.view.isVisible
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.bumptech.glide.request.target.ImageViewTarget import com.bumptech.glide.request.target.ImageViewTarget
import com.bumptech.glide.request.transition.Transition import com.bumptech.glide.request.transition.Transition
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
/** /**
* A glide target to display an image with an optional view to show while loading and a configurable * A glide target to display an image with an optional view to show while loading and a configurable
@ -37,12 +36,12 @@ class StateImageViewTarget(
} }
override fun onLoadStarted(placeholder: Drawable?) { override fun onLoadStarted(placeholder: Drawable?) {
progress?.visible() progress?.isVisible = true
super.onLoadStarted(placeholder) super.onLoadStarted(placeholder)
} }
override fun onLoadFailed(errorDrawable: Drawable?) { override fun onLoadFailed(errorDrawable: Drawable?) {
progress?.gone() progress?.isVisible = false
view.scaleType = errorScaleType view.scaleType = errorScaleType
val vector = VectorDrawableCompat.create(view.context.resources, errorDrawableRes, null) val vector = VectorDrawableCompat.create(view.context.resources, errorDrawableRes, null)
@ -51,12 +50,12 @@ class StateImageViewTarget(
} }
override fun onLoadCleared(placeholder: Drawable?) { override fun onLoadCleared(placeholder: Drawable?) {
progress?.gone() progress?.isVisible = false
super.onLoadCleared(placeholder) super.onLoadCleared(placeholder)
} }
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) { override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
progress?.gone() progress?.isVisible = false
view.scaleType = imageScaleType view.scaleType = imageScaleType
super.onResourceReady(resource, transition) super.onResourceReady(resource, transition)
this.resource = resource this.resource = resource