refactor: new constructor for common case

This commit is contained in:
Eric House 2019-03-19 08:06:16 -07:00
parent 0728d06c4d
commit 97a3c3a2d8
5 changed files with 15 additions and 14 deletions

View file

@ -1213,8 +1213,8 @@ public class BoardDelegate extends DelegateBase
RequestCode.SMS_DATA_INVITE_RESULT );
} else if ( Perms23.anyBanned( m_activity, perms ) ) {
makeOkOnlyBuilder( R.string.sms_banned_ok_only )
.setActionPair(new ActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info ) )
.setActionPair(Action.PERMS_BANNED_INFO,
R.string.button_more_info )
.show();
}
break;
@ -2327,9 +2327,8 @@ public class BoardDelegate extends DelegateBase
DlgDelegate.ConfirmThenBuilder builder =
makeConfirmThenBuilder( explID, Action.DROP_SMS_ACTION );
if ( banned ) {
ActionPair pr = new ActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info );
builder.setActionPair( pr )
builder.setActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info )
.setNAKey( R.string.key_na_sms_banned )
;
}

View file

@ -174,8 +174,8 @@ public class ConnViaViewLayout extends LinearLayout {
DlgDelegate.DlgDelegateBuilder builder = 0 != keyID
? m_dlgDlgt.makeNotAgainBuilder( msgID, keyID )
: m_dlgDlgt.makeOkOnlyBuilder( msgID )
.setActionPair( new ActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info ) )
.setActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info )
;
builder.show();
}

View file

@ -197,6 +197,9 @@ public class DlgDelegate {
public DlgDelegateBuilder setActionPair( ActionPair pr )
{ m_actionPair = pr; return this; }
public DlgDelegateBuilder setActionPair( Action actn, int id )
{ return setActionPair( new ActionPair( actn, id ) ); }
abstract void show();
}

View file

@ -1074,8 +1074,8 @@ public class GamesListDelegate extends ListDelegateBase
R.string.not_again_nbsGamesOnUpgrade,
smsGameCount );
makeNotAgainBuilder( msg, R.string.key_notagain_nbsGamesOnUpgrade )
.setActionPair( new ActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info ) )
.setActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info )
.show();
}
}
@ -1997,12 +1997,11 @@ public class GamesListDelegate extends ListDelegateBase
if ( skipOffer ) {
handleNewGame( solo );
} else {
ActionPair pair = new ActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
R.string.set_pref );
makeNotAgainBuilder( R.string.not_again_hidenewgamebuttons,
R.string.key_notagain_hidenewgamebuttons,
Action.NEW_GAME_PRESSED )
.setActionPair( pair )
.setActionPair( Action.SET_HIDE_NEWGAME_BUTTONS,
R.string.set_pref )
.show();
}
}

View file

@ -120,8 +120,8 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
&& Perm.SEND_SMS.isBanned(activity) ) {
activity
.makeOkOnlyBuilder( R.string.sms_banned_ok_only )
.setActionPair(new ActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info ) )
.setActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info )
.show();
} else if ( ! XWPrefs.getNBSEnabled( context ) ) {
activity