DSpotDevelopers / declex

DecleX - Declarative Framework for Android, easier and faster coding.
Other
168 stars 25 forks source link

Switch case support for AlertDialog actions #113

Open z3phyro opened 7 years ago

z3phyro commented 7 years ago

AlertDialogs in Declex are really easy using

$AlertDialog().message(R.string.rate) .positiveButton(R.string.yes) .negativeButton(R.string.no) .neutralButton(R.string.ask);

and then handling the answer like if ($AlertDialog.PositiveButtonPressed){ // some code here } if ($AlertDialog.NegativeButtonPressed){ // some code here } if ($AlertDialog.NeutralButtonPressed){ // some code here }

but it could be nicer if the answer was handled like this: switch ($AlertDialog.Result){ case $AlertDialog.PositiveButtonPressed: // some code here break; case $AlertDialog.NegativeButtonPressed: // some code here break; case $AlertDialog.NeutralButtonPressed: // some code here break; }

smaugho commented 7 years ago

Agree, instead of $AlertDialog.Result I would call it $AlertDialog.Selector, and this selector. The values $AlertDialog.PositivieButtonPressed cannot be used because it is a boolean for the ifs-selectors, but probably an ENUM with similar name can be used.