Skip to content

Commit

Permalink
Render first tab first
Browse files Browse the repository at this point in the history
Until now tabs were added to screen in reverse order, meaning the last tab was attached to hierarchy first and the first tab was attached last.
This caused the first tab, which usually should appear first, to be rendered last as the root view’s startReactApplication was called last.
This commit changes render order so that the first tab is rendered first. Some apps will probably see an improvement in time to interaction as a result.
  • Loading branch information
guyca committed Jan 3, 2019
1 parent 37e23b8 commit e5a2efb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private List<AHBottomNavigationItem> createTabs() {
}

private void attachTabs(RelativeLayout root) {
for (int i = (tabs.size() - 1); i >= 0; i--) {
for (int i = 0; i < tabs.size(); i++) {
ViewGroup tab = tabs.get(i).getView();
tab.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
Options options = resolveCurrentOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public void setTabs_allChildViewsAreAttachedToHierarchy() {
public void setTabs_firstChildIsVisibleOtherAreGone() {
uut.onViewAppeared();
for (int i = 0; i < uut.getChildControllers().size(); i++) {
assertThat(uut.getView().getChildAt(i).getVisibility()).isEqualTo(i == 0 ? View.VISIBLE : View.INVISIBLE);
assertThat(uut.getView().getChildAt(i + 1)).isEqualTo(tabs.get(i).getView());
assertThat(uut.getView().getChildAt(i + 1).getVisibility()).isEqualTo(i == 0 ? View.VISIBLE : View.INVISIBLE);
}
}

Expand Down

0 comments on commit e5a2efb

Please sign in to comment.