package com.goodow.drive.android.svg;

import android.content.Context;
import android.content.Intent;

import com.goodow.realtime.channel.Bus;
import com.goodow.realtime.channel.Message;
import com.goodow.realtime.channel.MessageHandler;
import com.goodow.realtime.json.JsonObject;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;


/**
 * Created by liudenghui on 14-6-30.
 */
public class SvgModule extends AbstractModule {

  @Override
  protected void configure() {
     bind(Binder.class).asEagerSingleton();
  }

  @Singleton
  public static class Binder {
    @Inject
    public Binder(final Provider<Bus> busProvider, final Provider<Context> context) {
      busProvider.get().subscribe("drive.svg", new MessageHandler<JsonObject>() {
        @Override
        public void handle(Message<JsonObject> message) {
          JsonObject body = message.body();
          if (body.has("open") && body.getString("open").equals("svg")) {
            Intent intent = new Intent(context.get(), MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.get().startActivity(intent);
          }
        }
      });
    }
  }

}

@@ -783,16 +783,21 @@
 ubscribe
+Local
 (%22drive.
@@ -833,24 +833,24 @@
 Object%3E() %7B%0A
-
         @Ove
@@ -917,128 +917,8 @@
 ) %7B%0A
-          JsonObject body = message.body();%0A          if (body.has(%22open%22) && body.getString(%22open%22).equals(%22svg%22)) %7B%0A  
     
@@ -996,18 +996,16 @@
         
-  
 intent.a
@@ -1044,18 +1044,16 @@
 _TASK);%0A
-  
         
@@ -1095,20 +1095,8 @@
 t);%0A
-          %7D%0A
     

change address of bus