diff options
-rw-r--r-- | same-android/src/main/java/com/orbekk/same/SameService.java | 11 | ||||
-rw-r--r-- | same-android/src/main/java/com/orbekk/same/android/SameInterfaceBridge.java | 5 |
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); |