calculate minimal tile dpi at fullscreen view dynamically

This commit is contained in:
tibbi 2018-09-05 22:13:31 +02:00
parent cff5949f94
commit 036641c0c4
1 changed files with 12 additions and 0 deletions

View File

@ -354,7 +354,9 @@ class PhotoFragment : ViewPagerFragment() {
private fun addZoomableView() {
val rotation = degreesForRotation(imageOrientation)
view.subsampling_view.apply {
setMinimumTileDpi(getMinTileDpi())
background = ColorDrawable(Color.TRANSPARENT)
setBitmapDecoderFactory { PicassoDecoder(medium.path, Picasso.get(), rotation) }
setRegionDecoderFactory { PicassoRegionDecoder() }
@ -396,6 +398,16 @@ class PhotoFragment : ViewPagerFragment() {
}
}
private fun getMinTileDpi(): Int {
val metrics = resources.displayMetrics
val averageDpi = (metrics.xdpi + metrics.ydpi) / 2
return when {
averageDpi > 400 -> 320
averageDpi > 300 -> 240
else -> 160
}
}
private fun checkIfPanorama() {
isPanorama = try {
val inputStream = if (medium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(medium.path)) else File(medium.path).inputStream()