diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIDialog.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIDialog.java index c09eb03ba4a..710173ccd9c 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIDialog.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIDialog.java @@ -47,7 +47,7 @@ public ClickHandler(int id) } public void onClick(DialogInterface dialog, int which) { - handleEvent(result); + handleEvent(result, true); hide(null); } } @@ -134,7 +134,7 @@ private void processOptions(String[] optionText, int selectedIndex) @Override public void onClick(DialogInterface dialog, int which) { - handleEvent(which); + handleEvent(which, true); hide(null); } }); @@ -143,7 +143,7 @@ public void onClick(DialogInterface dialog, int which) @Override public void onClick(DialogInterface dialog, int which) { - handleEvent(which); + handleEvent(which, false); hide(null); } }); @@ -322,7 +322,8 @@ public void onCancel(DialogInterface dlg) ? TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_CANCEL)) : -1; Log.d(TAG, "onCancelListener called. Sending index: " + cancelIndex, Log.DEBUG_MODE); - handleEvent(cancelIndex); + // In case wew cancel the Dialog we should not overwrite the selectedIndex + handleEvent(cancelIndex, false); hide(null); } }); @@ -438,7 +439,7 @@ private void createBuilder() } } - public void handleEvent(int id) + public void handleEvent(int id, boolean saveSelectedIndex) { int cancelIndex = (proxy.hasProperty(TiC.PROPERTY_CANCEL)) ? TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_CANCEL)) : -1; @@ -452,8 +453,8 @@ public void handleEvent(int id) id &= ~BUTTON_MASK; } else { data.put(TiC.PROPERTY_BUTTON, false); - // If an option was selected and the user accepted it, update the proxy. - if (proxy.hasProperty(TiC.PROPERTY_OPTIONS)) { + // If an option was selected, the user accepted and we are showing radio buttons, update the proxy. + if (proxy.hasProperty(TiC.PROPERTY_OPTIONS) && saveSelectedIndex) { proxy.setProperty(TiC.PROPERTY_SELECTED_INDEX, id); } }