use Glide for displaying fullscreen images, if subsampling fails

This commit is contained in:
tibbi 2016-12-29 19:58:16 +01:00
parent 7a4948fa31
commit 0383769c9e
2 changed files with 27 additions and 3 deletions

View File

@ -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?) {
}
})
}
}

View File

@ -6,13 +6,12 @@
android:layout_height="match_parent">
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/gif_view"
android:id="@+id/glide_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>