diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/TrimTransformation.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/TrimTransformation.kt index ee37d0c9d..88dda77b5 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/TrimTransformation.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/image/TrimTransformation.kt @@ -11,7 +11,7 @@ import coil.size.Size import coil.transform.Transformation import kotlin.math.abs -data class TrimTransformation( +class TrimTransformation( private val tolerance: Int = 20, ) : Transformation { @@ -104,4 +104,12 @@ data class TrimTransformation( abs(a.blue - b.blue) <= tolerance && abs(a.alpha - b.alpha) <= tolerance } + + override fun equals(other: Any?): Boolean { + return this === other || (other is TrimTransformation && other.tolerance == tolerance) + } + + override fun hashCode(): Int { + return tolerance + } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/model/DateTimeAgo.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/model/DateTimeAgo.kt index 5dfe1045b..6411bb3ea 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/model/DateTimeAgo.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/model/DateTimeAgo.kt @@ -20,6 +20,22 @@ sealed class DateTimeAgo { override fun equals(other: Any?): Boolean = other === JustNow } + data class MinutesAgo(val minutes: Int) : DateTimeAgo() { + override fun format(resources: Resources): String { + return resources.getQuantityString(R.plurals.minutes_ago, minutes, minutes) + } + + override fun toString() = "minutes_ago_$minutes" + } + + data class HoursAgo(val hours: Int) : DateTimeAgo() { + override fun format(resources: Resources): String { + return resources.getQuantityString(R.plurals.hours_ago, hours, hours) + } + + override fun toString() = "hours_ago_$hours" + } + object Today : DateTimeAgo() { override fun format(resources: Resources): String { return resources.getString(R.string.today) @@ -41,7 +57,6 @@ sealed class DateTimeAgo { } data class DaysAgo(val days: Int) : DateTimeAgo() { - override fun format(resources: Resources): String { return resources.getQuantityString(R.plurals.days_ago, days, days) } @@ -50,7 +65,6 @@ sealed class DateTimeAgo { } data class MonthsAgo(val months: Int) : DateTimeAgo() { - override fun format(resources: Resources): String { return if (months == 0) { resources.getString(R.string.this_month) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/ImageActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/ImageActivity.kt index 73203e59d..56a11f004 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/ImageActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/ImageActivity.kt @@ -98,7 +98,7 @@ class ImageActivity : BaseActivity(), ImageRequest.Listene .enqueueWith(coil) } - private data class SsivTarget( + private class SsivTarget( override val view: SubsamplingScaleImageView, ) : ViewTarget { @@ -106,6 +106,14 @@ class ImageActivity : BaseActivity(), ImageRequest.Listene override fun onSuccess(result: Drawable) = setDrawable(result) + override fun equals(other: Any?): Boolean { + return (this === other) || (other is SsivTarget && view == other.view) + } + + override fun hashCode() = view.hashCode() + + override fun toString() = "SsivTarget(view=$view)" + private fun setDrawable(drawable: Drawable?) { if (drawable != null) { view.setImage(ImageSource.Bitmap(drawable.toBitmap()))