@Override public void onDestroy() { super.onDestroy(); eventRegister.unregisterEventBuses(); eventRegister.onDestroy(); AndroidMvc.graph().release(this); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getParentFragment() == null) { setRetainInstance(true); } AndroidMvc.graph().inject(this); eventRegister = new EventRegister(this); eventRegister.onCreate(); eventRegister.registerEventBuses(); }
@Override public void onDestroyView() { // ====================================== // workaround of this bug // https://code.google.com/p/android/issues/detail?id=17423 if (getDialog() != null && (getParentFragment() != null || getRetainInstance())) { getDialog().setDismissMessage(null); } // ============================================ super.onDestroyView(); eventRegister.unregisterEventBuses(); }
/** * Post an event from this view to other views. Using EventBusV2V is a handy way to * inter-communicate among views but it's a little anti pattern. Best practice is that views * communicates to other views through controllers and EventBusC2V. For example, if view1 wants to * talk to view2, instead of sending V2V events, view1 can send a command to a controller and that * controller will fire an C2VEvent that will be received by view2. In this way, more business * logic can be wrapped into controllers rather than exposed to view1. * * <p>However, it's not absolute. If touching a controller is an overkill, sending events directly * through V2V channel is still an option. * * @param event */ protected void postEventV2V(BaseEventV2V event) { eventRegister.postEventV2V(event); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); eventRegister.registerEventBuses(); }