Apply requested changes
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -98,7 +98,7 @@ class ImageActivity : BaseActivity<ActivityImageBinding>(), ImageRequest.Listene
|
||||
.enqueueWith(coil)
|
||||
}
|
||||
|
||||
private data class SsivTarget(
|
||||
private class SsivTarget(
|
||||
override val view: SubsamplingScaleImageView,
|
||||
) : ViewTarget<SubsamplingScaleImageView> {
|
||||
|
||||
@@ -106,6 +106,14 @@ class ImageActivity : BaseActivity<ActivityImageBinding>(), 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()))
|
||||
|
||||
Reference in New Issue
Block a user