Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28555] Android: Moving a TableView row into an empty section or header/footer causes a crashes

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2021-10-20T03:13:12.000+0000
Affected Version/sRelease 9.3.0
Fix Version/sRelease 10.2.0
ComponentsAndroid
LabelsTableView, android, editing, move, parity
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-10-14T01:20:47.000+0000
Updated2021-10-20T03:13:12.000+0000

Description

*Summary:* Moving a TableView row via edit mode into an empty section or a header/footer title will cause a crash. *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 tableView = Ti.UI.createTableView({
	data: [
		Ti.UI.createTableViewSection({ headerTitle: "Section 1" }),
		Ti.UI.createTableViewSection({ headerTitle: "Section 2" }),
	],
	allowsSelectionDuringEditing: false,
	allowsMultipleSelectionDuringEditing: false,
	editing: true,
	headerTitle: "Header Title",
	footerTitle: "Footer Title",
});
tableView.sections[1].add(Ti.UI.createTableViewRow({ title: "Row 1", editable: false, moveable: true }));
tableView.addEventListener("move", (e) => {
	const data = {
		sectionTitle: e.section.headerTitle,
		rowTitle: e.row.title,
		index: e.index,
	};
	console.log(@@@ "move" event: ${JSON.stringify(data)});
});
window.add(tableView);
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) [517745,517850] Index: -1, Size: 0
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     java.util.ArrayList.add(ArrayList.java:483)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TableViewSectionProxy.add(TableViewSectionProxy.java:59)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TableViewProxy.moveItem(TableViewProxy.java:264)
[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