|
@@ -18,14 +18,16 @@ import java.util.Stack;
|
18
|
18
|
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
19
|
19
|
|
20
|
20
|
// TODO there's really no reason for ScreenStack to extend FrameLayout. All screens can be added to parent.
|
21
|
|
-public class ScreenStack extends FrameLayout implements TitleBarBackButtonListener {
|
|
21
|
+public class ScreenStack extends FrameLayout {
|
22
|
22
|
|
23
|
23
|
private final AppCompatActivity activity;
|
|
24
|
+ private TitleBarBackButtonListener titleBarBackButtonListener;
|
24
|
25
|
private Stack<Screen> stack = new Stack<>();
|
25
|
26
|
|
26
|
|
- public ScreenStack(AppCompatActivity activity, ScreenParams initialScreenParams) {
|
|
27
|
+ public ScreenStack(AppCompatActivity activity, ScreenParams initialScreenParams, TitleBarBackButtonListener titleBarBackButtonListener) {
|
27
|
28
|
super(activity);
|
28
|
29
|
this.activity = activity;
|
|
30
|
+ this.titleBarBackButtonListener = titleBarBackButtonListener;
|
29
|
31
|
setLayoutTransition(new LayoutTransition());
|
30
|
32
|
pushInitialScreen(initialScreenParams);
|
31
|
33
|
}
|
|
@@ -41,7 +43,7 @@ public class ScreenStack extends FrameLayout implements TitleBarBackButtonListen
|
41
|
43
|
}
|
42
|
44
|
|
43
|
45
|
private void addScreen(ScreenParams screenParams) {
|
44
|
|
- Screen screen = ScreenFactory.create(activity, screenParams, this);
|
|
46
|
+ Screen screen = ScreenFactory.create(activity, screenParams, titleBarBackButtonListener);
|
45
|
47
|
addView(screen, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
46
|
48
|
stack.push(screen);
|
47
|
49
|
}
|
|
@@ -131,18 +133,11 @@ public class ScreenStack extends FrameLayout implements TitleBarBackButtonListen
|
131
|
133
|
performOnScreen(screenInstanceId, new Task<Screen>() {
|
132
|
134
|
@Override
|
133
|
135
|
public void run(Screen param) {
|
134
|
|
- param.setTitleBarLeftButton(navigatorEventId, ScreenStack.this, titleBarLeftButtonParams);
|
|
136
|
+ param.setTitleBarLeftButton(navigatorEventId, titleBarBackButtonListener, titleBarLeftButtonParams);
|
135
|
137
|
}
|
136
|
138
|
});
|
137
|
139
|
}
|
138
|
140
|
|
139
|
|
- @Override
|
140
|
|
- public void onTitleBarBackPress() {
|
141
|
|
- if (canPop()) {
|
142
|
|
- pop();
|
143
|
|
- }
|
144
|
|
- }
|
145
|
|
-
|
146
|
141
|
public StyleParams getCurrentScreenStyleParams() {
|
147
|
142
|
return stack.peek().getStyleParams();
|
148
|
143
|
}
|