From 24440230bace47e2e3ab31f5c2aad697f3c454e7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 21 Sep 2018 15:21:04 -0700 Subject: [PATCH] refactor so startService can change (no behavior change yet) --- .../org/eehouse/android/xw4/BTService.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java index 20c0bad8d..98d851b16 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java @@ -227,7 +227,7 @@ public class BTService extends XWService { public static void startService( Context context ) { if ( XWApp.BTSUPPORTED ) { - context.startService( new Intent( context, BTService.class ) ); + startService( context, new Intent( context, BTService.class ) ); } } @@ -235,20 +235,20 @@ public class BTService extends XWService { { Intent intent = getIntentTo( context, BTAction.RADIO ); intent.putExtra( RADIO_KEY, cameOn ); - context.startService( intent ); + startService( context, intent ); } public static void clearDevices( Context context, String[] btAddrs ) { Intent intent = getIntentTo( context, BTAction.CLEAR ); intent.putExtra( CLEAR_KEY, btAddrs ); - context.startService( intent ); + startService( context, intent ); } public static void scan( Context context ) { Intent intent = getIntentTo( context, BTAction.SCAN ); - context.startService( intent ); + startService( context, intent ); } public static void pingHost( Context context, String hostAddr, int gameID ) @@ -257,7 +257,7 @@ public class BTService extends XWService { Intent intent = getIntentTo( context, BTAction.PINGHOST ); intent.putExtra( ADDR_KEY, hostAddr ); intent.putExtra( GAMEID_KEY, gameID ); - context.startService( intent ); + startService( context, intent ); } public static void inviteRemote( Context context, String btAddr, @@ -269,7 +269,7 @@ public class BTService extends XWService { intent.putExtra( GAMEDATA_KEY, nliData ); intent.putExtra( ADDR_KEY, btAddr ); - context.startService( intent ); + startService( context, intent ); } public static void gotGameViaNFC( Context context, NetLaunchInfo bli ) @@ -282,7 +282,7 @@ public class BTService extends XWService { intent.putExtra( BT_NAME_KEY, bli.btName ); intent.putExtra( BT_ADDRESS_KEY, bli.btAddress ); - context.startService( intent ); + startService( context, intent ); } public static int enqueueFor( Context context, byte[] buf, @@ -296,7 +296,7 @@ public class BTService extends XWService { intent.putExtra( MSG_KEY, buf ); intent.putExtra( ADDR_KEY, btAddr ); intent.putExtra( GAMEID_KEY, gameID ); - context.startService( intent ); + startService( context, intent ); nSent = buf.length; } @@ -312,6 +312,11 @@ public class BTService extends XWService { Intent intent = getIntentTo( context, BTAction.REMOVE ); intent.putExtra( GAMEID_KEY, gameID ); intent.putExtra( ADDR_KEY, btAddr ); + startService( context, intent ); + } + + private static void startService( Context context, Intent intent ) + { context.startService( intent ); }