Skip to content

Commit

Permalink
feat(android): parity for Tab.popToRootWindow()
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Jan 29, 2024
1 parent 87a105a commit 0200e1a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ public void onPropertyChanged(String name, Object value)
}
}

@Kroll.method
public void popToRootWindow()
{
TiApplication.getInstance().popToRootWindow();
}

@Override
public String getApiName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,4 +1023,27 @@ public AccessibilityManager getAccessibilityManager()
public void verifyCustomModules(TiRootActivity rootActivity)
{
}

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().getApiName().equals("Ti.UI.TabGroup");

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

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

0 comments on commit 0200e1a

Please sign in to comment.