image: fix seam regression in coverview

Turns out that useless code from ImageGroup prevented a seam from
appearing when the playing indicator was shown. Re-add that,
albeit a bit less hacky.
This commit is contained in:
Alexander Capehart 2023-05-28 16:01:59 -06:00
parent b7c15e0cc5
commit 770ae77eed
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 12 additions and 19 deletions

View file

@ -199,7 +199,18 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
private fun invalidatePlaybackIndicatorAlpha(playbackIndicator: ImageView) {
playbackIndicator.alpha = if (isSelected) 1f else 0f
// Occasionally content can bleed through the rounded corners and result in a seam
// on the playing indicator, prevent that from occurring by disabling the visibility of
// all views below the playback indicator.
for (child in children) {
child.alpha =
when (child) {
// Selection badge is above the playback indicator, do nothing
selectionBadge -> child.alpha
playbackIndicator -> if (isSelected) 1f else 0f
else -> if (isSelected) 0f else 1f
}
}
}
private fun invalidateSelectionIndicatorAlpha(selectionBadge: ImageView) {

View file

@ -43,7 +43,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import java.io.ByteArrayInputStream
import java.io.InputStream
import javax.inject.Inject
import kotlin.math.min
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.guava.asDeferred
import kotlinx.coroutines.withContext
@ -253,21 +252,4 @@ constructor(
val size = pxOrElse { 512 }
return if (size.mod(2) > 0) size + 1 else size
}
private fun transform(input: Bitmap, size: Size): Bitmap {
// Find the smaller dimension and then take a center portion of the image that
// has that size.
val dstSize = min(input.width, input.height)
val x = (input.width - dstSize) / 2
val y = (input.height - dstSize) / 2
val dst = Bitmap.createBitmap(input, x, y, dstSize, dstSize)
val desiredWidth = size.width.pxOrElse { dstSize }
val desiredHeight = size.height.pxOrElse { dstSize }
if (dstSize != desiredWidth || dstSize != desiredHeight) {
// Image is not the desired size, upscale it.
return Bitmap.createScaledBitmap(dst, desiredWidth, desiredHeight, true)
}
return dst
}
}