Browse Source

on activity resumed (#2370)

Roman Kozlov 6 years ago
parent
commit
d050ce2fda

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/EventEmitter.java View File

34
         sendGlobalScreenChangedEvent("didDisappear", params.timestamp, params.screenId, type);
34
         sendGlobalScreenChangedEvent("didDisappear", params.timestamp, params.screenId, type);
35
     }
35
     }
36
 
36
 
37
+    public void sendActivityResumed(String id) {
38
+        sendScreenChangedEventToJsScreen("onActivityResumed", id);
39
+    }
40
+
37
     private void sendScreenChangedEventToJsScreen(String eventId, String navigatorEventId) {
41
     private void sendScreenChangedEventToJsScreen(String eventId, String navigatorEventId) {
38
         WritableMap map = Arguments.createMap();
42
         WritableMap map = Arguments.createMap();
39
         map.putString("type", "ScreenChangedEvent");
43
         map.putString("type", "ScreenChangedEvent");

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/Modal.java View File

107
         return layout.getCurrentlyVisibleScreenId();
107
         return layout.getCurrentlyVisibleScreenId();
108
     }
108
     }
109
 
109
 
110
+    String getCurrentlyVisibleEventId() {
111
+        return layout.getCurrentScreen().getNavigatorEventId();
112
+    }
113
+
110
     interface OnModalDismissedListener {
114
     interface OnModalDismissedListener {
111
         void onModalDismissed(Modal modal);
115
         void onModalDismissed(Modal modal);
112
     }
116
     }

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/ModalController.java View File

188
     String getCurrentlyVisibleScreenId() {
188
     String getCurrentlyVisibleScreenId() {
189
         return stack.peek().getCurrentlyVisibleScreenId();
189
         return stack.peek().getCurrentlyVisibleScreenId();
190
     }
190
     }
191
+
192
+    String getCurrentlyVisibleEventId() {
193
+        return stack.peek().getCurrentlyVisibleEventId();
194
+    }
191
 }
195
 }

+ 10
- 4
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

58
     private ActivityParams activityParams;
58
     private ActivityParams activityParams;
59
     private ModalController modalController;
59
     private ModalController modalController;
60
     private Layout layout;
60
     private Layout layout;
61
-    @Nullable private PermissionListener mPermissionListener;
61
+    @Nullable
62
+    private PermissionListener mPermissionListener;
62
 
63
 
63
     @Override
64
     @Override
64
     protected void onCreate(Bundle savedInstanceState) {
65
     protected void onCreate(Bundle savedInstanceState) {
65
         super.onCreate(savedInstanceState);
66
         super.onCreate(savedInstanceState);
66
-         if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext() || 
67
-                getIntent() == null || 
67
+        if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext() ||
68
+                getIntent() == null ||
68
                 getIntent().getBundleExtra("ACTIVITY_PARAMS_BUNDLE") == null) {
69
                 getIntent().getBundleExtra("ACTIVITY_PARAMS_BUNDLE") == null) {
69
             SplashActivity.start(this);
70
             SplashActivity.start(this);
70
             finish();
71
             finish();
103
 
104
 
104
     private boolean hasBackgroundColor() {
105
     private boolean hasBackgroundColor() {
105
         return AppStyle.appStyle.screenBackgroundColor != null &&
106
         return AppStyle.appStyle.screenBackgroundColor != null &&
106
-               AppStyle.appStyle.screenBackgroundColor.hasColor();
107
+                AppStyle.appStyle.screenBackgroundColor.hasColor();
107
     }
108
     }
108
 
109
 
109
     @Override
110
     @Override
125
         NavigationApplication.instance.getActivityCallbacks().onActivityResumed(this);
126
         NavigationApplication.instance.getActivityCallbacks().onActivityResumed(this);
126
         EventBus.instance.register(this);
127
         EventBus.instance.register(this);
127
         IntentDataHandler.onPostResume(getIntent());
128
         IntentDataHandler.onPostResume(getIntent());
129
+        NavigationApplication.instance.getEventEmitter().sendActivityResumed(getCurrentlyVisibleEventId());
128
     }
130
     }
129
 
131
 
130
     @Override
132
     @Override
458
     public String getCurrentlyVisibleScreenId() {
460
     public String getCurrentlyVisibleScreenId() {
459
         return modalController.isShowing() ? modalController.getCurrentlyVisibleScreenId() : layout.getCurrentlyVisibleScreenId();
461
         return modalController.isShowing() ? modalController.getCurrentlyVisibleScreenId() : layout.getCurrentlyVisibleScreenId();
460
     }
462
     }
463
+
464
+    public String getCurrentlyVisibleEventId() {
465
+        return modalController.isShowing() ? modalController.getCurrentlyVisibleEventId() : layout.getCurrentScreen().getNavigatorEventId();
466
+    }
461
 }
467
 }