summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/same
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-25 22:39:07 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-25 22:39:07 +0100
commitcd22ae793f261976d29f2d02f852ef657be0c6bb (patch)
treee7e8adb022ab88a0eca7f9d6c556df522e10d78f /same-android/src/main/java/com/orbekk/same
parentdfbb6b1a8b7d33a2e2097187ddc07d379163bce7 (diff)
Send state updates from SameService.
Diffstat (limited to 'same-android/src/main/java/com/orbekk/same')
-rw-r--r--same-android/src/main/java/com/orbekk/same/SameService.java11
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/SameInterfaceBridge.java5
2 files changed, 16 insertions, 0 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/SameService.java b/same-android/src/main/java/com/orbekk/same/SameService.java
index 78bc62a..53742bd 100644
--- a/same-android/src/main/java/com/orbekk/same/SameService.java
+++ b/same-android/src/main/java/com/orbekk/same/SameService.java
@@ -15,6 +15,7 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.widget.Toast;
+import com.orbekk.same.State.Component;
import com.orbekk.same.android.net.AndroidBroadcasterFactory;
import com.orbekk.same.android.net.Broadcaster;
import com.orbekk.same.config.Configuration;
@@ -107,6 +108,16 @@ public class SameService extends Service {
private final Messenger messenger = new Messenger(new InterfaceHandler());
+ private StateChangedListener stateListener = new StateChangedListener() {
+ @Override
+ public void stateChanged(Component component) {
+ for (Messenger messenger : stateReceivers) {
+ Message message = Message.obtain(null, UPDATED_STATE_MESSAGE);
+ message.obj = component;
+ }
+ }
+ };
+
private void initializeConfiguration() {
Properties properties = new Properties();
String localIp = new Broadcaster(this)
diff --git a/same-android/src/main/java/com/orbekk/same/android/SameInterfaceBridge.java b/same-android/src/main/java/com/orbekk/same/android/SameInterfaceBridge.java
index c049d37..4d44a03 100644
--- a/same-android/src/main/java/com/orbekk/same/android/SameInterfaceBridge.java
+++ b/same-android/src/main/java/com/orbekk/same/android/SameInterfaceBridge.java
@@ -12,6 +12,7 @@ import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
+import android.widget.Toast;
import com.orbekk.same.ClientInterface;
import com.orbekk.same.SameService;
@@ -23,6 +24,10 @@ public class SameInterfaceBridge implements ClientInterface {
class ResponseHandler extends Handler {
@Override public void handleMessage(Message message) {
switch (message.what) {
+ case SameService.UPDATED_STATE_MESSAGE:
+ State.Component component = (State.Component)message.obj;
+ Toast.makeText(context, "Updated: " + component,
+ Toast.LENGTH_SHORT).show();
default:
logger.warn("Received unknown message from service: {}",
message);