Skip to content

Commit

Permalink
Fix shared elements bug
Browse files Browse the repository at this point in the history
  • Loading branch information
igreenwood committed Jun 27, 2020
1 parent 51848ce commit ecaf432
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions loupe-library/src/main/java/com/igreenwood/loupe/Loupe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class Loupe(imageView: ImageView, container: ViewGroup) : View.OnTouchListener,

init {
container.apply {
background.alpha = 255
setOnTouchListener(this@Loupe)
addOnLayoutChangeListener(this@Loupe)
scaleGestureDetector = ScaleGestureDetector(context, onScaleGestureListener)
Expand All @@ -219,7 +220,12 @@ class Loupe(imageView: ImageView, container: ViewGroup) : View.OnTouchListener,
resources.displayMetrics
)
}
imageView.scaleType = ImageView.ScaleType.MATRIX
imageView.apply {
imageMatrix = null
y = 0f
animate().cancel()
scaleType = ImageView.ScaleType.MATRIX
}
}

private var imageViewRef: WeakReference<ImageView> = WeakReference(imageView)
Expand Down Expand Up @@ -902,15 +908,9 @@ class Loupe(imageView: ImageView, container: ViewGroup) : View.OnTouchListener,
}

private fun cleanup() {
imageViewRef.get()?.apply {
imageMatrix = null
y = 0f
animate().cancel()
}
containerRef.get()?.apply {
setOnTouchListener(null)
removeOnLayoutChangeListener(null)
visibility = View.INVISIBLE
}
imageViewRef.clear()
containerRef.clear()
Expand Down

0 comments on commit ecaf432

Please sign in to comment.