Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2337] Android: picker setSelectedRow() method causes exception when third (bool) argument omitted

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-04-18T23:07:13.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0 M03
ComponentsAndroid
Labelsandroid, defect
ReporterPaul Dowsett
AssigneeDon Thorp
Created2011-04-15T03:17:05.000+0000
Updated2011-04-18T23:07:13.000+0000

Description

Environment:

ubuntu
android emulator
1_4_X (2 Nov)
1_5_X (6 Nov) - unable to test due to #2284'
Change line 19 of https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/picker_basic.js#L19"> picker_basic.js from:
picker.setSelectedRow(0,1,true);
to
picker.setSelectedRow(0,1);

Following exception will occur as soon as script is invoked:

  718            KrollContext  D  (kroll$5) [438,21753] eval file: app://examples/picker_basic.js
  718            KrollContext  E  (kroll$5) [348,22101] Error evaluating source: Wrapped java.lang.IllegalArgumentException: argument type mismatch (app://examples/picker_basic.js#18)
  718            KrollContext  E  org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalArgumentException: argument type mismatch (app://examples/picker_basic.js#18)
  718            KrollContext  E    at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Unknown Source)
  718            KrollContext  E    at org.appcelerator.titanium.kroll.KrollMethod.call(KrollMethod.java:109)
  718            KrollContext  E    at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
  718            KrollContext  E    at script(app://examples/picker_basic.js:18)
  718            KrollContext  E    at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
  718            KrollContext  E    at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
  718            KrollContext  E    at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
  718            KrollContext  E    at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
  718            KrollContext  E    at org.mozilla.javascript.InterpretedFunction.exec(Unknown Source)
  718            KrollContext  E    at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
  718            KrollContext  E    at org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:159)
  718            KrollContext  E    at org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:101)
  718            KrollContext  E    at android.os.Handler.dispatchMessage(Handler.java:95)
  718            KrollContext  E    at android.os.Looper.loop(Looper.java:123)
  718            KrollContext  E    at android.os.HandlerThread.run(HandlerThread.java:60)
  718            KrollContext  E  Caused by: java.lang.IllegalArgumentException: argument type mismatch
  718            KrollContext  E    at java.lang.reflect.Method.invokeNative(Native Method)
  718            KrollContext  E    at java.lang.reflect.Method.invoke(Method.java:521)
  718            KrollContext  E    at org.appcelerator.titanium.kroll.KrollMethod.call(KrollMethod.java:81)
  718            KrollContext  E    ... 12 more

Comments

  1. Bill Dawson 2011-04-15

    Failcase app.js:

       /*global Ti, Titanium, alert, JSON, setTimeout */
       Titanium.UI.setBackgroundColor('#000');
       var win = Titanium.UI.createWindow({  
           title:'Test',
           backgroundColor:'#fff',
           exitOnClose: true
       });
       win.open();
       
       var rows = [ Ti.UI.createPickerRow({title: 'Row 1'}), Ti.UI.createPickerRow({title: 'Row 2'}) ];
       var col = Ti.UI.createPickerColumn({ rows: rows });
       var picker = Ti.UI.createPicker( { columns: [ col ] } );
       win.add(picker);
       try {
           picker.setSelectedRow(0, 1);
       } catch(e) {
           alert('ERROR: ' + e);
       }
       

    If you see an error dialog, then you got the error. If you don't see the error dialog -- and if the row changes to Row 2 -- then you already have the fix for this.

  2. Bill Dawson 2011-04-15

    (from [591838a54d95778c634837374a9eed5298ca078a]) [#2337 state:fixed-in-qa] Make third arg of setSelectedRow optional like iOS, and update documentation to reflect that. Add unit test for it. Also add a few missing kroll annotations in the picker classes https://github.com/appcelerator/titanium_mobile/commit/591838a54d95778c634837374a9eed5298ca078a"> https://github.com/appcelerator/titanium_mobile/commit/591838a54d95...

  3. Matt Schmulen 2011-04-15

    Pass Titanium SDK version: 1.5.0 (12/01/10 09:30 ac7cfd8) drillbit test Android Sim 1.6/2.1

    android sim 1.6
    https://5111068499667359260-a-appcelerator-com-s-sites.googlegroups.com/a/appcelerator.com/android/screenshots/Screenshot2010-12-02at2.30.47AM.png?attachauth=ANoY7crKsfvMfdez3l27wnG_vOB0igXOd2AW8GVzP33R4KO4JNDSdg0wYeWx8OR34RLcQs0pfHxUiuoIsoVb5OClouqEI_CmWLRvbhD64WJg7KiGw4U6-679XjvXSqApaVCVyGqDjjfcHnceQepDqw0Wky44GDYZpomldZ1mAY0K0qqkI_BWhN2ETrFqCIPUjsjX6ZtLnuIJ5H1eYOg2P-M9OoYJKY6_TozjeA9AGUlbA3qoW-OTVh0%3D&;attredirects=0"> https://5111068499667359260-a-appcelerator-com-s-sites.googlegroups...

    android sim 2.1
    https://5111068499667359260-a-appcelerator-com-s-sites.googlegroups.com/a/appcelerator.com/android/screenshots/Screenshot2010-12-02at2.48.13AM.png?attachauth=ANoY7cqZMHs0_-0NFdd52s4sE13MK769EMBj1VEL9mkQdyPJ_1Lylg56ioZ3EKIhrSl7RMoVTCAI9cY4-jfDs6mOqdJOyP9mQrY28Zjh5vBQGQ6_377a21CU3cn9Al6-wi8damB2gpx5waY3FoILV9l9iIqifi6D5Jue3Rbig8yVLAwmls-q_qLFApWfmRmL9V7zuCx18cVF9-Om9uMmhzz7EKdEBj6cJ1MuzGF5vuOn6vTnexNmgr0%3D&;attredirects=0"> https://5111068499667359260-a-appcelerator-com-s-sites.googlegroups...

JSON Source