From 409085dd25daefc31b22216d7496995cc914256b Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 9 Aug 2014 07:20:00 -0700 Subject: [PATCH] cleanup: remove duplicate methods Conflicts: xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java --- .../org/eehouse/android/xw4/BTService.java | 2 +- .../eehouse/android/xw4/DispatchNotify.java | 2 +- .../android/xw4/GamesListActivity.java | 59 ++----------------- .../org/eehouse/android/xw4/MultiService.java | 2 +- .../org/eehouse/android/xw4/RelayService.java | 4 +- .../org/eehouse/android/xw4/SMSService.java | 2 +- 6 files changed, 11 insertions(+), 60 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java index ea99ca298..48aba6952 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -971,7 +971,7 @@ public class BTService extends XWService { private void postNotification( int gameID, int title, String body, long rowid ) { - Intent intent = GamesListActivity.makeGameIDIntent( this, gameID ); + Intent intent = GamesListDelegate.makeGameIDIntent( this, gameID ); Utils.postNotification( this, intent, R.string.new_btmove_title, body, (int)rowid ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java index 4514d4af8..5cee9c3dc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java @@ -40,7 +40,7 @@ public class DispatchNotify extends Activity { Uri data = getIntent().getData(); if ( null != data ) { // relay invite redirected URL case - GamesListActivity.openGame( this, data ); + GamesListDelegate.openGame( this, data ); } finish(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java index 9692e4f5c..a2182495b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java @@ -55,60 +55,11 @@ public class GamesListActivity extends XWListActivity { m_dlgt.onNewIntent( intent ); } - public static void onGameDictDownload( Context context, Intent intent ) + ////////////////////////////////////////////////////////////////////// + // GamesListDelegator interface + ////////////////////////////////////////////////////////////////////// + public void launchGame( long rowID, boolean invited ) { - intent.setClass( context, GamesListActivity.class ); - context.startActivity( intent ); - } - - private static Intent makeSelfIntent( Context context ) - { - Intent intent = new Intent( context, GamesListActivity.class ); - intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP - | Intent.FLAG_ACTIVITY_NEW_TASK ); - return intent; - } - - public static Intent makeRowidIntent( Context context, long rowid ) - { - Intent intent = makeSelfIntent( context ); - intent.putExtra( ROWID_EXTRA, rowid ); - return intent; - } - - public static Intent makeGameIDIntent( Context context, int gameID ) - { - Intent intent = makeSelfIntent( context ); - intent.putExtra( GAMEID_EXTRA, gameID ); - return intent; - } - - public static Intent makeRematchIntent( Context context, CurGameInfo gi, - long rowid ) - { - Intent intent = null; - - if ( CurGameInfo.DeviceRole.SERVER_STANDALONE == gi.serverRole ) { - intent = makeSelfIntent( context ) - .putExtra( REMATCH_ROWID_EXTRA, rowid ); - } else { - Utils.notImpl( context ); - } - - return intent; - } - - public static Intent makeAlertIntent( Context context, String msg ) - { - Intent intent = makeSelfIntent( context ); - intent.putExtra( ALERT_MSG, msg ); - return intent; - } - - public static void openGame( Context context, Uri data ) - { - Intent intent = makeSelfIntent( context ); - intent.setData( data ); - context.startActivity( intent ); + GameUtils.launchGame( this, rowID, invited ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java index e1707c6e0..5ac1b562a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MultiService.java @@ -172,7 +172,7 @@ public class MultiService { SMSService.onGameDictDownload( context, intent ); break; case OWNER_RELAY: - GamesListActivity.onGameDictDownload( context, intent ); + GamesListDelegate.onGameDictDownload( context, intent ); break; default: DbgUtils.logf( "unexpected OWNER" ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java index 049dd6ac9..fcf9e705c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java @@ -379,7 +379,7 @@ public class RelayService extends XWService private void setupNotification( long rowid ) { - Intent intent = GamesListActivity.makeRowidIntent( this, rowid ); + Intent intent = GamesListDelegate.makeRowidIntent( this, rowid ); String msg = LocUtils.getString( this, R.string.notify_body_fmt, GameUtils.getName( this, rowid ) ); Utils.postNotification( this, intent, R.string.notify_title, @@ -580,7 +580,7 @@ public class RelayService extends XWService break; case XWPDEV_ALERT: str = getVLIString( dis ); - Intent intent = GamesListActivity.makeAlertIntent( this, str ); + Intent intent = GamesListDelegate.makeAlertIntent( this, str ); Utils.postNotification( this, intent, R.string.relay_alert_title, str, str.hashCode() ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index e3a58e3e2..7903ba3b9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -789,7 +789,7 @@ public class SMSService extends XWService { private void postNotification( int gameID, int title, String body, long rowid ) { - Intent intent = GamesListActivity.makeGameIDIntent( this, gameID ); + Intent intent = GamesListDelegate.makeGameIDIntent( this, gameID ); Utils.postNotification( this, intent, title, body, (int)rowid ); }