From 820d3f2413b117b49c4c32f0cd50e5a88ddb1c16 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Wed, 17 Apr 2024 19:16:23 +0300 Subject: [PATCH] Update placeholders --- .../kotatsu/tracker/ui/debug/TrackDebugAD.kt | 5 +- .../kotatsu/alternatives/ui/AlternativeAD.kt | 5 +- .../bookmarks/ui/adapter/BookmarkListAD.kt | 6 +- .../bookmarks/ui/sheet/BookmarkLargeAD.kt | 6 +- .../ui/image/AnimatedPlaceholderDrawable.kt | 81 +++++++++++++++++++ .../koitharu/kotatsu/core/util/ext/Coil.kt | 9 +++ .../kotatsu/details/ui/DetailsActivity.kt | 6 +- .../details/ui/pager/pages/PageThumbnailAD.kt | 5 +- .../details/ui/scrobbling/ScrobblingInfoAD.kt | 5 +- .../ui/scrobbling/ScrobblingInfoSheet.kt | 5 +- .../download/ui/list/DownloadItemAD.kt | 5 +- .../ui/adapter/ExploreAdapterDelegates.kt | 5 +- .../list/ui/adapter/MangaGridItemAD.kt | 6 +- .../ui/adapter/MangaListDetailedItemAD.kt | 6 +- .../list/ui/adapter/MangaListItemAD.kt | 6 +- .../list/ui/preview/PreviewFragment.kt | 5 +- .../reader/ui/ReaderBottomMenuProvider.kt | 1 + .../ui/config/adapter/ScrobblingMangaAD.kt | 6 +- .../ui/selector/adapter/ScrobblingMangaAD.kt | 6 +- .../adapter/SearchSuggestionsMangaListAD.kt | 5 +- .../tracker/ui/feed/adapter/FeedItemAD.kt | 5 +- 21 files changed, 127 insertions(+), 62 deletions(-) create mode 100644 app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/AnimatedPlaceholderDrawable.kt diff --git a/app/src/debug/kotlin/org/koitharu/kotatsu/tracker/ui/debug/TrackDebugAD.kt b/app/src/debug/kotlin/org/koitharu/kotatsu/tracker/ui/debug/TrackDebugAD.kt index 596669443..9590267eb 100644 --- a/app/src/debug/kotlin/org/koitharu/kotatsu/tracker/ui/debug/TrackDebugAD.kt +++ b/app/src/debug/kotlin/org/koitharu/kotatsu/tracker/ui/debug/TrackDebugAD.kt @@ -11,6 +11,7 @@ import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.drawableStart import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.getThemeColor @@ -35,9 +36,7 @@ fun trackDebugAD( bind { binding.imageViewCover.newImageRequest(lifecycleOwner, item.manga.coverUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) source(item.manga.source) enqueueWith(coil) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/ui/AlternativeAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/ui/AlternativeAD.kt index 377ecd327..fa467541e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/ui/AlternativeAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/ui/AlternativeAD.kt @@ -16,6 +16,7 @@ import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.image.TrimTransformation import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.source @@ -79,9 +80,7 @@ fun alternativeAD( } binding.imageViewCover.newImageRequest(lifecycleOwner, item.manga.coverUrl)?.run { size(CoverSizeResolver(binding.imageViewCover)) - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) transformations(TrimTransformation()) allowRgb565(true) tag(item.manga) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarkListAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarkListAD.kt index c947e0669..e86073cb1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarkListAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarkListAD.kt @@ -3,12 +3,12 @@ package org.koitharu.kotatsu.bookmarks.ui.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.bookmarks.domain.Bookmark import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener import org.koitharu.kotatsu.core.util.ext.decodeRegion +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.source @@ -29,9 +29,7 @@ fun bookmarkListAD( bind { binding.imageViewThumb.newImageRequest(lifecycleOwner, item.imageLoadData)?.run { size(CoverSizeResolver(binding.imageViewThumb)) - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) tag(item) decodeRegion(item.scroll) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarkLargeAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarkLargeAD.kt index 0cfc4122a..57a46c11c 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarkLargeAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/sheet/BookmarkLargeAD.kt @@ -3,12 +3,12 @@ package org.koitharu.kotatsu.bookmarks.ui.sheet import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.bookmarks.domain.Bookmark import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener import org.koitharu.kotatsu.core.util.ext.decodeRegion +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.source @@ -30,9 +30,7 @@ fun bookmarkLargeAD( bind { binding.imageViewThumb.newImageRequest(lifecycleOwner, item.imageLoadData)?.run { size(CoverSizeResolver(binding.imageViewThumb)) - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) tag(item) decodeRegion(item.scroll) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/AnimatedPlaceholderDrawable.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/AnimatedPlaceholderDrawable.kt new file mode 100644 index 000000000..860929a27 --- /dev/null +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/AnimatedPlaceholderDrawable.kt @@ -0,0 +1,81 @@ +package org.koitharu.kotatsu.core.ui.image + +import android.animation.TimeAnimator +import android.content.Context +import android.graphics.Canvas +import android.graphics.ColorFilter +import android.graphics.PixelFormat +import android.graphics.drawable.Animatable +import android.graphics.drawable.Drawable +import android.view.animation.AccelerateDecelerateInterpolator +import androidx.core.graphics.ColorUtils +import androidx.interpolator.view.animation.FastOutSlowInInterpolator +import com.google.android.material.animation.ArgbEvaluatorCompat +import org.koitharu.kotatsu.core.util.ext.getThemeColor +import kotlin.math.abs +import com.google.android.material.R as materialR + +class AnimatedPlaceholderDrawable(context: Context) : Drawable(), Animatable, TimeAnimator.TimeListener { + + private val colorLow = context.getThemeColor(materialR.attr.colorSurfaceContainerLow) + private val colorHigh = context.getThemeColor(materialR.attr.colorSurfaceContainerHigh) + private var currentColor: Int = colorLow + private var alpha: Int = 255 + private val interpolator = FastOutSlowInInterpolator() + private val period = 2000 + private val timeAnimator = TimeAnimator() + + init { + timeAnimator.setTimeListener(this) + updateColor() + } + + override fun draw(canvas: Canvas) { + if (!isRunning) { + updateColor() + start() + } + canvas.drawColor(currentColor) + } + + override fun setAlpha(alpha: Int) { + this.alpha = alpha + } + + override fun setColorFilter(colorFilter: ColorFilter?) { + throw UnsupportedOperationException("ColorFilter is not supported by PlaceholderDrawable") + } + + @Deprecated("Deprecated in Java") + override fun getOpacity(): Int = PixelFormat.OPAQUE + + override fun getAlpha(): Int = alpha + + override fun onTimeUpdate(animation: TimeAnimator?, totalTime: Long, deltaTime: Long) { + if (callback != null) { + updateColor() + invalidateSelf() + } + } + + override fun start() { + timeAnimator.start() + } + + override fun stop() { + timeAnimator.cancel() + } + + override fun isRunning(): Boolean = timeAnimator.isStarted + + private fun updateColor() { + val ph = period / 2 + val fraction = abs((System.currentTimeMillis() % period) - ph) / ph.toFloat() + var color = ArgbEvaluatorCompat.getInstance() + .evaluate(interpolator.getInterpolation(fraction), colorLow, colorHigh) + if (alpha != 255) { + color = ColorUtils.setAlphaComponent(color, alpha) + } + currentColor = color + } +} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt index c64f5c97f..e34c743f7 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt @@ -1,6 +1,7 @@ package org.koitharu.kotatsu.core.util.ext import android.content.Context +import android.graphics.drawable.ColorDrawable import android.widget.ImageView import androidx.core.graphics.drawable.toBitmap import androidx.lifecycle.LifecycleOwner @@ -12,9 +13,11 @@ import coil.request.SuccessResult import coil.util.CoilUtils import com.google.android.material.progressindicator.BaseProgressIndicator import org.koitharu.kotatsu.R +import org.koitharu.kotatsu.core.ui.image.AnimatedPlaceholderDrawable import org.koitharu.kotatsu.core.ui.image.RegionBitmapDecoder import org.koitharu.kotatsu.core.util.progress.ImageRequestIndicatorListener import org.koitharu.kotatsu.parsers.model.MangaSource +import com.google.android.material.R as materialR fun ImageView.newImageRequest(lifecycleOwner: LifecycleOwner, data: Any?): ImageRequest.Builder? { val current = CoilUtils.result(this) @@ -85,6 +88,12 @@ fun ImageRequest.Builder.source(source: MangaSource?): ImageRequest.Builder { return tag(MangaSource::class.java, source) } +fun ImageRequest.Builder.defaultPlaceholders(context: Context): ImageRequest.Builder { + return placeholder(AnimatedPlaceholderDrawable(context)) + .fallback(ColorDrawable(context.getThemeColor(materialR.attr.colorSurfaceContainer))) + .error(ColorDrawable(context.getThemeColor(materialR.attr.colorErrorContainer))) +} + fun ImageRequest.Builder.addListener(listener: ImageRequest.Listener): ImageRequest.Builder { val existing = build().listener return listener( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index d352bf830..7ca5e7465 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -51,13 +51,13 @@ import org.koitharu.kotatsu.core.ui.BaseListAdapter import org.koitharu.kotatsu.core.ui.image.ChipIconTarget import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener -import org.koitharu.kotatsu.core.ui.list.decor.SpacingItemDecoration import org.koitharu.kotatsu.core.ui.util.MenuInvalidator import org.koitharu.kotatsu.core.ui.util.ReversibleActionObserver import org.koitharu.kotatsu.core.ui.widgets.ChipsView import org.koitharu.kotatsu.core.util.FileSize import org.koitharu.kotatsu.core.util.ViewBadge import org.koitharu.kotatsu.core.util.ext.crossfade +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.getThemeColor import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty @@ -638,9 +638,7 @@ class DetailsActivity : .placeholder(previousDrawable) .error(previousDrawable) } else { - request.fallback(R.drawable.ic_placeholder) - .placeholder(R.drawable.ic_placeholder) - .error(R.drawable.ic_error_placeholder) + request.defaultPlaceholders(this) } request.enqueueWith(coil) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/pages/PageThumbnailAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/pages/PageThumbnailAD.kt index e18c2e233..d315fe027 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/pages/PageThumbnailAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/pages/PageThumbnailAD.kt @@ -9,6 +9,7 @@ import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener import org.koitharu.kotatsu.core.util.ext.decodeRegion +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.setTextColorAttr @@ -38,9 +39,7 @@ fun pageThumbnailAD( bind { val data: Any = item.page.preview?.takeUnless { it.isEmpty() } ?: item.page.toMangaPage() binding.imageViewThumb.newImageRequest(lifecycleOwner, data)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) size(thumbSize) scale(Scale.FILL) allowRgb565(true) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoAD.kt index 1a42bd0bd..83326baff 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoAD.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding import org.koitharu.kotatsu.R +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.databinding.ItemScrobblingInfoBinding @@ -24,9 +25,7 @@ fun scrobblingInfoAD( bind { binding.imageViewCover.newImageRequest(lifecycleOwner, item.coverUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) enqueueWith(coil) } binding.textViewTitle.setText(item.scrobbler.titleResId) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoSheet.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoSheet.kt index cc3f71d6a..de96a0a5a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoSheet.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/scrobbling/ScrobblingInfoSheet.kt @@ -18,6 +18,7 @@ import coil.ImageLoader import dagger.hilt.android.AndroidEntryPoint import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.sheet.BaseAdaptiveSheet +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.getDisplayMessage import org.koitharu.kotatsu.core.util.ext.newImageRequest @@ -129,9 +130,7 @@ class ScrobblingInfoSheet : binding.imageViewLogo.contentDescription = getString(scrobbling.scrobbler.titleResId) binding.imageViewLogo.setImageResource(scrobbling.scrobbler.iconResId) binding.imageViewCover.newImageRequest(viewLifecycleOwner, scrobbling.coverUrl)?.apply { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(binding.imageViewCover.context) enqueueWith(coil) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt index 50803559b..cfa2a06c5 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt @@ -19,6 +19,7 @@ import kotlinx.coroutines.launch import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.BaseListAdapter import org.koitharu.kotatsu.core.ui.image.TrimTransformation +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.source @@ -88,9 +89,7 @@ fun downloadItemAD( binding.textViewTitle.text = item.manga?.title ?: getString(R.string.unknown) if ((CoilUtils.result(binding.imageViewCover) as? SuccessResult)?.memoryCacheKey != item.coverCacheKey) { binding.imageViewCover.newImageRequest(lifecycleOwner, item.manga?.coverUrl)?.apply { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) transformations(TrimTransformation()) memoryCacheKey(item.coverCacheKey) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt index 04c592ed6..f181d5088 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/adapter/ExploreAdapterDelegates.kt @@ -13,6 +13,7 @@ import org.koitharu.kotatsu.core.ui.image.FaviconDrawable import org.koitharu.kotatsu.core.ui.image.TrimTransformation import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.recyclerView @@ -89,9 +90,7 @@ fun recommendationMangaItemAD( binding.textViewTitle.text = item.manga.title binding.textViewSubtitle.textAndVisible = item.subtitle binding.imageViewCover.newImageRequest(lifecycleOwner, item.manga.coverUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) transformations(TrimTransformation()) source(item.manga.source) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt index 0840404e8..0fc374be2 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaGridItemAD.kt @@ -5,10 +5,10 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.google.android.material.badge.BadgeDrawable import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.image.TrimTransformation import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.setOnContextClickListenerCompat @@ -44,9 +44,7 @@ fun mangaGridItemAD( binding.progressView.setPercent(item.progress, ListModelDiffCallback.PAYLOAD_PROGRESS_CHANGED in payloads) binding.imageViewCover.newImageRequest(lifecycleOwner, item.coverUrl)?.run { size(CoverSizeResolver(binding.imageViewCover)) - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) transformations(TrimTransformation()) allowRgb565(true) tag(item.manga) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt index ee7e3ba5d..5e575d225 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListDetailedItemAD.kt @@ -5,9 +5,9 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.google.android.material.badge.BadgeDrawable import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.image.TrimTransformation +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.setOnContextClickListenerCompat @@ -42,9 +42,7 @@ fun mangaListDetailedItemAD( binding.progressView.setPercent(item.progress, ListModelDiffCallback.PAYLOAD_PROGRESS_CHANGED in payloads) binding.imageViewCover.newImageRequest(lifecycleOwner, item.coverUrl)?.run { size(CoverSizeResolver(binding.imageViewCover)) - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) transformations(TrimTransformation()) allowRgb565(true) tag(item.manga) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt index c15805d59..6a92013f5 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/adapter/MangaListItemAD.kt @@ -5,9 +5,9 @@ import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.google.android.material.badge.BadgeDrawable import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.image.TrimTransformation import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.setOnContextClickListenerCompat @@ -39,9 +39,7 @@ fun mangaListItemAD( binding.textViewTitle.text = item.title binding.textViewSubtitle.textAndVisible = item.subtitle binding.imageViewCover.newImageRequest(lifecycleOwner, item.coverUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) transformations(TrimTransformation()) tag(item.manga) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt index 450986b23..c28db648e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt @@ -20,6 +20,7 @@ import org.koitharu.kotatsu.core.ui.BaseFragment import org.koitharu.kotatsu.core.ui.image.CoverSizeResolver import org.koitharu.kotatsu.core.ui.widgets.ChipsView import org.koitharu.kotatsu.core.util.ext.crossfade +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.observe @@ -178,9 +179,7 @@ class PreviewFragment : BaseFragment(), View.OnClickList .placeholder(previousDrawable) .error(previousDrawable) } else { - request.fallback(R.drawable.ic_placeholder) - .placeholder(R.drawable.ic_placeholder) - .error(R.drawable.ic_error_placeholder) + request.defaultPlaceholders(requireContext()) } request.enqueueWith(coil) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt index c7ddc9f22..462c256e1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt @@ -113,6 +113,7 @@ class ReaderBottomMenuProvider( valueTo = state.totalPages.toFloat() - 1 setValueRounded(state.currentPage.toFloat()) labelBehavior = LabelFormatter.LABEL_FLOATING + isTickVisible = true setLabelFormatter(PageLabelFormatter()) ReaderSliderListener(viewModel, callback).attachToSlider(this) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAD.kt index 25e83d14c..dd6c1a1b4 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/config/adapter/ScrobblingMangaAD.kt @@ -3,9 +3,9 @@ package org.koitharu.kotatsu.scrobbling.common.ui.config.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.databinding.ItemScrobblingMangaBinding @@ -25,9 +25,7 @@ fun scrobblingMangaAD( bind { binding.imageViewCover.newImageRequest(lifecycleOwner, item.coverUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) enqueueWith(coil) } binding.textViewTitle.text = item.title diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblingMangaAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblingMangaAD.kt index df3fb42ad..29d27adf1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblingMangaAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/scrobbling/common/ui/selector/adapter/ScrobblingMangaAD.kt @@ -3,8 +3,8 @@ package org.koitharu.kotatsu.scrobbling.common.ui.selector.adapter import androidx.lifecycle.LifecycleOwner import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.textAndVisible @@ -27,9 +27,7 @@ fun scrobblingMangaAD( binding.textViewTitle.text = item.name binding.textViewSubtitle.textAndVisible = item.altName binding.imageViewCover.newImageRequest(lifecycleOwner, item.cover)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) enqueueWith(coil) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/adapter/SearchSuggestionsMangaListAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/adapter/SearchSuggestionsMangaListAD.kt index 7609d4881..382a97b1b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/adapter/SearchSuggestionsMangaListAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/adapter/SearchSuggestionsMangaListAD.kt @@ -11,6 +11,7 @@ import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.list.decor.SpacingItemDecoration import org.koitharu.kotatsu.core.util.RecyclerViewScrollCallback +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest import org.koitharu.kotatsu.core.util.ext.source @@ -56,9 +57,7 @@ private fun searchSuggestionMangaGridAD( bind { binding.imageViewCover.newImageRequest(lifecycleOwner, item.coverUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) source(item.source) enqueueWith(coil) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/adapter/FeedItemAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/adapter/FeedItemAD.kt index 2eaab8816..e69ceb513 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/adapter/FeedItemAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/ui/feed/adapter/FeedItemAD.kt @@ -6,6 +6,7 @@ import coil.ImageLoader import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener +import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.drawableStart import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.newImageRequest @@ -29,9 +30,7 @@ fun feedItemAD( bind { binding.imageViewCover.newImageRequest(lifecycleOwner, item.imageUrl)?.run { - placeholder(R.drawable.ic_placeholder) - fallback(R.drawable.ic_placeholder) - error(R.drawable.ic_error_placeholder) + defaultPlaceholders(context) allowRgb565(true) source(item.manga.source) enqueueWith(coil)