fix delegated dialogs to clear state before issuing dismiss callback

so that callback can set up another dialog without tripping an assert,
then move SMS invite dialog chaining from on-click callback to
on-dismiss.
This commit is contained in:
Eric House 2012-05-23 07:16:27 -07:00
parent 60e1d50f43
commit 2db02f9aa5
2 changed files with 17 additions and 6 deletions

View file

@ -440,11 +440,12 @@ public class DlgDelegate {
if ( null == m_cbkOnDismissLstnr ) { if ( null == m_cbkOnDismissLstnr ) {
m_cbkOnDismissLstnr = new DialogInterface.OnDismissListener() { m_cbkOnDismissLstnr = new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface di ) { public void onDismiss( DialogInterface di ) {
if ( SKIP_CALLBACK != m_cbckID ) { int cbckID = m_cbckID;
m_clickCallback.dlgButtonClicked( m_cbckID, m_cbckID = 0;
if ( SKIP_CALLBACK != cbckID ) {
m_clickCallback.dlgButtonClicked( cbckID,
DISMISS_BUTTON ); DISMISS_BUTTON );
} }
m_cbckID = 0;
} }
}; };
} }

View file

@ -64,6 +64,7 @@ public class SMSInviteActivity extends InviteActivity {
private ImageButton m_addButton; private ImageButton m_addButton;
private String m_pendingName; private String m_pendingName;
private String m_pendingNumber; private String m_pendingNumber;
private boolean m_immobileConfirmed;
@Override @Override
protected void onCreate( Bundle savedInstanceState ) protected void onCreate( Bundle savedInstanceState )
@ -191,20 +192,28 @@ public class SMSInviteActivity extends InviteActivity {
@Override @Override
public void dlgButtonClicked( int id, int which ) public void dlgButtonClicked( int id, int which )
{ {
if ( AlertDialog.BUTTON_POSITIVE == which ) { switch( which ) {
case AlertDialog.BUTTON_POSITIVE:
switch( id ) { switch( id ) {
case CLEAR_ACTION: case CLEAR_ACTION:
clearSelectedImpl(); clearSelectedImpl();
break; break;
case USE_IMMOBILE_ACTION: case USE_IMMOBILE_ACTION:
showConfirmThen( R.string.warn_unlimited, R.string.button_yes, m_immobileConfirmed = true;
POST_WARNING_ACTION );
break; break;
case POST_WARNING_ACTION: case POST_WARNING_ACTION:
addChecked( new PhoneRec( m_pendingName, m_pendingNumber ) ); addChecked( new PhoneRec( m_pendingName, m_pendingNumber ) );
saveAndRebuild(); saveAndRebuild();
break; break;
} }
break;
case DlgDelegate.DISMISS_BUTTON:
if ( USE_IMMOBILE_ACTION == id && m_immobileConfirmed ) {
showConfirmThen( R.string.warn_unlimited,
R.string.button_yes,
POST_WARNING_ACTION );
}
break;
} }
} }
@ -243,6 +252,7 @@ public class SMSInviteActivity extends InviteActivity {
showConfirmThen( R.string.warn_unlimited, R.string.button_yes, showConfirmThen( R.string.warn_unlimited, R.string.button_yes,
POST_WARNING_ACTION ); POST_WARNING_ACTION );
} else { } else {
m_immobileConfirmed = false;
String msg = Utils.format( this, R.string.warn_nomobilef, String msg = Utils.format( this, R.string.warn_nomobilef,
number, name ); number, name );
showConfirmThen( msg, R.string.button_yes, USE_IMMOBILE_ACTION ); showConfirmThen( msg, R.string.button_yes, USE_IMMOBILE_ACTION );