Skip to content

Commit

Permalink
Fix for issue MobiDevelop#21. splitterTouchSlop now works even when c…
Browse files Browse the repository at this point in the history
…hildren are clickable
  • Loading branch information
Rubén Viguera Marañón committed Mar 4, 2020
1 parent 8e191ed commit 6f1fa0d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

<com.mobidevelop.spl.widget.SplitPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<com.mobidevelop.spl.widget.SplitPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:spl="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
spl:orientation="horizontal"
spl:splitterSize="4dip"
spl:splitterPosition="33%"
spl:paneSizeMin="48dip"
spl:splitterBackground="@drawable/splitter_bg_h"
spl:splitterDraggingBackground="#88000000"
spl:paneSizeMin="48dip">
spl:splitterPosition="33%"
spl:splitterSize="4dip"
spl:splitterTouchSlop="48dp">

<TextView
android:id="@+id/first"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="@string/hello_world" />

<TextView
android:id="@+id/second"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="@string/hello_world" />

</com.mobidevelop.spl.widget.SplitPaneLayout>
15 changes: 9 additions & 6 deletions split-pane-layout-demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

<com.mobidevelop.spl.widget.SplitPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<com.mobidevelop.spl.widget.SplitPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:spl="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
spl:orientation="vertical"
spl:splitterSize="4dip"
spl:splitterPosition="50%"
spl:paneSizeMin="48dip"
spl:splitterBackground="@drawable/splitter_bg_v"
spl:splitterDraggingBackground="#88000000"
spl:paneSizeMin="48dip">
spl:splitterPosition="50%"
spl:splitterSize="4dip"
spl:splitterTouchSlop="48dp">

<TextView
android:id="@+id/first"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="@string/hello_world" />

<TextView
android:id="@+id/second"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="@string/hello_world" />

</com.mobidevelop.spl.widget.SplitPaneLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ class SplitPaneLayout : ViewGroup {
return super.onKeyDown(keyCode, event)
}

override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
if (isSplitterMovable) {
val x = event.x.toInt()
val y = event.y.toInt()
return if (event.action == MotionEvent.ACTION_DOWN)
(mSplitterTouchBounds.contains(x, y))
else false
}
return false
}

override fun onTouchEvent(event: MotionEvent): Boolean {
if (isSplitterMovable) {
val x = event.x.toInt()
Expand Down

0 comments on commit 6f1fa0d

Please sign in to comment.