fix #972, use GifTextureView for displaying gifs, do not pause/resume them
This commit is contained in:
parent
ab06f366f8
commit
f9000830f5
2 changed files with 18 additions and 27 deletions
|
@ -45,7 +45,7 @@ import it.sephiroth.android.library.exif2.ExifInterface
|
||||||
import kotlinx.android.synthetic.main.pager_photo_item.view.*
|
import kotlinx.android.synthetic.main.pager_photo_item.view.*
|
||||||
import org.apache.sanselan.common.byteSources.ByteSourceInputStream
|
import org.apache.sanselan.common.byteSources.ByteSourceInputStream
|
||||||
import org.apache.sanselan.formats.jpeg.JpegImageParser
|
import org.apache.sanselan.formats.jpeg.JpegImageParser
|
||||||
import pl.droidsonroids.gif.GifDrawable
|
import pl.droidsonroids.gif.InputSource
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -66,7 +66,6 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private var isPanorama = false
|
private var isPanorama = false
|
||||||
private var isSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
private var isSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
||||||
private var imageOrientation = -1
|
private var imageOrientation = -1
|
||||||
private var gifDrawable: GifDrawable? = null
|
|
||||||
private var loadZoomableViewHandler = Handler()
|
private var loadZoomableViewHandler = Handler()
|
||||||
|
|
||||||
private var storedShowExtendedDetails = false
|
private var storedShowExtendedDetails = false
|
||||||
|
@ -187,9 +186,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
super.setMenuVisibility(menuVisible)
|
super.setMenuVisibility(menuVisible)
|
||||||
isFragmentVisible = menuVisible
|
isFragmentVisible = menuVisible
|
||||||
if (wasInit) {
|
if (wasInit) {
|
||||||
if (medium.isGIF()) {
|
if (!medium.isGIF()) {
|
||||||
gifFragmentVisibilityChanged(menuVisible)
|
|
||||||
} else {
|
|
||||||
photoFragmentVisibilityChanged(menuVisible)
|
photoFragmentVisibilityChanged(menuVisible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,14 +217,6 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gifFragmentVisibilityChanged(isVisible: Boolean) {
|
|
||||||
if (isVisible) {
|
|
||||||
gifDrawable?.start()
|
|
||||||
} else {
|
|
||||||
gifDrawable?.stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun photoFragmentVisibilityChanged(isVisible: Boolean) {
|
private fun photoFragmentVisibilityChanged(isVisible: Boolean) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
|
@ -269,22 +258,18 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private fun loadGif() {
|
private fun loadGif() {
|
||||||
try {
|
try {
|
||||||
val pathToLoad = getPathToLoad(medium)
|
val pathToLoad = getPathToLoad(medium)
|
||||||
gifDrawable = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
val source = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
||||||
GifDrawable(context!!.contentResolver, Uri.parse(pathToLoad))
|
InputSource.UriSource(context!!.contentResolver, Uri.parse(pathToLoad))
|
||||||
} else {
|
} else {
|
||||||
GifDrawable(pathToLoad)
|
InputSource.FileSource(pathToLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFragmentVisible) {
|
view.photo_view.beGone()
|
||||||
gifDrawable!!.stop()
|
view.gif_view.beVisible()
|
||||||
}
|
view.gif_view.setInputSource(source)
|
||||||
|
|
||||||
view.photo_view.setImageDrawable(gifDrawable)
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
gifDrawable = null
|
|
||||||
loadBitmap()
|
loadBitmap()
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
gifDrawable = null
|
|
||||||
loadBitmap()
|
loadBitmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<pl.droidsonroids.gif.GifTextureView
|
||||||
|
android:id="@+id/gif_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
android:id="@+id/subsampling_view"
|
android:id="@+id/subsampling_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -45,8 +51,8 @@
|
||||||
android:id="@+id/photo_brightness_controller"
|
android:id="@+id/photo_brightness_controller"
|
||||||
android:layout_width="@dimen/media_side_slider_width"
|
android:layout_width="@dimen/media_side_slider_width"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentStart="true"/>
|
android:layout_alignParentLeft="true"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/slide_info"
|
android:id="@+id/slide_info"
|
||||||
|
@ -58,10 +64,10 @@
|
||||||
android:alpha="0"
|
android:alpha="0"
|
||||||
android:background="@drawable/black_rounded_background"
|
android:background="@drawable/black_rounded_background"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:paddingBottom="@dimen/medium_margin"
|
|
||||||
android:paddingLeft="@dimen/activity_margin"
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
android:paddingRight="@dimen/activity_margin"
|
|
||||||
android:paddingTop="@dimen/medium_margin"
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="@dimen/extra_big_text_size"/>
|
android:textSize="@dimen/extra_big_text_size"/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue