mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(bottom-navigation): crash when tab selected with no item (#7527)
This commit is contained in:
committed by
GitHub
parent
59575514ad
commit
46c17ca3a4
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user