calculate minimal tile dpi at fullscreen view dynamically
This commit is contained in:
parent
cff5949f94
commit
036641c0c4
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue