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

View file

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

View file

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

View file

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

View file

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