mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
shorten some code at PicassoRegionDecoder
This commit is contained in:
parent
b78243997d
commit
f40543ae3b
1 changed files with 6 additions and 6 deletions
|
@ -11,23 +11,23 @@ class PicassoRegionDecoder : ImageRegionDecoder {
|
|||
|
||||
override fun init(context: Context, uri: Uri): Point {
|
||||
val inputStream = context.contentResolver.openInputStream(uri)
|
||||
this.decoder = BitmapRegionDecoder.newInstance(inputStream, false)
|
||||
return Point(this.decoder!!.width, this.decoder!!.height)
|
||||
decoder = BitmapRegionDecoder.newInstance(inputStream, false)
|
||||
return Point(decoder!!.width, decoder!!.height)
|
||||
}
|
||||
|
||||
override fun decodeRegion(rect: Rect, sampleSize: Int): Bitmap {
|
||||
synchronized(this.decoderLock) {
|
||||
synchronized(decoderLock) {
|
||||
val options = BitmapFactory.Options()
|
||||
options.inSampleSize = sampleSize
|
||||
options.inPreferredConfig = Bitmap.Config.ARGB_8888
|
||||
val bitmap = this.decoder!!.decodeRegion(rect, options)
|
||||
val bitmap = decoder!!.decodeRegion(rect, options)
|
||||
return bitmap ?: throw RuntimeException("Region decoder returned null bitmap - image format may not be supported")
|
||||
}
|
||||
}
|
||||
|
||||
override fun isReady() = this.decoder != null && !this.decoder!!.isRecycled
|
||||
override fun isReady() = decoder != null && !decoder!!.isRecycled
|
||||
|
||||
override fun recycle() {
|
||||
this.decoder!!.recycle()
|
||||
decoder!!.recycle()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue