Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28553] Android: Moving a ListView item into an empty section causes a crash

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2021-10-20T03:12:54.000+0000
Affected Version/sRelease 9.3.0
Fix Version/sRelease 10.2.0
ComponentsAndroid
LabelsListItem, ListView, android, move
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-10-12T19:25:03.000+0000
Updated2021-10-20T03:12:54.000+0000

Description

*Summary:* Moving a ListView item via edit mode and drag-and-drop will cause a crash if the ListItem is moved into an empty ListSection. *Steps to reproduce:*

Build and run the below on Android.

Tap and hold "Row 1".

Drag it into "Section 1".

Notice the app crashes.

const window = Ti.UI.createWindow();
const listView = Ti.UI.createListView({
	sections: [
		Ti.UI.createListSection({
			headerTitle: "Section 1",
		}),
		Ti.UI.createListSection({
			headerTitle: "Section 2",
			items: [{
				properties: {
					title: Row 1,
					canEdit: false,
					canMove: true,
				},
			}],
		}),
	],
	allowsSelectionDuringEditing: false,
	allowsMultipleSelectionDuringEditing: false,
	editing: true,
});
listView.addEventListener("move", (e) => {
	console.log(@@@ "move" event: ${JSON.stringify(e)});
});
window.add(listView);
window.open();
*Result:* App immediately crashes with the following exception when dragged into an empty section. You don't have to release your finger (ie: drop) for the crash to occur.
[ERROR] InputEventReceiver: Exception dispatching input event.
[ERROR] TiExceptionHandler: (main) [4739,4854] ti.modules.titanium.ui.widget.listview.ListViewProxy cannot be cast to ti.modules.titanium.ui.widget.listview.ListSectionProxy
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.listview.ListViewProxy.moveItem(ListViewProxy.java:186)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.listview.ItemTouchHandler.onMove(ItemTouchHandler.java:281)
[ERROR] TiExceptionHandler:     androidx.recyclerview.widget.ItemTouchHelper.moveIfNecessary(ItemTouchHelper.java:885)
[ERROR] TiExceptionHandler:     androidx.recyclerview.widget.ItemTouchHelper$2.onTouchEvent(ItemTouchHelper.java:389)
[ERROR] TiExceptionHandler:     androidx.recyclerview.widget.RecyclerView.dispatchToOnItemTouchListeners(RecyclerView.java:3259)
[ERROR] TiExceptionHandler:     androidx.recyclerview.widget.RecyclerView.onTouchEvent(RecyclerView.java:3421)
[ERROR] TiExceptionHandler:     android.view.View.dispatchTouchEvent(View.java:14309)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3112)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2785)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.listview.TiNestedRecyclerView.dispatchTouchEvent(TiNestedRecyclerView.java:109)
[ERROR] TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3118)

Comments

  1. Joshua Quick 2021-10-14

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/13120

JSON Source