Skip to content

Commit

Permalink
fix(android): fix TabbedBar Click loop (#11495)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27779
  • Loading branch information
m1ga authored and sgtcoolguy committed Jul 23, 2020
1 parent 6b31037 commit 1c5327d
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -36,6 +36,7 @@ public class TiUITabbedBar extends TiUIView implements MenuItem.OnMenuItemClickL
private int style = AndroidModule.TABS_STYLE_DEFAULT;
private ArrayList<MenuItem> bottomNavigationMenuItems = new ArrayList<>();
private int bottomNavigationIndex = -1;
private boolean skipClickEvent = false;

/**
* Constructs a TiUIView object with the associated proxy.
Expand Down Expand Up @@ -251,6 +252,7 @@ public void setNewStyle(int newStyle)
// Recreate the native views from scratch in case the data set has been changed
public void setNewLabels()
{
skipClickEvent = true;
switch (((int) getProxy().getProperty(TiC.PROPERTY_STYLE))) {
case AndroidModule.TABS_STYLE_DEFAULT:
if (this.tabLayout != null) {
Expand All @@ -268,6 +270,7 @@ public void setNewLabels()
break;
}
parseDataSet();
skipClickEvent = false;
}

private void setSelectedIndex(Object value)
Expand Down Expand Up @@ -338,9 +341,11 @@ private void onTabIndexChangedTo(int index)
proxy.setProperty(TiC.PROPERTY_INDEX, index);

// Last, fire a "click" event.
KrollDict data = new KrollDict();
data.put(TiC.PROPERTY_INDEX, index);
proxy.fireEvent(TiC.EVENT_CLICK, data);
if (!skipClickEvent) {
KrollDict data = new KrollDict();
data.put(TiC.PROPERTY_INDEX, index);
proxy.fireEvent(TiC.EVENT_CLICK, data);
}
}
}

Expand Down

0 comments on commit 1c5327d

Please sign in to comment.