Skip to content

Commit

Permalink
dynamic tabgroup position
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Nov 24, 2024
1 parent 3e6bb20 commit 3673f23
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1011,15 +1011,25 @@ public void popToRootWindow()
/**
* emulates the iOS Tab.popToRootWindow() by closing all windows above a TabGroup.
*/
boolean isTabGroup = (activityStack.get(1).get() instanceof TiActivity)
&& ((TiActivity) activityStack.get(1).get()).getWindowProxy() instanceof TabGroupProxy;
int tabGroupPosition = -1;
boolean isTabGroup = false;

for (int i = 0; i <= activityStack.size(); ++i) {
isTabGroup = (activityStack.get(i).get() instanceof TiActivity)
&& ((TiActivity) activityStack.get(i).get()).getWindowProxy() instanceof TabGroupProxy;
if (isTabGroup) {
tabGroupPosition = i;
break;
}
}

// no TabGroup - don't do anything
if (!isTabGroup) {
if (!isTabGroup || tabGroupPosition == -1) {
return;
}

// finish all activities above our TabGroup
for (int i = activityStack.size() - 1; i > 1; --i) {
for (int i = activityStack.size() - 1; i > tabGroupPosition; --i) {
if (activityStack.get(i).get() instanceof TiActivity) {
TiActivity currentActivity = (TiActivity) activityStack.get(i).get();
currentActivity.finish();
Expand Down

0 comments on commit 3673f23

Please sign in to comment.