From 0383769c9e561d270e094ca4af32e5e3c9f8763f Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 29 Dec 2016 19:58:16 +0100 Subject: [PATCH] use Glide for displaying fullscreen images, if subsampling fails --- .../gallery/fragments/PhotoFragment.kt | 27 ++++++++++++++++++- app/src/main/res/layout/pager_photo_item.xml | 3 +-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index fccb577c5..d6386c5a4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -29,7 +29,7 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener { subsamplingView = view.photo_view if (medium.isGif()) { subsamplingView.visibility = View.GONE - view.gif_view.apply { + view.glide_view.apply { visibility = View.VISIBLE Glide.with(context).load(medium.path).asGif().diskCacheStrategy(DiskCacheStrategy.NONE).into(this) setOnClickListener(this@PhotoFragment) @@ -42,6 +42,31 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener { maxScale = 4f setMinimumTileDpi(100) setOnClickListener(this@PhotoFragment) + setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener { + override fun onImageLoaded() { + } + + override fun onReady() { + } + + override fun onTileLoadError(p0: Exception?) { + } + + override fun onPreviewReleased() { + } + + override fun onImageLoadError(p0: Exception?) { + subsamplingView.visibility = View.GONE + view.glide_view.apply { + visibility = View.VISIBLE + Glide.with(context).load(medium.path).diskCacheStrategy(DiskCacheStrategy.NONE).into(this) + setOnClickListener(this@PhotoFragment) + } + } + + override fun onPreviewLoadError(p0: Exception?) { + } + }) } } diff --git a/app/src/main/res/layout/pager_photo_item.xml b/app/src/main/res/layout/pager_photo_item.xml index bf7420d63..463630ace 100644 --- a/app/src/main/res/layout/pager_photo_item.xml +++ b/app/src/main/res/layout/pager_photo_item.xml @@ -6,13 +6,12 @@ android:layout_height="match_parent">