Daniel Zlotin 8 年 前
コミット
2a4b95c792

+ 11
- 1
lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java ファイルの表示

@@ -43,6 +43,14 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
43 43
 		this.contentView = contentView;
44 44
 	}
45 45
 
46
+	public void setLayout(Layout layout) {
47
+		this.layout = layout;
48
+	}
49
+
50
+	public Layout getLayout() {
51
+		return layout;
52
+	}
53
+
46 54
 	@Nullable
47 55
 	public View getContentView() {
48 56
 		return contentView;
@@ -55,7 +63,9 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
55 63
 
56 64
 	@Override
57 65
 	public void onBackPressed() {
58
-		if (!(contentView instanceof LayoutStack) || !((LayoutStack) contentView).onBackPressed()) {
66
+		if (layout instanceof LayoutStack && ((LayoutStack) layout).onBackPressed()) {
67
+			// do nothing, layout pops
68
+		} else {
59 69
 			super.onBackPressed();
60 70
 		}
61 71
 	}

+ 3
- 2
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java ファイルの表示

@@ -37,6 +37,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
37 37
 				LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager);
38 38
 				final Layout rootView = factory.create(layoutTree);
39 39
 				activity().setContentView(rootView.getView());
40
+				activity().setLayout(rootView);
40 41
 			}
41 42
 		});
42 43
 	}
@@ -49,7 +50,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
49 50
 				final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(rawLayoutTree));
50 51
 				LayoutFactory factory = new LayoutFactory(activity(), reactInstanceManager);
51 52
 				final Layout rootView = factory.create(layoutTree);
52
-				((LayoutStack) activity().getContentView()).push(rootView);
53
+				((LayoutStack) activity().getLayout()).push(rootView);
53 54
 			}
54 55
 		});
55 56
 	}
@@ -59,7 +60,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
59 60
 		handle(new Runnable() {
60 61
 			@Override
61 62
 			public void run() {
62
-				((LayoutStack) activity().getContentView()).pop();
63
+				((LayoutStack) activity().getLayout()).pop();
63 64
 			}
64 65
 		});
65 66
 	}