fix(bottom-navigation): crash when tab selected with no item (#7527)

This commit is contained in:
Alexander Djenkov
2019-07-19 17:09:40 +03:00
committed by GitHub
parent 59575514ad
commit 46c17ca3a4
5 changed files with 27 additions and 11 deletions

View File

@@ -216,8 +216,9 @@ public class BottomNavigationBar extends LinearLayout {
lp.weight = 1;
}
public void onTap(int position) {
public boolean onTap(int position) {
// to be overridden in JS
return true;
}
public void onSelectedPositionChange(int position, int prevPosition) {
@@ -269,8 +270,9 @@ public class BottomNavigationBar extends LinearLayout {
public void onClick(View v) {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
if (v == mTabStrip.getChildAt(i)) {
onTap(i);
setSelectedPosition(i);
if (onTap(i)) {
setSelectedPosition(i);
}
return;
}
}

View File

@@ -301,8 +301,9 @@ public class TabLayout extends HorizontalScrollView {
}
}
public void onTap(int position) {
public boolean onTap(int position) {
// to be overridden in JS
return true;
}
public void onSelectedPositionChange(int position, int prevPosition) {
@@ -429,8 +430,9 @@ public class TabLayout extends HorizontalScrollView {
public void onClick(View v) {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
if (v == mTabStrip.getChildAt(i)) {
onTap(i);
mViewPager.setCurrentItem(i);
if (onTap(i)) {
mViewPager.setCurrentItem(i);
}
return;
}
}