aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-05 12:51:21 -0700
committerAllan Wang <me@allanwang.ca>2017-07-05 12:51:21 -0700
commit10e2ee9d4f105d9737b98b1caacf5e6ccb1c3c7d (patch)
tree81f2976a43b65a28c428b1ae60a62888e573a756 /core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
parent4e254b4b983b8531193c02852d2866a876d8cfcf (diff)
downloadkau-10e2ee9d4f105d9737b98b1caacf5e6ccb1c3c7d.tar.gz
kau-10e2ee9d4f105d9737b98b1caacf5e6ccb1c3c7d.tar.bz2
kau-10e2ee9d4f105d9737b98b1caacf5e6ccb1c3c7d.zip
Remap color dark and fix up swipe
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt66
1 files changed, 66 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
new file mode 100644
index 0000000..e9a872b
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
@@ -0,0 +1,66 @@
+package ca.allanwang.kau.swipe
+
+import android.app.Activity
+import android.graphics.Color
+import android.graphics.drawable.ColorDrawable
+import android.view.ViewGroup
+import ca.allanwang.kau.logging.KL
+
+/**
+ * Created by Mr.Jude on 2015/8/3.
+ * 每个滑动页面的管理
+ */
+class SwipeBackPage(activity: Activity) : SwipeBackPageContract by SwipeBackLayout(activity) {
+
+ var activity: Activity? = activity
+ var slider: RelativeSlider
+
+ /**
+ * initializing is the equivalent to onCreate
+ * since that is when the page is created
+ */
+ init {
+ activity.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
+ activity.window.decorView.setBackgroundColor(Color.TRANSPARENT)
+ swipeBackLayout.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
+ slider = RelativeSlider(this)
+ }
+
+ fun onPostCreate() {
+ handleLayout()
+ }
+
+ override var swipeEnabled: Boolean
+ get() = swipeBackLayout.swipeEnabled
+ set(value) {
+ swipeBackLayout.swipeEnabled = value
+ handleLayout()
+ }
+
+ private fun handleLayout() {
+ KL.d("Handle layout")
+ if (swipeEnabled) swipeBackLayout.attachToActivity(activity!!)
+ else swipeBackLayout.removeFromActivity(activity!!)
+ }
+
+
+ //触发关闭Activity百分比
+ fun setClosePercent(percent: Float): SwipeBackPage {
+ swipeBackLayout.scrollThreshold=percent
+ return this
+ }
+
+}
+
+interface SwipeBackPageContract {
+ var swipeEnabled: Boolean
+ var scrimColor:Int
+ val swipeBackLayout: SwipeBackLayout
+ var scrollThreshold:Float
+ var disallowIntercept:Boolean
+ fun setEdgeSize(swipeEdge: Int)
+ fun setEdgeSizePercent(swipeEdgePercent: Float)
+ fun addListener(listener: SwipeListener)
+ fun removeListener(listener: SwipeListener)
+ fun scrollToFinishActivity()
+}