瀏覽代碼

viewcontrollers

Daniel Zlotin 7 年之前
父節點
當前提交
e33903c74b

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java 查看文件

@@ -18,25 +18,25 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
18 18
 	protected void onCreate(@Nullable Bundle savedInstanceState) {
19 19
 		super.onCreate(savedInstanceState);
20 20
 		setContentView(new FrameLayout(this));
21
-		app().activityLifecycle.onActivityCreated(this);
21
+		app().getInitializer().onActivityCreated(this);
22 22
 	}
23 23
 
24 24
 	@Override
25 25
 	protected void onResume() {
26 26
 		super.onResume();
27
-		app().activityLifecycle.onActivityResumed(this);
27
+		app().getInitializer().onActivityResumed(this);
28 28
 	}
29 29
 
30 30
 	@Override
31 31
 	protected void onPause() {
32 32
 		super.onPause();
33
-		app().activityLifecycle.onActivityPaused(this);
33
+		app().getInitializer().onActivityPaused(this);
34 34
 	}
35 35
 
36 36
 	@Override
37 37
 	protected void onDestroy() {
38 38
 		super.onDestroy();
39
-		app().activityLifecycle.onActivityDestroyed(this);
39
+		app().getInitializer().onActivityDestroyed(this);
40 40
 	}
41 41
 
42 42
 	@Override

+ 8
- 3
lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java 查看文件

@@ -4,22 +4,23 @@ import android.app.Application;
4 4
 
5 5
 import com.facebook.react.ReactApplication;
6 6
 import com.facebook.react.ReactNativeHost;
7
-import com.reactnativenavigation.controllers.ActivityLifecycleDelegate;
8 7
 import com.reactnativenavigation.controllers.Store;
8
+import com.reactnativenavigation.react.DevPermissionRequest;
9
+import com.reactnativenavigation.react.NavigationReactInitializer;
9 10
 import com.reactnativenavigation.react.NavigationReactNativeHost;
10 11
 
11 12
 public abstract class NavigationApplication extends Application implements ReactApplication {
12 13
 
13 14
 	private Store store;
14 15
 	private NavigationReactNativeHost reactNativeHost;
15
-	ActivityLifecycleDelegate activityLifecycle;
16
+	private NavigationReactInitializer initializer;
16 17
 
17 18
 	@Override
18 19
 	public void onCreate() {
19 20
 		super.onCreate();
20 21
 		store = new Store();
21 22
 		reactNativeHost = new NavigationReactNativeHost(this, isDebug(), store);
22
-		activityLifecycle = new ActivityLifecycleDelegate(reactNativeHost.getReactInstanceManager(), isDebug());
23
+		initializer = new NavigationReactInitializer(reactNativeHost.getReactInstanceManager(), new DevPermissionRequest(isDebug()));
23 24
 	}
24 25
 
25 26
 	@Override
@@ -28,4 +29,8 @@ public abstract class NavigationApplication extends Application implements React
28 29
 	}
29 30
 
30 31
 	public abstract boolean isDebug();
32
+
33
+	NavigationReactInitializer getInitializer() {
34
+		return initializer;
35
+	}
31 36
 }

lib/android/app/src/main/java/com/reactnativenavigation/controllers/ActivityLifecycleDelegate.java → lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactInitializer.java 查看文件

@@ -1,22 +1,20 @@
1
-package com.reactnativenavigation.controllers;
1
+package com.reactnativenavigation.react;
2 2
 
3 3
 import com.facebook.react.ReactInstanceManager;
4 4
 import com.facebook.react.bridge.ReactContext;
5 5
 import com.reactnativenavigation.NavigationActivity;
6
-import com.reactnativenavigation.react.DevPermissionRequest;
7
-import com.reactnativenavigation.react.NavigationEvent;
8 6
 
9 7
 import java.util.concurrent.atomic.AtomicBoolean;
10 8
 
11
-public class ActivityLifecycleDelegate {
9
+public class NavigationReactInitializer {
12 10
 
13 11
 	private final ReactInstanceManager reactInstanceManager;
14 12
 	private final DevPermissionRequest devPermissionRequest;
15 13
 	private final AtomicBoolean appLaunchEmitted = new AtomicBoolean(false);
16 14
 
17
-	public ActivityLifecycleDelegate(ReactInstanceManager reactInstanceManager, boolean isDebug) {
15
+	public NavigationReactInitializer(ReactInstanceManager reactInstanceManager, final DevPermissionRequest devPermissionRequest) {
18 16
 		this.reactInstanceManager = reactInstanceManager;
19
-		this.devPermissionRequest = new DevPermissionRequest(isDebug);
17
+		this.devPermissionRequest = devPermissionRequest;
20 18
 	}
21 19
 
22 20
 	public void onActivityCreated(NavigationActivity activity) {

+ 15
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java 查看文件

@@ -0,0 +1,15 @@
1
+package com.reactnativenavigation.viewcontrollers;
2
+
3
+import android.view.View;
4
+
5
+public class ViewController {
6
+	private View view;
7
+
8
+	public View getView() {
9
+		return view;
10
+	}
11
+
12
+	public void setView(final View view) {
13
+		this.view = view;
14
+	}
15
+}

+ 19
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.reactnativenavigation.viewcontrollers;
2
+
3
+import android.view.View;
4
+
5
+import com.reactnativenavigation.BaseTest;
6
+
7
+import org.junit.Test;
8
+import org.robolectric.shadow.api.Shadow;
9
+
10
+import static org.assertj.core.api.Java6Assertions.assertThat;
11
+
12
+public class ViewControllerTest extends BaseTest {
13
+	@Test
14
+	public void holdsAView() throws Exception {
15
+		ViewController uut = new ViewController();
16
+		assertThat(uut.getView()).isNull();
17
+		uut.setView(Shadow.newInstanceOf(View.class));
18
+	}
19
+}

+ 1
- 1
scripts/test.e2e.android.js 查看文件

@@ -2,7 +2,7 @@ const exec = require('shell-utils').exec;
2 2
 
3 3
 function run() {
4 4
   if (process.env.CI) {
5
-    console.log(`e2e disabled on CI`); //eslint-disable-line
5
+    console.log(`android e2e disabled on CI for now`); //eslint-disable-line
6 6
     return;
7 7
   }
8 8