From b10aa02cf43a0aad42161ab8d0193f28ce3d0457 Mon Sep 17 00:00:00 2001 From: Christian Waldmann Date: Tue, 12 May 2015 16:20:03 +0200 Subject: [PATCH 1/2] Fix crash on Android when no selectedIndex was found --- controllers/widget.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/controllers/widget.js b/controllers/widget.js index 478de7d..609bd3b 100644 --- a/controllers/widget.js +++ b/controllers/widget.js @@ -71,7 +71,8 @@ else { * Generate and populate the optionsDialog. */ function populateOptionsDialog() { - var selectedIndex = undefined; + var selectedIndex; + var options; // Convert the object into array pairs. pickerValueArray = _.pairs(args.pickerValues[0]); @@ -87,12 +88,18 @@ function populateOptionsDialog() { selectedIndex = getKeyIndexFromPairs(pickerValueArray, args.selectedValues[0]); } - // Create an options dialog. - optionsDialog = Ti.UI.createOptionDialog({ + options = { options: pickerData, - buttonNames: ['Cancel'], - selectedIndex: selectedIndex - }); + buttonNames: ['Cancel'] + }; + + + if(selectedIndex !== null) { + options.selectedIndex = selectedIndex; + } + + // Create an options dialog. + optionsDialog = Ti.UI.createOptionDialog(options); optionsDialog.show(); optionsDialog.addEventListener('click', done); } From fd5014df989e7abf615b0a1f0ae3dc1ec00778b2 Mon Sep 17 00:00:00 2001 From: Christian Waldmann Date: Tue, 12 May 2015 16:21:51 +0200 Subject: [PATCH 2/2] Fix wrong selectedIndex when key === 0 --- controllers/widget.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/widget.js b/controllers/widget.js index 609bd3b..11d9035 100644 --- a/controllers/widget.js +++ b/controllers/widget.js @@ -207,7 +207,11 @@ function getSelectedRowTitle(index) { */ function getKeyIndexFromPairs(pairs, key) { pairs = pairs || []; - key = key || null; + + if(typeof key === 'undefined') { + key = null; + } + var rowIndex = null; // Determine index.