widgets: work around new coil scaling behavior
Fix an issue where album covers fail to load when not explicitly specifying a size. At some point, Coil changed some internal scaling logic to depend on this weird pseudo-screen size value that caused the bitmap to fail to load only on in widget creation process. Who knows why. Fix this by explicitly specifying the size in all cases.
This commit is contained in:
parent
8100f294d7
commit
2406c371db
1 changed files with 4 additions and 1 deletions
|
@ -31,6 +31,7 @@ import android.widget.RemoteViews
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import coil.imageLoader
|
import coil.imageLoader
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
|
import coil.size.Size
|
||||||
import coil.transform.RoundedCornersTransformation
|
import coil.transform.RoundedCornersTransformation
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import org.oxycblt.auxio.BuildConfig
|
import org.oxycblt.auxio.BuildConfig
|
||||||
|
@ -120,7 +121,9 @@ class WidgetProvider : AppWidgetProvider() {
|
||||||
.transformations(SquareFrameTransform(), transform)
|
.transformations(SquareFrameTransform(), transform)
|
||||||
.size(min(metrics.widthPixels, metrics.heightPixels))
|
.size(min(metrics.widthPixels, metrics.heightPixels))
|
||||||
} else {
|
} else {
|
||||||
coverRequest.transformations(SquareFrameTransform())
|
// Note: Explicitly use the "original" size as without it the scaling logic
|
||||||
|
// in SquareFrameTransform breaks down and results in an error.
|
||||||
|
coverRequest.transformations(SquareFrameTransform()).size(Size.ORIGINAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.imageLoader.enqueue(coverRequest.build())
|
context.imageLoader.enqueue(coverRequest.build())
|
||||||
|
|
Loading…
Reference in a new issue