]> Pileus Git - ~andy/iBeaconNav/blobdiff - src/edu/ucla/iBeaconNav/Task.java
Move commands to CMD class
[~andy/iBeaconNav] / src / edu / ucla / iBeaconNav / Task.java
index 049776ed9b0929c55096a709b31cb03af9e0a781..6d8c777d33960792e38be0f87f0fd13b0aa21968 100644 (file)
@@ -24,25 +24,12 @@ import com.radiusnetworks.ibeacon.service.*;
 
 public class Task extends Service implements IBeaconConsumer, RangeNotifier, MonitorNotifier
 {
-       /* Main -> Task Messsages */
-       static enum Command {
-               REGISTER,
-               CONNECT,
-               DISCONNECT,
-       };
-
-       /* Task -> Main messages */
-       static enum Response {
-               POSITION,
-               NOTIFY,
-       };
-
        /* Private data */
        private Messenger      messenger;
        private IBeaconManager ibeacon;
 
        /* Private methods */
-       private void tellMain(Response cmd, Object value)
+       private void tellMain(CMD.Response cmd, Object value)
        {
                try {
                        android.os.Message msg = android.os.Message.obtain();
@@ -57,7 +44,7 @@ public class Task extends Service implements IBeaconConsumer, RangeNotifier, Mon
        private void notify(String text, int icon)
        {
                // Notify Main
-               this.tellMain(Task.Response.NOTIFY, text);
+               this.tellMain(CMD.Response.NOTIFY, text);
 
                // Notification bar
                //Notification  note   = new Notification(icon, null, 0);
@@ -75,10 +62,10 @@ public class Task extends Service implements IBeaconConsumer, RangeNotifier, Mon
                this.startForeground(1, note);
        }
 
-       private void handle(Command cmd, Messenger mgr)
+       private void handle(CMD.Command cmd, Messenger mgr)
        {
                // Validate messenger
-               if (cmd != Task.Command.REGISTER && mgr != null && mgr != this.messenger)
+               if (cmd != CMD.Command.REGISTER && mgr != null && mgr != this.messenger)
                        Util.debug("Task: handle - invalid messenger");
 
                // Handle the command
@@ -135,9 +122,9 @@ public class Task extends Service implements IBeaconConsumer, RangeNotifier, Mon
        public int onStartCommand(Intent intent, int flags, int startId)
        {
                Util.debug("Task: onStartCommand");
-               int       rval = super.onStartCommand(intent, flags, startId);
-               Command   cmd  =   (Command)intent.getExtras().get("Command");
-               Messenger mgr  = (Messenger)intent.getExtras().get("Messenger");
+               int         rval = super.onStartCommand(intent, flags, startId);
+               CMD.Command cmd  = (CMD.Command)intent.getExtras().get("Command");
+               Messenger   mgr  = (Messenger)intent.getExtras().get("Messenger");
                this.handle(cmd, mgr);
                return rval;
        }