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,6 +34,10 @@ public class EventEmitter {
34 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 41
     private void sendScreenChangedEventToJsScreen(String eventId, String navigatorEventId) {
38 42
         WritableMap map = Arguments.createMap();
39 43
         map.putString("type", "ScreenChangedEvent");

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

@@ -107,6 +107,10 @@ class Modal extends Dialog implements DialogInterface.OnDismissListener, ScreenS
107 107
         return layout.getCurrentlyVisibleScreenId();
108 108
     }
109 109
 
110
+    String getCurrentlyVisibleEventId() {
111
+        return layout.getCurrentScreen().getNavigatorEventId();
112
+    }
113
+
110 114
     interface OnModalDismissedListener {
111 115
         void onModalDismissed(Modal modal);
112 116
     }

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

@@ -188,4 +188,8 @@ class ModalController implements ScreenStackContainer, Modal.OnModalDismissedLis
188 188
     String getCurrentlyVisibleScreenId() {
189 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,13 +58,14 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
58 58
     private ActivityParams activityParams;
59 59
     private ModalController modalController;
60 60
     private Layout layout;
61
-    @Nullable private PermissionListener mPermissionListener;
61
+    @Nullable
62
+    private PermissionListener mPermissionListener;
62 63
 
63 64
     @Override
64 65
     protected void onCreate(Bundle savedInstanceState) {
65 66
         super.onCreate(savedInstanceState);
66
-         if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext() || 
67
-                getIntent() == null || 
67
+        if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext() ||
68
+                getIntent() == null ||
68 69
                 getIntent().getBundleExtra("ACTIVITY_PARAMS_BUNDLE") == null) {
69 70
             SplashActivity.start(this);
70 71
             finish();
@@ -103,7 +104,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
103 104
 
104 105
     private boolean hasBackgroundColor() {
105 106
         return AppStyle.appStyle.screenBackgroundColor != null &&
106
-               AppStyle.appStyle.screenBackgroundColor.hasColor();
107
+                AppStyle.appStyle.screenBackgroundColor.hasColor();
107 108
     }
108 109
 
109 110
     @Override
@@ -125,6 +126,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
125 126
         NavigationApplication.instance.getActivityCallbacks().onActivityResumed(this);
126 127
         EventBus.instance.register(this);
127 128
         IntentDataHandler.onPostResume(getIntent());
129
+        NavigationApplication.instance.getEventEmitter().sendActivityResumed(getCurrentlyVisibleEventId());
128 130
     }
129 131
 
130 132
     @Override
@@ -458,4 +460,8 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
458 460
     public String getCurrentlyVisibleScreenId() {
459 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
 }