|
@@ -183,23 +183,27 @@ public class StackController extends ParentController<StackLayout> {
|
183
|
183
|
|
184
|
184
|
public void setRoot(List<ViewController> children, CommandListener listener) {
|
185
|
185
|
animator.cancelPushAnimations();
|
|
186
|
+ final ViewController toRemove = stack.peek();
|
186
|
187
|
IdStack stackToDestroy = stack;
|
187
|
188
|
stack = new IdStack<>();
|
|
189
|
+
|
|
190
|
+ ViewController child = last(children);
|
188
|
191
|
if (children.size() == 1) {
|
189
|
|
- backButtonHelper.clear(last(children));
|
190
|
|
- push(last(children), new CommandListenerAdapter() {
|
191
|
|
- @Override
|
192
|
|
- public void onSuccess(String childId) {
|
193
|
|
- destroyStack(stackToDestroy);
|
194
|
|
- listener.onSuccess(childId);
|
195
|
|
- }
|
196
|
|
- });
|
|
192
|
+ backButtonHelper.clear(child);
|
197
|
193
|
} else {
|
198
|
|
- backButtonHelper.addToPushedChild(last(children));
|
199
|
|
- push(last(children), new CommandListenerAdapter() {
|
200
|
|
- @Override
|
201
|
|
- public void onSuccess(String childId) {
|
202
|
|
- destroyStack(stackToDestroy);
|
|
194
|
+ backButtonHelper.addToPushedChild(child);
|
|
195
|
+ }
|
|
196
|
+
|
|
197
|
+ child.setParentController(this);
|
|
198
|
+ stack.push(child.getId(), child);
|
|
199
|
+ Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions());
|
|
200
|
+ addChildToStack(child, child.getView(), resolvedOptions);
|
|
201
|
+
|
|
202
|
+ CommandListener listenerAdapter = new CommandListenerAdapter() {
|
|
203
|
+ @Override
|
|
204
|
+ public void onSuccess(String childId) {
|
|
205
|
+ destroyStack(stackToDestroy);
|
|
206
|
+ if (children.size() > 1) {
|
203
|
207
|
for (int i = 0; i < children.size() - 1; i++) {
|
204
|
208
|
stack.set(children.get(i).getId(), children.get(i), i);
|
205
|
209
|
children.get(i).setParentController(StackController.this);
|
|
@@ -209,9 +213,24 @@ public class StackController extends ParentController<StackLayout> {
|
209
|
213
|
backButtonHelper.addToPushedChild(children.get(i));
|
210
|
214
|
}
|
211
|
215
|
}
|
212
|
|
- listener.onSuccess(childId);
|
213
|
216
|
}
|
214
|
|
- });
|
|
217
|
+ listener.onSuccess(childId);
|
|
218
|
+ }
|
|
219
|
+ };
|
|
220
|
+
|
|
221
|
+ if (toRemove != null && resolvedOptions.animations.setStackRoot.enabled.isTrueOrUndefined()) {
|
|
222
|
+ if (resolvedOptions.animations.setStackRoot.waitForRender.isTrue()) {
|
|
223
|
+ child.getView().setAlpha(0);
|
|
224
|
+ child.addOnAppearedListener(() -> animator.push(child.getView(), resolvedOptions.animations.setStackRoot, resolvedOptions.transitions, toRemove.getElements(), child.getElements(), () -> {
|
|
225
|
+ listenerAdapter.onSuccess(child.getId());
|
|
226
|
+ }));
|
|
227
|
+ } else {
|
|
228
|
+ animator.push(child.getView(), resolvedOptions.animations.setStackRoot, () -> {
|
|
229
|
+ listenerAdapter.onSuccess(child.getId());
|
|
230
|
+ });
|
|
231
|
+ }
|
|
232
|
+ } else {
|
|
233
|
+ listenerAdapter.onSuccess(child.getId());
|
215
|
234
|
}
|
216
|
235
|
}
|
217
|
236
|
|