Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14526] Android: Picker Column- addRow method accepts unintended parameters

GitHub Issuen/a
TypeBug
PriorityLow
StatusIn Progress
ResolutionUnresolved
Affected Version/sRelease 3.1.2
Fix Version/sn/a
ComponentsAndroid
Labelsqe-3.1.2
ReporterPriya Agarwal
AssigneeUnknown
Created2013-07-11T11:59:37.000+0000
Updated2018-02-28T20:03:13.000+0000

Description

addRow method of PickerColumn as per documentation must be passed with parameter as a row object. Hence must give error if passed with unintended parameter. iOS gives error but android is not giving any error. Its not a Regression since it occurs in 3.1.1GA Steps to reproduce: 1. Copy the sample code given below in app.js of titanium mobile classic project. 2. Click on button with title "Add "Manny". Actual Result: Both ios and android behave differently. ios gives error."invalid type passed to function at app.js(line 93)" android does not gives error. Expected Result: Both ios and android must give error."invalid type passed to function"
var w = Ti.UI.createWindow({
    backgroundColor : 'white'
});
var status = Ti.UI.createLabel({
    bottom : '5dp',
    left : '5dp',
    right : '5dp',
    height : '40dp',
    textAlign : 'center',
    color:'black'
});
w.add(status);
 
function showStatus(s) {
    status.text = s;
}
 
var names = ['Joanie', 'Mickey', 'Jean-Pierre', 'Gustav', 'Raul', 'Mimi', 'Emily', 'Sandra', 'Carrie', 'Chachi'];
var verbs = ['loves', 'likes', 'visits', 'loathes', 'waves to', 'babysits', 'accompanies', 'teaches', 'announces', 'supports', 'knows', 'high-fives'];

 
var rows1 = [];
for (var i = 0; i < names.length; i++) {
    rows1.push(Ti.UI.createPickerRow({
        title : names[i]
    }));
}
 
var rows2 = [];
for ( i = 0; i < verbs.length; i++) {
    rows2.push(Ti.UI.createPickerRow({
        title : verbs[i]
    }));
}
 
var rows3 = [];
for ( i = (names.length - 1); i >= 0; i--) {
    rows3.push(Ti.UI.createPickerRow({
        title : names[i]
    }));
}
 
var column1 = Ti.UI.createPickerColumn({
    rows : rows1,
    font : {
        fontSize : "12"
    }
});
var column2 = Ti.UI.createPickerColumn({
    rows : rows2,
    font : {
        fontSize : "12"
    }
});
var column3 = Ti.UI.createPickerColumn({
    rows : rows3,
    font : {
        fontSize : "12"
    }
});
 
var picker = Ti.UI.createPicker({
    useSpinner : true,
    visibleItems : 7,
    type : Ti.UI.PICKER_TYPE_PLAIN,
    top : '150dp',
    height : '250dp',
    selectionIndicator: true,
    columns : [column1, column2, column3]
});
 
picker.addEventListener('change', function(e) {
    showStatus(e.selectedValue[0] + " " + e.selectedValue[1] + " " + e.selectedValue[2]);
});
 
w.add(picker);
 
var btnAdd = Ti.UI.createButton({
    left : '5dp',
    height : '40dp',
    top : '50dp',
    title : 'Add "Manny"'
});

btnAdd.addEventListener('click', function() {
    picker.columns[0].addRow(Ti.UI.createPickerRow({
        title : 'Test Manny'
    }));
    picker.columns[2].addRow(Ti.UI.createPickerRow({
        title : 'Test Manny'
    }));
   // It must give error on both ios and android
   picker.columns[1].addRow("something");
   
  if (Ti.Platform.osname != 'android') {

   picker.reloadColumn(picker.columns[0]);
   picker.reloadColumn(picker.columns[1]);
   picker.reloadColumn(picker.columns[2]);
  }
    
});
w.add(btnAdd);
w.open(); 

Comments

  1. Sunila 2013-08-05

    The input type is changed from Object to PickerRowProxy for addRow and removeRow https://github.com/appcelerator/titanium_mobile/pull/4539
  2. Hieu Pham 2013-09-06

    This is part of a bigger issue involving type checking. We'd need to discuss the parity on this.

JSON Source