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.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.ExtensionDetailHeaderBinding
import eu.kanade.tachiyomi.ui.browse.extension.getApplicationIcon
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -49,12 +49,12 @@ class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPrese
.launchIn(scope)
if (extension.isObsolete) {
binding.extensionWarningBanner.visible()
binding.extensionWarningBanner.isVisible = true
binding.extensionWarningBanner.setText(R.string.obsolete_extension_message)
}
if (extension.isUnofficial) {
binding.extensionWarningBanner.visible()
binding.extensionWarningBanner.isVisible = true
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.os.Bundle
import androidx.core.view.isVisible
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice
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.source.globalsearch.GlobalSearchController
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
class SearchController(
@ -69,9 +68,9 @@ class SearchController(
fun renderIsReplacingManga(isReplacingManga: Boolean) {
if (isReplacingManga) {
binding.progress.visible()
binding.progress.isVisible = true
} else {
binding.progress.gone()
binding.progress.isVisible = false
router.popController(this)
}
}

View File

@ -1,10 +1,10 @@
package eu.kanade.tachiyomi.ui.browse.migration.sources
import android.view.View
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.source.icon
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.base.holder.SlicedHolder
import eu.kanade.tachiyomi.util.view.gone
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.image
@ -24,8 +24,8 @@ class SourceHolder(view: View, override val adapter: SourceAdapter) :
get() = card
init {
source_latest.gone()
source_browse.gone()
source_latest.isVisible = false
source_browse.isVisible = false
}
fun bind(item: SourceItem) {

View File

@ -1,13 +1,12 @@
package eu.kanade.tachiyomi.ui.browse.source
import android.view.View
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.icon
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
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 kotlinx.android.synthetic.main.source_main_controller_card_item.card
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)
if (source.supportsLatest) {
source_latest.visible()
} else {
source_latest.gone()
}
source_latest.isVisible = source.supportsLatest
}
}

View File

@ -9,6 +9,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView
import androidx.core.view.isVisible
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager
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.openInBrowser
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.shrinkOnScroll
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.EmptyView
import kotlinx.coroutines.Job
@ -141,7 +140,7 @@ open class BrowseSourceController(bundle: Bundle) :
adapter = FlexibleAdapter(null, this)
setupRecycler(view)
binding.progress.visible()
binding.progress.isVisible = true
}
open fun initFilterSheet() {
@ -167,19 +166,19 @@ open class BrowseSourceController(bundle: Bundle) :
filterSheet?.setFilters(presenter.filterItems)
// TODO: [ExtendedFloatingActionButton] hide/show methods don't work properly
filterSheet?.setOnShowListener { actionFab?.gone() }
filterSheet?.setOnDismissListener { actionFab?.visible() }
filterSheet?.setOnShowListener { actionFab?.isVisible = false }
filterSheet?.setOnDismissListener { actionFab?.isVisible = true }
actionFab?.setOnClickListener { filterSheet?.show() }
actionFab?.visible()
actionFab?.isVisible = true
}
override fun configureFab(fab: ExtendedFloatingActionButton) {
actionFab = fab
// Controlled by initFilterSheet()
fab.gone()
fab.isVisible = false
fab.setText(R.string.action_filter)
fab.setIconResource(R.drawable.ic_filter_list_24dp)
@ -515,7 +514,7 @@ open class BrowseSourceController(bundle: Bundle) :
*/
private fun showProgressBar() {
binding.emptyView.hide()
binding.progress.visible()
binding.progress.isVisible = true
snack?.dismiss()
snack = null
}
@ -525,7 +524,7 @@ open class BrowseSourceController(bundle: Bundle) :
*/
private fun hideProgressBar() {
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.widget.ProgressBar
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
import eu.davidea.flexibleadapter.items.IFlexible
import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
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?>) {
holder.progressBar.gone()
holder.progressMessage.gone()
holder.progressBar.isVisible = false
holder.progressMessage.isVisible = false
if (!adapter.isEndlessScrollEnabled) {
loadMore = false
}
if (loadMore) {
holder.progressBar.visible()
holder.progressBar.isVisible = true
} else {
holder.progressMessage.visible()
holder.progressMessage.isVisible = true
}
}

View File

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

View File

@ -6,6 +6,7 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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.ui.base.controller.FabController
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.visible
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@ -284,11 +283,11 @@ class DownloadController :
private fun setInformationView() {
if (presenter.downloadQueue.isEmpty()) {
binding.emptyView.show(R.string.information_no_downloads)
actionFab?.gone()
actionFab?.isVisible = false
} else {
binding.emptyView.hide()
actionFab?.apply {
visible()
isVisible = true
setText(
if (isRunning) {

View File

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

View File

@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.ui.library
import android.view.View
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
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.card
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.
with(unread_text) {
visibleIf { item.unreadCount > 0 }
isVisible = item.unreadCount > 0
text = item.unreadCount.toString()
}
// Update the download count and its visibility.
with(download_text) {
visibleIf { item.downloadCount > 0 }
isVisible = item.downloadCount > 0
text = item.downloadCount.toString()
}
// set local visibility if its local manga
local_text.visibleIf { item.manga.isLocal() }
local_text.isVisible = item.manga.isLocal()
// For rounded corners
card.clipToOutline = true

View File

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

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.library
import android.view.View
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
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.toMangaThumbnail
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.download_text
import kotlinx.android.synthetic.main.source_list_item.local_text
@ -48,16 +48,16 @@ class LibraryListHolder(
// Update the unread count and its visibility.
with(unread_text) {
visibleIf { item.unreadCount > 0 }
isVisible = item.unreadCount > 0
text = item.unreadCount.toString()
}
// Update the download count and its visibility.
with(download_text) {
visibleIf { item.downloadCount > 0 }
isVisible = item.downloadCount > 0
text = "${item.downloadCount}"
}
// 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
thumbnail.setOnClickListener {

View File

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.isVisible
import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Controller
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.launchUI
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.visible
import java.util.Date
import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.main_activity.appbar
@ -349,11 +348,11 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
}
if (from is FabController) {
binding.rootFab.gone()
binding.rootFab.isVisible = false
from.cleanupFab(binding.rootFab)
}
if (to is FabController) {
binding.rootFab.visible()
binding.rootFab.isVisible = true
to.configureFab(binding.rootFab)
}

View File

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

View File

@ -4,11 +4,11 @@ import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.view.View
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.view.visibleIf
import java.util.Date
import kotlinx.android.synthetic.main.chapters_item.bookmark_icon
import kotlinx.android.synthetic.main.chapters_item.chapter_description
@ -40,7 +40,7 @@ class ChapterHolder(
chapter_title.setTextColor(chapterColor)
chapter_description.setTextColor(chapterColor)
bookmark_icon.visibleIf { chapter.bookmark }
bookmark_icon.isVisible = chapter.bookmark
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.ui.manga.MangaController
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.setTooltip
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
@ -105,7 +102,7 @@ class MangaInfoHeaderAdapter(
with(binding.btnTracking) {
if (trackManager.hasLoggedServices()) {
visible()
isVisible = true
if (trackCount > 0) {
setIconResource(R.drawable.ic_done_24dp)
@ -121,18 +118,18 @@ class MangaInfoHeaderAdapter(
.onEach { controller.onTrackingClick() }
.launchIn(scope)
} else {
gone()
isVisible = false
}
}
if (controller.presenter.source is HttpSource) {
binding.btnWebview.visible()
binding.btnWebview.isVisible = true
binding.btnWebview.clicks()
.onEach { controller.openMangaInWebView() }
.launchIn(scope)
binding.btnWebview.setTooltip(R.string.action_open_in_web_view)
binding.btnShare.visible()
binding.btnShare.isVisible = true
binding.btnShare.clicks()
.onEach { controller.shareManga() }
.launchIn(scope)
@ -291,7 +288,7 @@ class MangaInfoHeaderAdapter(
binding.mangaGenresTagsCompactChips.setChips(manga.getGenres(), controller::performSearch)
binding.mangaGenresTagsFullChips.setChips(manga.getGenres(), controller::performSearch)
} else {
binding.mangaGenresTagsWrapper.gone()
binding.mangaGenresTagsWrapper.isVisible = false
}
// Handle showing more or less info
@ -308,10 +305,10 @@ class MangaInfoHeaderAdapter(
}
private fun showMangaInfo(visible: Boolean) {
binding.mangaSummaryLabel.visibleIf { visible }
binding.mangaSummary.visibleIf { visible }
binding.mangaGenresTagsWrapper.visibleIf { visible }
binding.mangaInfoToggle.visibleIf { visible }
binding.mangaSummaryLabel.isVisible = visible
binding.mangaSummary.isVisible = visible
binding.mangaGenresTagsWrapper.isVisible = visible
binding.mangaInfoToggle.isVisible = visible
}
private fun toggleMangaInfo(context: Context) {
@ -348,8 +345,8 @@ class MangaInfoHeaderAdapter(
}
}
binding.mangaGenresTagsCompact.visibleIf { isExpanded }
binding.mangaGenresTagsFullChips.visibleIf { !isExpanded }
binding.mangaGenresTagsCompact.isVisible = isExpanded
binding.mangaGenresTagsFullChips.isVisible = !isExpanded
}
/**

View File

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

View File

@ -4,11 +4,11 @@ import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.util.view.gone
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_start
@ -62,22 +62,22 @@ class TrackSearchAdapter(context: Context) :
}
if (track.publishing_status.isBlank()) {
view.track_search_status.gone()
view.track_search_status_result.gone()
view.track_search_status.isVisible = false
view.track_search_status_result.isVisible = false
} else {
view.track_search_status_result.text = track.publishing_status.capitalize()
}
if (track.publishing_type.isBlank()) {
view.track_search_type.gone()
view.track_search_type_result.gone()
view.track_search_type.isVisible = false
view.track_search_type_result.isVisible = false
} else {
view.track_search_type_result.text = track.publishing_type.capitalize()
}
if (track.start_date.isBlank()) {
view.track_search_start.gone()
view.track_search_start_result.gone()
view.track_search_start.isVisible = false
view.track_search_start_result.isVisible = false
} else {
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.os.Bundle
import android.view.View
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
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.model.TrackSearch
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 kotlinx.android.synthetic.main.track_search_dialog.view.progress
import kotlinx.android.synthetic.main.track_search_dialog.view.track_search
@ -108,23 +108,23 @@ class TrackSearchDialog : DialogController {
private fun search(query: String) {
val view = dialogView ?: return
view.progress.visible()
view.track_search_list.invisible()
view.progress.isVisible = true
view.track_search_list.isInvisible = true
trackController.presenter.search(query, service)
}
fun onSearchResults(results: List<TrackSearch>) {
selectedItem = null
val view = dialogView ?: return
view.progress.invisible()
view.track_search_list.visible()
view.progress.isInvisible = true
view.track_search_list.isVisible = true
adapter?.setItems(results)
}
fun onSearchResultsError() {
val view = dialogView ?: return
view.progress.visible()
view.track_search_list.invisible()
view.progress.isVisible = true
view.track_search_list.isInvisible = true
adapter?.setItems(emptyList())
}

View File

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

View File

@ -4,6 +4,8 @@ import android.os.Bundle
import android.widget.CompoundButton
import android.widget.Spinner
import androidx.annotation.ArrayRes
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetDialog
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.ui.reader.viewer.pager.PagerViewer
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 uy.kohesive.injekt.injectLazy
@ -80,8 +79,8 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
* Init the preferences for the pager reader.
*/
private fun initPagerPreferences() {
binding.webtoonPrefsGroup.invisible()
binding.pagerPrefsGroup.visible()
binding.webtoonPrefsGroup.isInvisible = true
binding.pagerPrefsGroup.isVisible = true
binding.scaleType.bindToPreference(preferences.imageScaleType(), 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.
*/
private fun initWebtoonPreferences() {
binding.pagerPrefsGroup.invisible()
binding.webtoonPrefsGroup.visible()
binding.pagerPrefsGroup.isInvisible = true
binding.webtoonPrefsGroup.isVisible = true
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() {
if (!preferences.readWithTapping().get()) {
binding.navigationPrefsGroup.gone()
binding.navigationPrefsGroup.isVisible = false
}
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.LinearInterpolator
import android.view.animation.RotateAnimation
import androidx.core.view.isGone
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.gone
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.
*/
fun hide(animate: Boolean = false) {
if (visibility == GONE) return
if (isGone) return
if (!animate) {
gone()
isVisible = false
} else {
ObjectAnimator.ofFloat(this, "alpha", 1f, 0f).apply {
interpolator = DecelerateInterpolator()
duration = 1000
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
gone()
isVisible = false
alpha = 1f
}

View File

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

View File

@ -5,6 +5,8 @@ import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup.LayoutParams
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.viewpager.widget.ViewPager
import eu.kanade.tachiyomi.R
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.ViewerChapters
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
/**
@ -66,7 +66,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
}
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.offscreenPageLimit = 1
pager.id = R.id.reader_pager
@ -225,11 +225,11 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
adapter.setChapters(chapters, forceTransition)
// Layout the pager once a chapter is being set
if (pager.visibility == View.GONE) {
if (pager.isGone) {
Timber.d("Pager first layout")
val pages = chapters.currChapter.pages ?: return
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 androidx.appcompat.widget.AppCompatButton
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.view.isVisible
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy
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.util.system.ImageUtil
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.util.concurrent.TimeUnit
import rx.Observable
@ -145,9 +144,9 @@ class WebtoonPageHolder(
removeDecodeErrorLayout()
subsamplingImageView?.recycle()
subsamplingImageView?.gone()
subsamplingImageView?.isVisible = false
imageView?.let { GlideApp.with(frame).clear(it) }
imageView?.gone()
imageView?.isVisible = false
progressBar.setProgress(0)
}
@ -238,9 +237,9 @@ class WebtoonPageHolder(
* Called when the page is queued.
*/
private fun setQueued() {
progressContainer.visible()
progressBar.visible()
retryContainer?.gone()
progressContainer.isVisible = true
progressBar.isVisible = true
retryContainer?.isVisible = false
removeDecodeErrorLayout()
}
@ -248,9 +247,9 @@ class WebtoonPageHolder(
* Called when the page is loading.
*/
private fun setLoading() {
progressContainer.visible()
progressBar.visible()
retryContainer?.gone()
progressContainer.isVisible = true
progressBar.isVisible = true
retryContainer?.isVisible = false
removeDecodeErrorLayout()
}
@ -258,9 +257,9 @@ class WebtoonPageHolder(
* Called when the page is downloading
*/
private fun setDownloading() {
progressContainer.visible()
progressBar.visible()
retryContainer?.gone()
progressContainer.isVisible = true
progressBar.isVisible = true
retryContainer?.isVisible = false
removeDecodeErrorLayout()
}
@ -268,10 +267,10 @@ class WebtoonPageHolder(
* Called when the page is ready.
*/
private fun setImage() {
progressContainer.visible()
progressBar.visible()
progressContainer.isVisible = true
progressBar.isVisible = true
progressBar.completeAndFadeOut()
retryContainer?.gone()
retryContainer?.isVisible = false
removeDecodeErrorLayout()
unsubscribeReadImageHeader()
@ -290,11 +289,11 @@ class WebtoonPageHolder(
.doOnNext { isAnimated ->
if (!isAnimated) {
val subsamplingView = initSubsamplingImageView()
subsamplingView.visible()
subsamplingView.isVisible = true
subsamplingView.setImage(ImageSource.inputStream(openStream!!))
} else {
val imageView = initImageView()
imageView.visible()
imageView.isVisible = true
imageView.setImage(openStream!!)
}
}
@ -310,23 +309,23 @@ class WebtoonPageHolder(
* Called when the page has an error.
*/
private fun setError() {
progressContainer.gone()
initRetryLayout().visible()
progressContainer.isVisible = false
initRetryLayout().isVisible = true
}
/**
* Called when the image is decoded and going to be displayed.
*/
private fun onImageDecoded() {
progressContainer.gone()
progressContainer.isVisible = false
}
/**
* Called when the image fails to decode.
*/
private fun onImageDecodeError() {
progressContainer.gone()
initDecodeErrorLayout().visible()
progressContainer.isVisible = false
initDecodeErrorLayout().isVisible = true
}
/**

View File

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

View File

@ -5,6 +5,8 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
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.WebtoonLayoutManager
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.ViewerChapters
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.min
import rx.subscriptions.CompositeSubscription
@ -66,7 +66,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
val subscriptions = CompositeSubscription()
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.itemAnimator = null
recycler.layoutManager = layoutManager
@ -211,11 +211,11 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
val forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition
adapter.setChapters(chapters, forceTransition)
if (recycler.visibility == View.GONE) {
if (recycler.isGone) {
Timber.d("Recycler first layout")
val pages = chapters.currChapter.pages ?: return
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.WebView
import androidx.core.graphics.ColorUtils
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.webkit.WebViewClientCompat
import eu.kanade.tachiyomi.BuildConfig
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.setDefaultSettings
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.onEach
import reactivecircus.flowbinding.appcompat.navigationClicks
@ -83,10 +83,10 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
binding.webview.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView?, newProgress: Int) {
binding.progressBar.visible()
binding.progressBar.isVisible = true
binding.progressBar.progress = newProgress
if (newProgress == 100) {
binding.progressBar.invisible()
binding.progressBar.isInvisible = true
}
super.onProgressChanged(view, newProgress)
}

View File

@ -68,26 +68,6 @@ fun View.popupMenu(@MenuRes menuRes: Int, initMenu: (Menu.() -> Unit)? = null, o
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.
*

View File

@ -9,9 +9,8 @@ import android.widget.FrameLayout
import androidx.annotation.IdRes
import androidx.annotation.MenuRes
import androidx.appcompat.view.ActionMode
import androidx.core.view.isVisible
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_toolbar
@ -50,7 +49,7 @@ class ActionToolbar @JvmOverloads constructor(context: Context, attrs: Attribute
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)
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)
bottomAnimation.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationEnd(animation: Animation) {
common_action_toolbar.gone()
common_action_toolbar.isVisible = false
}
})
common_action_toolbar.startAnimation(bottomAnimation)

View File

@ -6,9 +6,8 @@ import android.widget.LinearLayout
import android.widget.RelativeLayout
import androidx.annotation.StringRes
import androidx.appcompat.widget.AppCompatButton
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlin.random.Random
import kotlinx.android.synthetic.main.common_view_empty.view.actions_container
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
*/
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 {

View File

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

View File

@ -4,13 +4,12 @@ import android.graphics.drawable.Drawable
import android.view.View
import android.widget.ImageView
import android.widget.ImageView.ScaleType
import androidx.core.view.isVisible
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.bumptech.glide.request.target.ImageViewTarget
import com.bumptech.glide.request.transition.Transition
import eu.kanade.tachiyomi.R
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
@ -37,12 +36,12 @@ class StateImageViewTarget(
}
override fun onLoadStarted(placeholder: Drawable?) {
progress?.visible()
progress?.isVisible = true
super.onLoadStarted(placeholder)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
progress?.gone()
progress?.isVisible = false
view.scaleType = errorScaleType
val vector = VectorDrawableCompat.create(view.context.resources, errorDrawableRes, null)
@ -51,12 +50,12 @@ class StateImageViewTarget(
}
override fun onLoadCleared(placeholder: Drawable?) {
progress?.gone()
progress?.isVisible = false
super.onLoadCleared(placeholder)
}
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
progress?.gone()
progress?.isVisible = false
view.scaleType = imageScaleType
super.onResourceReady(resource, transition)
this.resource = resource