deps: upgrade
Round and round: Coil -> 2.0.0-alpha05 Material -> 1.5.0-rc01 Kotlin -> 1.6.10
This commit is contained in:
@@ -12,8 +12,9 @@ import coil.fetch.DrawableResult
|
||||
import coil.fetch.FetchResult
|
||||
import coil.fetch.Fetcher
|
||||
import coil.fetch.SourceResult
|
||||
import coil.size.PixelSize
|
||||
import coil.size.Dimension
|
||||
import coil.size.Size
|
||||
import coil.size.pxOrElse
|
||||
import com.google.android.exoplayer2.MediaItem
|
||||
import com.google.android.exoplayer2.MediaMetadata
|
||||
import com.google.android.exoplayer2.MetadataRetriever
|
||||
@@ -30,6 +31,7 @@ import org.oxycblt.auxio.settings.SettingsManager
|
||||
import org.oxycblt.auxio.util.logD
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.InputStream
|
||||
import android.util.Size as AndroidSize
|
||||
|
||||
/**
|
||||
* The base implementation for all image fetchers in Auxio.
|
||||
@@ -215,12 +217,8 @@ abstract class AuxioFetcher : Fetcher {
|
||||
// Use whatever size coil gives us to create the mosaic, rounding it to even so that we
|
||||
// get a symmetrical mosaic [and to prevent bugs]. If there is no size, default to a
|
||||
// 512x512 mosaic.
|
||||
val mosaicSize = when (size) {
|
||||
is PixelSize -> PixelSize(size.width.roundEven(), size.height.roundEven())
|
||||
else -> PixelSize(512, 512)
|
||||
}
|
||||
|
||||
val increment = PixelSize(mosaicSize.width / 2, mosaicSize.height / 2)
|
||||
val mosaicSize = AndroidSize(size.width.mosaicSize(), size.height.mosaicSize())
|
||||
val increment = AndroidSize(mosaicSize.width / 2, mosaicSize.height / 2)
|
||||
|
||||
val mosaicBitmap = Bitmap.createBitmap(
|
||||
mosaicSize.width, mosaicSize.height, Bitmap.Config.ARGB_8888
|
||||
@@ -265,5 +263,8 @@ abstract class AuxioFetcher : Fetcher {
|
||||
)
|
||||
}
|
||||
|
||||
private fun Int.roundEven(): Int = if (mod(2) != 0) inc() else this
|
||||
private fun Dimension.mosaicSize(): Int {
|
||||
val size = pxOrElse { 512 }
|
||||
return if (size.mod(2) != 0) size.inc() else size
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import coil.dispose
|
||||
import coil.imageLoader
|
||||
import coil.load
|
||||
import coil.request.ImageRequest
|
||||
import coil.size.OriginalSize
|
||||
import coil.size.Size
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.music.Album
|
||||
import org.oxycblt.auxio.music.Artist
|
||||
@@ -66,7 +66,7 @@ fun ImageView.bindGenreImage(genre: Genre?) = load(genre, R.drawable.ic_genre)
|
||||
fun <T : Music> ImageView.load(music: T?, @DrawableRes error: Int) {
|
||||
dispose()
|
||||
|
||||
// We don't round album covers by default as it descecrates album artwork, but we do provide
|
||||
// We don't round album covers by default as it desecrates album artwork, but we do provide
|
||||
// an option if one wants it.
|
||||
// As for why we use clipToOutline instead of coil's RoundedCornersTransformation, the transform
|
||||
// uses the dimensions of the image to create the corners, which results in inconsistent corners
|
||||
@@ -101,7 +101,7 @@ fun loadBitmap(
|
||||
context.imageLoader.enqueue(
|
||||
ImageRequest.Builder(context)
|
||||
.data(song.album)
|
||||
.size(OriginalSize)
|
||||
.size(Size.ORIGINAL)
|
||||
.target(
|
||||
onError = { onDone(null) },
|
||||
onSuccess = { onDone(it.toBitmap()) }
|
||||
|
||||
Reference in New Issue
Block a user