From 97a3c3a2d83d353262c777ee5595921c2330a3d4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 19 Mar 2019 08:06:16 -0700 Subject: [PATCH] refactor: new constructor for common case --- .../main/java/org/eehouse/android/xw4/BoardDelegate.java | 9 ++++----- .../java/org/eehouse/android/xw4/ConnViaViewLayout.java | 4 ++-- .../main/java/org/eehouse/android/xw4/DlgDelegate.java | 3 +++ .../java/org/eehouse/android/xw4/GamesListDelegate.java | 9 ++++----- .../java/org/eehouse/android/xw4/InviteChoicesAlert.java | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 080c2d722..e295f27b9 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -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 ) ; } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java index 4d1ff521e..b2d2f6c15 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java @@ -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(); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java index 7265c074d..7ef665918 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java @@ -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(); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index 74de390d9..9063a66a2 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -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(); } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java index bc5d65c5e..afd13ae2d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InviteChoicesAlert.java @@ -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