|
@@ -4,23 +4,20 @@ import android.content.Context;
|
4
|
4
|
import android.support.annotation.NonNull;
|
5
|
5
|
import android.support.design.widget.CoordinatorLayout;
|
6
|
6
|
|
7
|
|
-import com.reactnativenavigation.events.ScreenChangeBroadcastReceiver;
|
|
7
|
+import com.reactnativenavigation.events.Event;
|
|
8
|
+import com.reactnativenavigation.events.EventBus;
|
|
9
|
+import com.reactnativenavigation.events.ScreenChangedEvent;
|
|
10
|
+import com.reactnativenavigation.events.Subscriber;
|
8
|
11
|
import com.reactnativenavigation.params.FabParams;
|
9
|
12
|
import com.reactnativenavigation.params.SnackbarParams;
|
10
|
13
|
|
11
|
|
-public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakbar.OnDismissListener, ScreenChangeBroadcastReceiver.OnScreenChangeListener {
|
|
14
|
+public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakbar.OnDismissListener, Subscriber{
|
12
|
15
|
private Snakbar snakbar;
|
13
|
|
- private ScreenChangeBroadcastReceiver screenChangeBroadcastReceiver;
|
14
|
16
|
private FloatingActionButtonCoordinator actionButtonCoordinator;
|
15
|
17
|
|
16
|
18
|
public SnackbarAndFabContainer(Context context) {
|
17
|
19
|
super(context);
|
18
|
|
- registerTabSelectedReceiver();
|
19
|
|
- }
|
20
|
|
-
|
21
|
|
- private void registerTabSelectedReceiver() {
|
22
|
|
- screenChangeBroadcastReceiver = new ScreenChangeBroadcastReceiver(this);
|
23
|
|
- screenChangeBroadcastReceiver.register();
|
|
20
|
+ EventBus.instance.register(this);
|
24
|
21
|
}
|
25
|
22
|
|
26
|
23
|
public void showSnackbar(final String navigatorEventId, final SnackbarParams params) {
|
|
@@ -43,15 +40,17 @@ public class SnackbarAndFabContainer extends CoordinatorLayout implements Snakba
|
43
|
40
|
}
|
44
|
41
|
|
45
|
42
|
public void destroy() {
|
46
|
|
- screenChangeBroadcastReceiver.unregister();
|
47
|
|
- }
|
48
|
|
-
|
49
|
|
- @Override
|
50
|
|
- public void onScreenChangeListener() {
|
51
|
|
- onScreenChange();
|
|
43
|
+ EventBus.instance.unregister(this);
|
52
|
44
|
}
|
53
|
45
|
|
54
|
46
|
public void showFab(@NonNull FabParams fabParams) {
|
55
|
47
|
actionButtonCoordinator = new FloatingActionButtonCoordinator(this, fabParams);
|
56
|
48
|
}
|
|
49
|
+
|
|
50
|
+ @Override
|
|
51
|
+ public void onEvent(Event event) {
|
|
52
|
+ if (event.getType() == ScreenChangedEvent.TYPE) {
|
|
53
|
+ onScreenChange();
|
|
54
|
+ }
|
|
55
|
+ }
|
57
|
56
|
}
|