Browse Source

viewcontrollers

Daniel Zlotin 7 years ago
parent
commit
e33903c74b

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

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

+ 8
- 3
lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java View File

4
 
4
 
5
 import com.facebook.react.ReactApplication;
5
 import com.facebook.react.ReactApplication;
6
 import com.facebook.react.ReactNativeHost;
6
 import com.facebook.react.ReactNativeHost;
7
-import com.reactnativenavigation.controllers.ActivityLifecycleDelegate;
8
 import com.reactnativenavigation.controllers.Store;
7
 import com.reactnativenavigation.controllers.Store;
8
+import com.reactnativenavigation.react.DevPermissionRequest;
9
+import com.reactnativenavigation.react.NavigationReactInitializer;
9
 import com.reactnativenavigation.react.NavigationReactNativeHost;
10
 import com.reactnativenavigation.react.NavigationReactNativeHost;
10
 
11
 
11
 public abstract class NavigationApplication extends Application implements ReactApplication {
12
 public abstract class NavigationApplication extends Application implements ReactApplication {
12
 
13
 
13
 	private Store store;
14
 	private Store store;
14
 	private NavigationReactNativeHost reactNativeHost;
15
 	private NavigationReactNativeHost reactNativeHost;
15
-	ActivityLifecycleDelegate activityLifecycle;
16
+	private NavigationReactInitializer initializer;
16
 
17
 
17
 	@Override
18
 	@Override
18
 	public void onCreate() {
19
 	public void onCreate() {
19
 		super.onCreate();
20
 		super.onCreate();
20
 		store = new Store();
21
 		store = new Store();
21
 		reactNativeHost = new NavigationReactNativeHost(this, isDebug(), store);
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
 	@Override
26
 	@Override
28
 	}
29
 	}
29
 
30
 
30
 	public abstract boolean isDebug();
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 View File

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

+ 15
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java View File

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 View File

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 View File

2
 
2
 
3
 function run() {
3
 function run() {
4
   if (process.env.CI) {
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
     return;
6
     return;
7
   }
7
   }
8
 
8