[AC-6670] Android: Crash when scolling a ListView with a headerView
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2021-02-01T16:34:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Michael Gangolf |
Assignee | Abir Mukherjee |
Created | 2021-01-29T18:05:57.000+0000 |
Updated | 2021-02-01T16:34:52.000+0000 |
Description
If the first element of a ListView is not a section but a headerView it will crash when you start scrolling (SDK 9.3.1.GA)
*Error (shortened):*
[ERROR] InputEventReceiver: Exception dispatching input event.
[ERROR] TiExceptionHandler: (main) [19207,19325] 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.TiListView.generateScrollPayload(TiListView.java:263)
[ERROR] TiExceptionHandler: ti.modules.titanium.ui.widget.listview.TiListView$1.onScrolled(TiListView.java:98)
[ERROR] TiExceptionHandler: androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:5173)
[ERROR] TiExceptionHandler: androidx.recyclerview.widget.RecyclerView.scrollByInternal(RecyclerView.java:1971)
[ERROR] TiExceptionHandler: androidx.recyclerview.widget.RecyclerView.onTouchEvent(RecyclerView.java:3391)
*Example*
var win = Ti.UI.createWindow({ backgroundColor: 'white' });
var headerView = Ti.UI.createView({ height: Ti.UI.SIZE, width: Ti.UI.FILL, backgroundColor:"#444"});
var headerLabel = Ti.UI.createLabel({ height:Ti.UI.SIZE, width: Ti.UI.FILL, left: '15dp', right: '15dp', top: '15dp', color: 'black', text: 'Demo text'});
headerView.add(headerLabel);
var listView = Ti.UI.createListView({height: Ti.UI.FILL,top: 0,headerView: headerView});
var sections = [];
var fruitDataSet = [
{ properties: { title: 'Apple', color: 'black' } },
{ properties: { title: 'Banana', color: 'black' } },
];
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits', items: fruitDataSet });
sections.push(fruitSection);
var vegDataSet = [
{ properties: { title: 'Carrots', color: 'black' } },
{ properties: { title: 'Potatoes', color: 'black' } },
];
var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables', items: vegDataSet });
sections.push(vegSection);
var fishDataSet = [
{ properties: { title: 'Cod', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
{ properties: { title: 'Haddock', color: 'black' } },
];
var fishSection = Ti.UI.createListSection({ headerTitle: 'Fish', items: fishDataSet });
sections.push(fishSection);
listView.sections = sections;
listView.addEventListener("scrollend",function(e){console.log(e.firstVisibleItemIndex)});
win.add(listView);
win.open();
*Setup:*
Pixel 4, Android 11
Titanium SDK 9.3.1.GA
PR: https://github.com/appcelerator/titanium_mobile/pull/12423