protected void didProcessProperties() { if ((mProcessUpdateFlags & TIFLAG_NEEDS_OPTIONS) != 0) { clearDialog(); getBuilder().setView(null); String[] optionText = TiConvert.toStringArray(proxy.getProperty(TiC.PROPERTY_OPTIONS)); int selectedIndex = TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_SELECTED_INDEX), -1); if (selectedIndex >= optionText.length) { selectedIndex = -1; } processOptions(optionText, selectedIndex); mProcessUpdateFlags &= ~TIFLAG_NEEDS_OPTIONS; } super.didProcessProperties(); }
@Override public void propertySet(String key, Object newValue, Object oldValue, boolean changedProperty) { AlertDialog dialog = (AlertDialog) dialogWrapper.getDialog(); if (key.startsWith(TiC.PROPERTY_ACCESSIBILITY_PREFIX)) { if (dialog != null) { ListView listView = dialog.getListView(); if (listView != null) { if (key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) { int importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO; if (newValue != null && TiConvert.toBoolean(newValue)) { importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO; } ViewCompat.setImportantForAccessibility(listView, importance); } else { listView.setContentDescription(composeContentDescription()); } } } return; } switch (key) { case TiC.PROPERTY_TITLE: if (dialog != null) { dialog.setTitle(Html.fromHtml((String) newValue)); } else { getBuilder().setTitle(Html.fromHtml(TiConvert.toString(newValue))); } break; case TiC.PROPERTY_MESSAGE: if (dialog != null) { dialog.setMessage(Html.fromHtml((String) newValue)); } else { getBuilder().setMessage(Html.fromHtml(TiConvert.toString(newValue))); } break; case TiC.PROPERTY_BUTTON_NAMES: clearDialog(); processButtons(TiConvert.toStringArray(newValue)); break; case TiC.PROPERTY_OK: clearDialog(); processButtons(new String[] {TiConvert.toString(newValue)}); break; case TiC.PROPERTY_CUSTOM_VIEW: clearDialog(); processView(newValue); break; case TiC.PROPERTY_PERSISTENT: dialogWrapper.setPersistent(TiConvert.toBoolean(newValue)); break; case TiC.PROPERTY_CANCEL: cancelIndex = TiConvert.toInt(newValue, -1); break; case TiC.PROPERTY_OPTIONS: { mProcessUpdateFlags |= TIFLAG_NEEDS_OPTIONS; break; } case TiC.PROPERTY_SELECTED_INDEX: { mProcessUpdateFlags |= TIFLAG_NEEDS_OPTIONS; break; } case TiC.PROPERTY_HIDE_ON_CLICK: hideOnClick = TiConvert.toBoolean(newValue); if (dialog != null) { dialog.setCancelable(hideOnClick); } break; case TiC.PROPERTY_TAP_OUT_DISMISS: tapToDismiss = TiConvert.toBoolean(newValue); if (dialog != null) { dialog.setCanceledOnTouchOutside(tapToDismiss); } break; default: super.propertySet(key, newValue, oldValue, changedProperty); break; } }
public String[] getStringArray(String key) { return TiConvert.toStringArray((Object[]) get(key)); }