aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt28
-rw-r--r--docs/Changelog.md5
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml7
3 files changed, 33 insertions, 7 deletions
diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt
index 6369704..0c9f306 100644
--- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt
+++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt
@@ -23,6 +23,7 @@ import android.os.Build
import android.support.annotation.RequiresApi
import android.transition.TransitionInflater
import android.util.AttributeSet
+import android.view.MotionEvent
import android.view.View
import android.widget.FrameLayout
import ca.allanwang.kau.logging.KL
@@ -54,6 +55,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor(
private var totalDrag: Float = 0f
private var draggingDown = false
private var draggingUp = false
+ private var lastEvent = -1
private var callbacks: MutableList<ElasticDragDismissCallback> = mutableListOf()
@@ -95,6 +97,11 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor(
}
+ override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
+ lastEvent = ev.action
+ return super.onInterceptTouchEvent(ev)
+ }
+
override fun onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int): Boolean {
return nestedScrollAxes and View.SCROLL_AXIS_VERTICAL != 0
}
@@ -116,13 +123,20 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor(
if (Math.abs(totalDrag) >= dragDismissDistance) {
dispatchDismissCallback()
} else { // settle back to natural position
- animate()
- .translationY(0f)
- .scaleXY(1f)
- .setDuration(200L)
- .setInterpolator(AnimHolder.fastOutSlowInInterpolator(context))
- .setListener(null)
- .start()
+
+ if (lastEvent == MotionEvent.ACTION_DOWN) {
+ translationY = 0f
+ scaleXY = 1f
+ } else {
+ animate()
+ .translationY(0f)
+ .scaleXY(1f)
+ .setDuration(200L)
+ .setInterpolator(AnimHolder.fastOutSlowInInterpolator(context))
+ .setListener(null)
+ .start()
+ }
+
totalDrag = 0f
draggingUp = false
draggingDown = draggingUp
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 88fe4ff..88931e7 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1,5 +1,10 @@
# Changelog
+## v3.6.2
+* :core: Create more bundle utils to help with shared transition elements
+* :searchview: Add better encapsulation and use view location
+* :searchview: Add textClearedCallback
+
## v3.6.1
* :core: [Breaking] Removed private text field and introduced lazy logging functions
* :adapter: Improve library item layout
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index a4c4f95..09e5896 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -7,6 +7,13 @@
-->
+ <version title="v3.6.2" />
+ <item text=":core: Create more bundle utils to help with shared transition elements" />
+ <item text=":searchview: Add better encapsulation and use view location" />
+ <item text=":searchview: Add textClearedCallback" />
+ <item text="" />
+ <item text="" />
+
<version title="v3.6.1" />
<item text=":core: [Breaking] Removed private text field and introduced lazy logging functions" />
<item text=":adapter: Improve library item layout" />