// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java
// public class EventBus {
// 
//     private static EventProcessHandler defaultEventHandler;
//     private static WeakHashMap<Activity, EventHandler> eventHandlerMap;
//     private static EventHandler emptyEventHandler = new EventHandler();
//     private static Context staticContext;
//     private static boolean staticHasRemoteEvent;
//     volatile static IEventProxyFactory staticEventProxyFactory;
// 
//     public static void init(Context context, boolean hasRemoteEvent) {
//         staticContext = context.getApplicationContext();
//         staticHasRemoteEvent = hasRemoteEvent;
//         eventHandlerMap = new WeakHashMap<>();
//         defaultEventHandler = new EventProcessHandler(hasRemoteEvent);
//         staticEventProxyFactory = new EventProxyAptFactory();
//     }
// 
//     public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){
//         staticEventProxyFactory = eventProxyFactory;
//     }
// 
//     static IEventProxyFactory getEventProxyFactory(){
//         return staticEventProxyFactory;
//     }
// 
//     static Context getContext() {
//         return staticContext;
//     }
// 
//     static boolean isHasRemoteEvent() {
//         return staticHasRemoteEvent;
//     }
// 
//     public static void register(IEvent iEvent) {
//         checkInit();
//         defaultEventHandler.register(iEvent);
//     }
// 
//     public static void unregister(IEvent iEvent) {
//         checkInit();
//         defaultEventHandler.unregister(iEvent);
//     }
// 
//     public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) {
//         checkInit();
//         return defaultEventHandler.postMain(eventInterface);
//     }
// 
//     public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) {
//         checkInit();
//         return defaultEventHandler.post(eventInterface);
//     }
// 
//     public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) {
//         checkInit();
//         return defaultEventHandler.postRemote(eventInterface, processName);
//     }
// 
// //    public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) {
// //        return withActivity(activity).postMain(eventInterface);
// //    }
// //
// //    public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) {
// //        return withActivity(activity).postMain(eventInterface);
// //    }
// 
//     public static synchronized IEventHandler withActivity(Activity activity) {
//         checkInit();
//         if (activity == null) {
//             return emptyEventHandler;
//         }
//         EventHandler eventBusImp = eventHandlerMap.get(activity);
//         if (eventBusImp == null) {
//             eventBusImp = new EventHandler();
//             eventHandlerMap.put(activity, eventBusImp);
//         }
//         return eventBusImp;
//     }
// 
//     private static void checkInit() {
//         if (staticContext == null) {
//             throw new RuntimeException("请在Application调用EventBus.init方法进行初始化");
//         }
//     }
// }
// 
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java
// public class Filters {
// 
//     public static IEvent.Filter deliver(final IEvent... registers) {
//         if (registers == null) {
//             return acceptAll();
//         }
//         if (registers.length == 1) {
//             final WeakReference<IEvent> reference = new WeakReference<>(registers[0]);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return reference.get() != event;
//                 }
//             };
//         } else {
//             final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length));
//             Collections.addAll(iEvents, registers);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return !iEvents.contains(event);
//                 }
//             };
//         }
//     }
// 
//     public static IEvent.Filter contains(final IEvent... registers) {
//         if (registers == null) {
//             return NONE;
//         }
//         if (registers.length == 1) {
//             final WeakReference<IEvent> reference = new WeakReference<>(registers[0]);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return reference.get() == event;
//                 }
//             };
//         } else {
//             final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length));
//             Collections.addAll(iEvents, registers);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return iEvents.contains(event);
//                 }
//             };
//         }
//     }
// 
//     public static IEvent.Filter acceptAll() {
//         return ALL;
//     }
// 
//     private static final IEvent.Filter ALL = new IEvent.Filter() {
//         @Override
//         public boolean accept(IEvent event) {
//             return true;
//         }
//     };
// 
//     private static final IEvent.Filter NONE = new IEvent.Filter() {
//         @Override
//         public boolean accept(IEvent event) {
//             return true;
//         }
//     };
// }
// 
// Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java
// @Event
// public interface TestFilterEvent extends IEvent {
//     void onWrite(Filter filter, String text);
// }


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.shizhefei.eventbus.EventBus;
import com.shizhefei.eventbus.Filters;
import com.shizhefei.eventbus.demo.R;
import com.shizhefei.eventbusdemo.events.TestFilterEvent;
package com.shizhefei.eventbusdemo;



public class TestFilterActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_filter);
        findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/EventBus.java
// public class EventBus {
// 
//     private static EventProcessHandler defaultEventHandler;
//     private static WeakHashMap<Activity, EventHandler> eventHandlerMap;
//     private static EventHandler emptyEventHandler = new EventHandler();
//     private static Context staticContext;
//     private static boolean staticHasRemoteEvent;
//     volatile static IEventProxyFactory staticEventProxyFactory;
// 
//     public static void init(Context context, boolean hasRemoteEvent) {
//         staticContext = context.getApplicationContext();
//         staticHasRemoteEvent = hasRemoteEvent;
//         eventHandlerMap = new WeakHashMap<>();
//         defaultEventHandler = new EventProcessHandler(hasRemoteEvent);
//         staticEventProxyFactory = new EventProxyAptFactory();
//     }
// 
//     public static void setEventProxyFactory(IEventProxyFactory eventProxyFactory){
//         staticEventProxyFactory = eventProxyFactory;
//     }
// 
//     static IEventProxyFactory getEventProxyFactory(){
//         return staticEventProxyFactory;
//     }
// 
//     static Context getContext() {
//         return staticContext;
//     }
// 
//     static boolean isHasRemoteEvent() {
//         return staticHasRemoteEvent;
//     }
// 
//     public static void register(IEvent iEvent) {
//         checkInit();
//         defaultEventHandler.register(iEvent);
//     }
// 
//     public static void unregister(IEvent iEvent) {
//         checkInit();
//         defaultEventHandler.unregister(iEvent);
//     }
// 
//     public static <EVENT extends IEvent> EVENT postMain(Class<EVENT> eventInterface) {
//         checkInit();
//         return defaultEventHandler.postMain(eventInterface);
//     }
// 
//     public static <EVENT extends IEvent> EVENT post(Class<EVENT> eventInterface) {
//         checkInit();
//         return defaultEventHandler.post(eventInterface);
//     }
// 
//     public static <EVENT extends IRemoteEvent> EVENT postRemote(Class<EVENT> eventInterface, String processName) {
//         checkInit();
//         return defaultEventHandler.postRemote(eventInterface, processName);
//     }
// 
// //    public static <EVENT extends IEvent> EVENT postMainInActivity(Activity activity, Class<EVENT> eventInterface) {
// //        return withActivity(activity).postMain(eventInterface);
// //    }
// //
// //    public static <EVENT extends IEvent> EVENT postInActivity(Activity activity, Class<EVENT> eventInterface) {
// //        return withActivity(activity).postMain(eventInterface);
// //    }
// 
//     public static synchronized IEventHandler withActivity(Activity activity) {
//         checkInit();
//         if (activity == null) {
//             return emptyEventHandler;
//         }
//         EventHandler eventBusImp = eventHandlerMap.get(activity);
//         if (eventBusImp == null) {
//             eventBusImp = new EventHandler();
//             eventHandlerMap.put(activity, eventBusImp);
//         }
//         return eventBusImp;
//     }
// 
//     private static void checkInit() {
//         if (staticContext == null) {
//             throw new RuntimeException("请在Application调用EventBus.init方法进行初始化");
//         }
//     }
// }
// 
// Path: eventbus-api/src/main/java/com/shizhefei/eventbus/Filters.java
// public class Filters {
// 
//     public static IEvent.Filter deliver(final IEvent... registers) {
//         if (registers == null) {
//             return acceptAll();
//         }
//         if (registers.length == 1) {
//             final WeakReference<IEvent> reference = new WeakReference<>(registers[0]);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return reference.get() != event;
//                 }
//             };
//         } else {
//             final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length));
//             Collections.addAll(iEvents, registers);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return !iEvents.contains(event);
//                 }
//             };
//         }
//     }
// 
//     public static IEvent.Filter contains(final IEvent... registers) {
//         if (registers == null) {
//             return NONE;
//         }
//         if (registers.length == 1) {
//             final WeakReference<IEvent> reference = new WeakReference<>(registers[0]);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return reference.get() == event;
//                 }
//             };
//         } else {
//             final Set<IEvent> iEvents = Collections.newSetFromMap(new WeakHashMap<IEvent, Boolean>(registers.length));
//             Collections.addAll(iEvents, registers);
//             return new IEvent.Filter() {
//                 @Override
//                 public boolean accept(IEvent event) {
//                     return iEvents.contains(event);
//                 }
//             };
//         }
//     }
// 
//     public static IEvent.Filter acceptAll() {
//         return ALL;
//     }
// 
//     private static final IEvent.Filter ALL = new IEvent.Filter() {
//         @Override
//         public boolean accept(IEvent event) {
//             return true;
//         }
//     };
// 
//     private static final IEvent.Filter NONE = new IEvent.Filter() {
//         @Override
//         public boolean accept(IEvent event) {
//             return true;
//         }
//     };
// }
// 
// Path: app/src/main/java/com/shizhefei/eventbusdemo/events/TestFilterEvent.java
// @Event
// public interface TestFilterEvent extends IEvent {
//     void onWrite(Filter filter, String text);
// }


// Path: app/src/main/java/com/shizhefei/eventbusdemo/TestFilterActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.shizhefei.eventbus.EventBus;
import com.shizhefei.eventbus.Filters;
import com.shizhefei.eventbus.demo.R;
import com.shizhefei.eventbusdemo.events.TestFilterEvent;

package com.shizhefei.eventbusdemo;



public class TestFilterActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_filter);
        findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.postMain(TestFilterEvent.class).onWrite(null, "aaaaa");