Skip to content

Commit

Permalink
feat(android): add getScaledTouchSlop() to ListView (#11680)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27879
  • Loading branch information
m1ga authored Jul 6, 2020
1 parent ebae7bd commit 901f991
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import android.util.TypedValue;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
Expand All @@ -30,22 +29,16 @@
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutParams;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.RefreshControlProxy;
import ti.modules.titanium.ui.SearchBarProxy;
import ti.modules.titanium.ui.UIModule;
import ti.modules.titanium.ui.android.SearchViewProxy;
import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar;
import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar.OnSearchChangeListener;
import ti.modules.titanium.ui.widget.searchview.TiUISearchView;
import ti.modules.titanium.ui.widget.TiSwipeRefreshLayout;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.util.Pair;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.AbsListView;
Expand All @@ -55,6 +48,15 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import ti.modules.titanium.ui.RefreshControlProxy;
import ti.modules.titanium.ui.SearchBarProxy;
import ti.modules.titanium.ui.UIModule;
import ti.modules.titanium.ui.android.SearchViewProxy;
import ti.modules.titanium.ui.widget.TiSwipeRefreshLayout;
import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar;
import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar.OnSearchChangeListener;
import ti.modules.titanium.ui.widget.searchview.TiUISearchView;

public class TiListView extends TiUIView implements OnSearchChangeListener
{

Expand Down Expand Up @@ -403,7 +405,14 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
_firstVisibleItem = firstVisibleItem;
_visibleItemCount = visibleItemCount;
int scrolledOffset = listView.getVerticalScrollOffset();
if (scrolledOffset != mInitialScroll) {

ViewConfiguration viewConfiguration = ViewConfiguration.get(activity);
int scrollDamping = 0;
if (viewConfiguration != null) {
scrollDamping = viewConfiguration.getScaledTouchSlop();
}

if (Math.abs(mInitialScroll - scrolledOffset) > scrollDamping) {
if (scrolledOffset > mInitialScroll) {
scrollUp = 1;
} else {
Expand Down
12 changes: 6 additions & 6 deletions apidoc/Titanium/UI/ListView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ events:

- name: itemsselected
summary: |
Fired when user stops two-pan gesture interaction for selecting multiple items.
Fired when user stops two-pan gesture interaction for selecting multiple items.
It is used with <Titanium.UI.ListView.allowsMultipleSelectionInteraction>.
properties:
- name: selectedItems
Expand Down Expand Up @@ -744,9 +744,9 @@ properties:
- name: allowsMultipleSelectionInteraction
summary: Allows a two-finger pan gesture to automatically transition the table view into editing mode and start selecting rows.
description: |
Setting this property to true allows the user to start selecting multiple contiguous rows via a two-finger pan gesture.
If the table view is already in editing mode, the user can also select multiple rows via a one-finger pan gesture along
the edge of the table that contains editing controls (checkboxes). In order to support this behavior,
Setting this property to true allows the user to start selecting multiple contiguous rows via a two-finger pan gesture.
If the table view is already in editing mode, the user can also select multiple rows via a one-finger pan gesture along
the edge of the table that contains editing controls (checkboxes). In order to support this behavior,
you must also set <Titanium.UI.ListView.allowsMultipleSelectionDuringEditing> to true.
Once user interaction stops the <Titanium.UI.ListView.itemsselected> event is fired.
type: Boolean
Expand Down Expand Up @@ -1118,8 +1118,8 @@ properties:
- name: showSearchBarInNavBar
summary: A Boolean indicating whether search bar will be in navigation bar.
description: |
If you want to show the search bar in navigation bar, set this property `true` during creation.
Use the <Titanium.UI.Window.hidesSearchBarWhenScrolling> property to control the visibility of the
If you want to show the search bar in navigation bar, set this property `true` during creation.
Use the <Titanium.UI.Window.hidesSearchBarWhenScrolling> property to control the visibility of the
searchbar when scrolling.
type: Boolean
default: false
Expand Down

0 comments on commit 901f991

Please sign in to comment.