Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): touchEnabled for ListView #13951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,22 @@ public Object handleEvent(String eventName, Object data, boolean fireItemClick)
final Object sourceObject = payload.containsKeyAndNotNull(TiC.EVENT_PROPERTY_SOURCE)
? payload.get(TiC.EVENT_PROPERTY_SOURCE) : this;
final TiViewProxy source = sourceObject instanceof TiViewProxy ? (TiViewProxy) sourceObject : this;
final KrollDict properties = getProperties();

final Object parent = getParent();
boolean sectionTouchEnabled = true;

if (parent instanceof ListSectionProxy) {
final ListSectionProxy section = (ListSectionProxy) parent;

// Include section specific properties.
payload.putIfAbsent(TiC.PROPERTY_SECTION, section);
payload.putIfAbsent(TiC.PROPERTY_SECTION_INDEX, listViewProxy.getIndexOfSection(section));
payload.putIfAbsent(TiC.PROPERTY_ITEM_INDEX, getIndexInSection());
sectionTouchEnabled = section.getProperties().optBoolean(TiC.PROPERTY_TOUCH_ENABLED, true);
}

final Object itemId = getProperties().get(TiC.PROPERTY_ITEM_ID);
final Object itemId = properties.get(TiC.PROPERTY_ITEM_ID);
if (itemId != null) {

// Include `itemId` if specified.
Expand All @@ -156,9 +160,12 @@ public Object handleEvent(String eventName, Object data, boolean fireItemClick)
}
}

final int accessoryType = getProperties().optInt(TiC.PROPERTY_ACCESSORY_TYPE,
final int accessoryType = properties.optInt(TiC.PROPERTY_ACCESSORY_TYPE,
UIModule.LIST_ACCESSORY_TYPE_NONE);
final boolean isAccessoryDetail = accessoryType == UIModule.LIST_ACCESSORY_TYPE_DETAIL;
final boolean touchEnabled = properties.optBoolean(TiC.PROPERTY_TOUCH_ENABLED, true);
final boolean listViewTouchEnabled = listViewProxy.getProperties()
.optBoolean(TiC.PROPERTY_TOUCH_ENABLED, true);

// If item is `LIST_ACCESSORY_TYPE_DETAIL` then `accessoryClicked` will be `true`.
payload.put(TiC.EVENT_PROPERTY_ACCESSORY_CLICKED, isAccessoryDetail);
Expand All @@ -167,7 +174,8 @@ public Object handleEvent(String eventName, Object data, boolean fireItemClick)
data = payload;

// Fire `itemclick` event on ListView.
if (fireItemClick && eventName.equals(TiC.EVENT_CLICK)) {
if (fireItemClick && eventName.equals(TiC.EVENT_CLICK) && touchEnabled
&& sectionTouchEnabled && listViewTouchEnabled) {
listViewProxy.fireSyncEvent(TiC.EVENT_ITEM_CLICK, data);
}
}
Expand Down
Loading