use caching at the ImageDecoder for faster fullscreen image loading
This commit is contained in:
parent
c0f2f0a301
commit
c5042bd89d
1 changed files with 7 additions and 9 deletions
|
@ -5,7 +5,6 @@ import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.DecodeFormat
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.davemorrissey.labs.subscaleview.ImageDecoder
|
import com.davemorrissey.labs.subscaleview.ImageDecoder
|
||||||
|
@ -14,16 +13,15 @@ class MyGlideImageDecoder(val degrees: Int) : ImageDecoder {
|
||||||
|
|
||||||
override fun decode(context: Context, uri: Uri): Bitmap {
|
override fun decode(context: Context, uri: Uri): Bitmap {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.fitCenter()
|
||||||
.fitCenter()
|
|
||||||
|
|
||||||
val builder = Glide.with(context)
|
val builder = Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(uri)
|
.load(uri)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.transform(RotateTransformation(-degrees))
|
.transform(RotateTransformation(-degrees))
|
||||||
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
|
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
|
||||||
|
|
||||||
return builder.get()
|
return builder.get()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue