@ -22,16 +22,9 @@ import android.content.Context
import android.graphics.drawable.Drawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.net.Uri
import android.os.Bundle
import android.os.Bundle
import android.util.Log
import android.view.*
import android.view.*
import android.widget.TextView
import androidx.exifinterface.media.ExifInterface
import com.bumptech.glide.Glide
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.target.Target
import com.bumptech.glide.request.transition.Transition
import com.bumptech.glide.request.transition.Transition
import com.github.piasy.biv.BigImageViewer
import com.github.piasy.biv.BigImageViewer
import com.github.piasy.biv.loader.ImageLoader
import com.github.piasy.biv.loader.ImageLoader
@ -69,15 +62,19 @@ class ViewImageFragment : ViewMediaFragment() {
private var previewUri = Uri . EMPTY
private var previewUri = Uri . EMPTY
private var showingPreview = false
private var showingPreview = false
override lateinit var descriptionView : TextView
override fun onAttach ( context : Context ) {
override fun onAttach ( context : Context ) {
super . onAttach ( context )
super . onAttach ( context )
photoActionsListener = context as PhotoActionsListener
photoActionsListener = context as PhotoActionsListener
}
}
override fun setupMediaView ( url : String , previewUrl : String ? ) {
override fun setupMediaView ( url : String ,
descriptionView = mediaDescription
previewUrl : String ? ,
description : String ? ,
showingDescription : Boolean ) {
photoView . transitionName = url
photoView . transitionName = url
mediaDescription . text = description
captionSheet . visible ( showingDescription )
startedTransition = false
startedTransition = false
uri = Uri . parse ( url )
uri = Uri . parse ( url )
if ( previewUrl != null && ! previewUrl . equals ( url ) ) {
if ( previewUrl != null && ! previewUrl . equals ( url ) ) {
@ -91,8 +88,6 @@ class ViewImageFragment : ViewMediaFragment() {
return inflater . inflate ( R . layout . fragment _view _image , container , false )
return inflater . inflate ( R . layout . fragment _view _image , container , false )
}
}
private lateinit var gestureDetector : GestureDetector
private val imageOnTouchListener = object : View . OnTouchListener {
private val imageOnTouchListener = object : View . OnTouchListener {
private var lastY = 0.0f
private var lastY = 0.0f
private var swipeStartedWithOneFinger = false
private var swipeStartedWithOneFinger = false
@ -100,7 +95,6 @@ class ViewImageFragment : ViewMediaFragment() {
override fun onTouch ( v : View , event : MotionEvent ) : Boolean {
override fun onTouch ( v : View , event : MotionEvent ) : Boolean {
// This part is for scaling/translating on vertical move.
// This part is for scaling/translating on vertical move.
// We use raw coordinates to get the correct ones during scaling
// We use raw coordinates to get the correct ones during scaling
gestureDetector . onTouchEvent ( event )
if ( event . pointerCount != 1 ) {
if ( event . pointerCount != 1 ) {
onGestureEnd ( )
onGestureEnd ( )
@ -143,13 +137,6 @@ class ViewImageFragment : ViewMediaFragment() {
override fun onViewCreated ( view : View , savedInstanceState : Bundle ? ) {
override fun onViewCreated ( view : View , savedInstanceState : Bundle ? ) {
super . onViewCreated ( view , savedInstanceState )
super . onViewCreated ( view , savedInstanceState )
gestureDetector = GestureDetector ( requireContext ( ) , object : GestureDetector . SimpleOnGestureListener ( ) {
override fun onSingleTapConfirmed ( e : MotionEvent ? ) : Boolean {
onMediaTap ( )
return true
}
} )
photoView . setImageLoaderCallback ( imageLoaderCallback )
photoView . setImageLoaderCallback ( imageLoaderCallback )
photoView . setImageViewFactory ( GlideImageViewFactory ( ) )
photoView . setImageViewFactory ( GlideImageViewFactory ( ) )
@ -190,10 +177,10 @@ class ViewImageFragment : ViewMediaFragment() {
}
}
isDescriptionVisible = showingDescription && visible
isDescriptionVisible = showingDescription && visible
val alpha = if ( isDescriptionVisible ) 1.0f else 0.0f
val alpha = if ( isDescriptionVisible ) 1.0f else 0.0f
descriptionView . animate ( ) . alpha ( alpha )
captionSheet . animate ( ) . alpha ( alpha )
. setListener ( object : AnimatorListenerAdapter ( ) {
. setListener ( object : AnimatorListenerAdapter ( ) {
override fun onAnimationEnd ( animation : Animator ) {
override fun onAnimationEnd ( animation : Animator ) {
descriptionView . visible ( isDescriptionVisible )
captionSheet . visible ( isDescriptionVisible )
animation . removeListener ( this )
animation . removeListener ( this )
}
}
} )
} )