Skip to content
Browse files

-- only try and send updated prefs to service if it's instantiated

  • Loading branch information...
1 parent 4f63359 commit 0b6890986f7dfb759a5347f7a3e7b6faee410075 @zeitkunst committed Aug 23, 2011
Showing with 24 additions and 12 deletions.
  1. +24 −12 src/net/fluidnexus/FluidNexusAndroid/MainActivity.java
View
36 src/net/fluidnexus/FluidNexusAndroid/MainActivity.java
@@ -777,8 +777,10 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
msg.arg1 = (prefs.getBoolean("enableBluetoothServicePref", false))? 1 : 0;
msg.arg2 = Integer.parseInt(prefs.getString("bluetoothScanFrequency", "300"));
msg.replyTo = messenger;
- networkService.send(msg);
- enableBluetoothServicePref = tmp;
+ if (networkService != null) {
+ networkService.send(msg);
+ enableBluetoothServicePref = tmp;
+ }
} catch (RemoteException e) {
log.error("Unable to send MSG_BLUETOOTH_ENABLED");
}
@@ -790,8 +792,10 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
msg.arg1 = (prefs.getBoolean("enableZeroconfServicePref", false))? 1 : 0;
msg.arg2 = Integer.parseInt(prefs.getString("zeroconfScanFrequency", "300"));
msg.replyTo = messenger;
- networkService.send(msg);
- enableZeroconfServicePref = tmp;
+ if (networkService != null) {
+ networkService.send(msg);
+ enableZeroconfServicePref = tmp;
+ }
} catch (RemoteException e) {
log.error("Unable to send MSG_ZEROCONF_ENABLED");
}
@@ -805,8 +809,10 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
// Add preference for this
msg.arg2 = Integer.parseInt(prefs.getString("nexusScanFrequency", "300"));
msg.replyTo = messenger;
- networkService.send(msg);
- enableNexusServicePref = tmp;
+ if (networkService != null) {
+ networkService.send(msg);
+ enableNexusServicePref = tmp;
+ }
} catch (RemoteException e) {
log.error("Unable to send MSG_NEXUS_ENABLED");
}
@@ -815,8 +821,9 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
Message msg = Message.obtain(null, NetworkService.MSG_BLUETOOTH_SCAN_FREQUENCY);
msg.arg1 = Integer.parseInt(prefs.getString("bluetoothScanFrequency", "300"));
msg.replyTo = messenger;
- networkService.send(msg);
-
+ if (networkService != null) {
+ networkService.send(msg);
+ }
} catch (RemoteException e) {
log.error("Unable to send scan frequency message: " + e);
}
@@ -825,7 +832,9 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
Message msg = Message.obtain(null, NetworkService.MSG_BLUETOOTH_BONDED_ONLY_FLAG);
msg.arg1 = (prefs.getBoolean("bluetoothBondedOnlyFlag", true) ? 1:0);
msg.replyTo = messenger;
- networkService.send(msg);
+ if (networkService != null) {
+ networkService.send(msg);
+ }
} catch (RemoteException e) {
log.error("Unable to send bonded only flag message: " + e);
}
@@ -834,8 +843,9 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
Message msg = Message.obtain(null, NetworkService.MSG_ZEROCONF_SCAN_FREQUENCY);
msg.arg1 = Integer.parseInt(prefs.getString("zeroconfScanFrequency", "300"));
msg.replyTo = messenger;
- networkService.send(msg);
-
+ if (networkService != null) {
+ networkService.send(msg);
+ }
} catch (RemoteException e) {
log.error("Unable to send scan frequency message: " + e);
}
@@ -851,7 +861,9 @@ public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
Message msg = Message.obtain(null, NetworkService.MSG_SEND_BLACKLISTED);
msg.arg1 = (prefs.getBoolean("sendBlacklistPref", false) ? 1:0);
msg.replyTo = messenger;
- networkService.send(msg);
+ if (networkService != null) {
+ networkService.send(msg);
+ }
} catch (RemoteException e) {
log.error("Unable to send bonded only flag message: " + e);
}

0 comments on commit 0b68909

Please sign in to comment.
Something went wrong with that request. Please try again.