mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-29 16:08:00 +01:00
fix #2202, fix crashing at zooming heic files on some devices
This commit is contained in:
parent
6fa72db840
commit
8a88a69eea
3 changed files with 11 additions and 4 deletions
|
@ -646,7 +646,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {
|
||||
override fun make() = PicassoRegionDecoder(showHighestQuality, mScreenWidth, mScreenHeight, minTileDpi)
|
||||
override fun make() = PicassoRegionDecoder(showHighestQuality, mScreenWidth, mScreenHeight, minTileDpi, mMedium.isHeic())
|
||||
}
|
||||
|
||||
var newOrientation = (rotation + mCurrentRotationDegrees) % 360
|
||||
|
|
|
@ -5,7 +5,13 @@ import android.graphics.*
|
|||
import android.net.Uri
|
||||
import com.davemorrissey.labs.subscaleview.ImageRegionDecoder
|
||||
|
||||
class PicassoRegionDecoder(val showHighestQuality: Boolean, val screenWidth: Int, val screenHeight: Int, val minTileDpi: Int) : ImageRegionDecoder {
|
||||
class PicassoRegionDecoder(
|
||||
val showHighestQuality: Boolean,
|
||||
val screenWidth: Int,
|
||||
val screenHeight: Int,
|
||||
val minTileDpi: Int,
|
||||
val isHeic: Boolean
|
||||
) : ImageRegionDecoder {
|
||||
private var decoder: BitmapRegionDecoder? = null
|
||||
private val decoderLock = Any()
|
||||
|
||||
|
@ -29,9 +35,8 @@ class PicassoRegionDecoder(val showHighestQuality: Boolean, val screenWidth: Int
|
|||
|
||||
val options = BitmapFactory.Options()
|
||||
options.inSampleSize = newSampleSize
|
||||
options.inPreferredConfig = if (showHighestQuality) Bitmap.Config.ARGB_8888 else Bitmap.Config.RGB_565
|
||||
options.inPreferredConfig = if (showHighestQuality || isHeic) Bitmap.Config.ARGB_8888 else Bitmap.Config.RGB_565
|
||||
val bitmap = decoder!!.decodeRegion(rect, options)
|
||||
|
||||
return bitmap ?: throw RuntimeException("Region decoder returned null bitmap - image format may not be supported")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ data class Medium(
|
|||
|
||||
fun isHidden() = name.startsWith('.')
|
||||
|
||||
fun isHeic() = name.toLowerCase().endsWith(".heic") || name.toLowerCase().endsWith(".heif")
|
||||
|
||||
fun getBubbleText(sorting: Int, context: Context, dateFormat: String, timeFormat: String) = when {
|
||||
sorting and SORT_BY_NAME != 0 -> name
|
||||
sorting and SORT_BY_PATH != 0 -> path
|
||||
|
|
Loading…
Reference in a new issue