Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14890] Android: Ti.UI.PickerColumn exception when calling removeRow and useSpinner is true

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-08-19T22:37:45.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 17, 2013 Sprint 17 API, Release 3.2.0
ComponentsAndroid
Labelsmodule_picker, qe-testadded
ReporterDavide Cassenti
AssigneeBiju pm
Created2013-08-15T19:35:27.000+0000
Updated2013-10-10T11:30:05.000+0000

Description

Problem description

When removing columns from a picker, if useSpinner is set to true, the application crashes

Code to reproduce

Just click the remove button in the app:
var win = Ti.UI.createWindow({
  layout: 'vertical'
});

var picker = Ti.UI.createPicker({
  useSpinner: true
});

var fruit = [ 'Bananas', 'Strawberries', 'Mangos', 'Grapes' ];
var column1 = Ti.UI.createPickerColumn();

for(var i=0, ilen=fruit.length; i<ilen; i++){
  var row = Ti.UI.createPickerRow({title: fruit[i]});
  column1.addRow(row);
}

picker.add([column1]);
win.add(picker);
win.open();

var btn = Ti.UI.createButton({
	title: "Remove columns"
});
btn.addEventListener('click', function() {
	var _col = picker.columns[0];
    var len = _col.rowCount;
    for(var x = len-1; x >= 0; x-- ){
        var _row = _col.rows[x];
        _col.removeRow(_row);
    }
});
win.add(btn);

Error log

E/TiApplication(21214): java.lang.NullPointerException: storage == null
E/TiApplication(21214): 	at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
E/TiApplication(21214): 	at java.util.Arrays.asList(Arrays.java:154)
E/TiApplication(21214): 	at ti.modules.titanium.ui.widget.picker.TextWheelAdapter.<init>(TextWheelAdapter.java:28)
E/TiApplication(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.refreshNativeView(TiUISpinnerColumn.java:180)
E/TiApplication(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinner.refreshColumn(TiUISpinner.java:63)
E/TiApplication(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinner.refreshColumn(TiUISpinner.java:56)
E/TiApplication(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinner.onColumnModelChanged(TiUISpinner.java:99)
E/TiApplication(21214): 	at ti.modules.titanium.ui.PickerProxy.handleFireColumnModelChange(PickerProxy.java:706)
E/TiApplication(21214): 	at ti.modules.titanium.ui.PickerProxy.fireColumnModelChange(PickerProxy.java:694)
E/TiApplication(21214): 	at ti.modules.titanium.ui.PickerProxy.rowRemoved(PickerProxy.java:765)
E/TiApplication(21214): 	at ti.modules.titanium.ui.PickerColumnProxy.handleRemoveRow(PickerColumnProxy.java:160)
E/TiApplication(21214): 	at ti.modules.titanium.ui.PickerColumnProxy.handleMessage(PickerColumnProxy.java:76)
E/TiApplication(21214): 	at android.os.Handler.dispatchMessage(Handler.java:95)
E/TiApplication(21214): 	at android.os.Looper.loop(Looper.java:137)
E/TiApplication(21214): 	at android.app.ActivityThread.main(ActivityThread.java:5103)
E/TiApplication(21214): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication(21214): 	at java.lang.reflect.Method.invoke(Method.java:525)
E/TiApplication(21214): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
E/TiApplication(21214): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/TiApplication(21214): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(21214): FATAL EXCEPTION: main
E/AndroidRuntime(21214): java.lang.NullPointerException: storage == null
E/AndroidRuntime(21214): 	at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
E/AndroidRuntime(21214): 	at java.util.Arrays.asList(Arrays.java:154)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.widget.picker.TextWheelAdapter.<init>(TextWheelAdapter.java:28)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.refreshNativeView(TiUISpinnerColumn.java:180)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinner.refreshColumn(TiUISpinner.java:63)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinner.refreshColumn(TiUISpinner.java:56)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.widget.picker.TiUISpinner.onColumnModelChanged(TiUISpinner.java:99)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.PickerProxy.handleFireColumnModelChange(PickerProxy.java:706)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.PickerProxy.fireColumnModelChange(PickerProxy.java:694)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.PickerProxy.rowRemoved(PickerProxy.java:765)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.PickerColumnProxy.handleRemoveRow(PickerColumnProxy.java:160)
E/AndroidRuntime(21214): 	at ti.modules.titanium.ui.PickerColumnProxy.handleMessage(PickerColumnProxy.java:76)
E/AndroidRuntime(21214): 	at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(21214): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(21214): 	at android.app.ActivityThread.main(ActivityThread.java:5103)
E/AndroidRuntime(21214): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(21214): 	at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime(21214): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
E/AndroidRuntime(21214): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(21214): 	at dalvik.system.NativeStart.main(Native Method)

Comments

  1. Biju pm 2013-08-16

    PR:- https://github.com/appcelerator/titanium_mobile/pull/4576
  2. Anshu Mittal 2013-10-10

    Verified fix on: Appc-Studio: 3.2.0.201310100354 Sdk:3.2.0.v20131009134844 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.0.3 Device:Google Nexus 7(v4.3) Xcode: 5

JSON Source