diff options
author | Sergei Kozelko <KozelkoS@yandex.ru> | 2022-10-22 06:37:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-22 06:37:31 +0000 |
commit | 5e3eaafe268fc64e8c7d92187e6c2447addc410d (patch) | |
tree | 5f2f1a6aa77d1811083f95e32893d6b27384630d /app/src/main/res/layout/adapter_table_block.xml | |
parent | d11fb884c26c739e9e919ec98c1a0990f0953c93 (diff) | |
download | infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.tar infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.tar.gz infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.tar.bz2 infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.tar.lz infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.tar.xz infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.tar.zst infinity-for-reddit-5e3eaafe268fc64e8c7d92187e6c2447addc410d.zip |
Add view that can lock swipe-to-close gesture (#1140)
Slidr works by adding its own view in the hierarchy and listening to touch
events in `onInterceptTouchEvent`. Once it detects movement in the correct
direction, it returns `true` and handles all the events itself.
Adding scrollable view detection to Slidr would solve the problem, but it is
not possible and would probably have performance impact.
Fortunately Slidr does not intercept the very first event, which is
ACTION_DOWN, and it reaches scrollable view. So the scrollable view itself can
decide if it should disallow the swipe.
This also has a performance benefit over `OnScrollChangedListener` because
the listener is triggered for every scroll of every view even if the child we
are interested in did not scroll. On the other hand `on(Intercept)TouchEvent`
is triggered only when the view is touched.
There is a possibility that swipe won't be unlocked if view never receives
ACTION_UP or ACTION_CANCEL. However the docs say nothing about the probability
of this happening. Anyways, one possible solution is to post a runnable that
will unlock swipe soon after locking.
Diffstat (limited to 'app/src/main/res/layout/adapter_table_block.xml')
-rw-r--r-- | app/src/main/res/layout/adapter_table_block.xml | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/src/main/res/layout/adapter_table_block.xml b/app/src/main/res/layout/adapter_table_block.xml index ab8ddfb1..a4adce5f 100644 --- a/app/src/main/res/layout/adapter_table_block.xml +++ b/app/src/main/res/layout/adapter_table_block.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" +<ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" @@ -12,4 +13,4 @@ android:layout_height="wrap_content" android:stretchColumns="*" /> -</HorizontalScrollView>
\ No newline at end of file +</ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView> |