From 749ff1d67eb812c149f08fc705c87fa440e415a2 Mon Sep 17 00:00:00 2001 From: Joshua Quick Date: Thu, 23 Jul 2020 08:05:09 -0700 Subject: [PATCH] fix(android): fix TabbedBar Click loop (#11838) Fixes TIMOB-27779 --- .../ti/modules/titanium/ui/widget/TiUITabbedBar.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java index 6e91aa70bbe..f3c163e6f4a 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUITabbedBar.java @@ -36,6 +36,7 @@ public class TiUITabbedBar extends TiUIView implements MenuItem.OnMenuItemClickL private int style = AndroidModule.TABS_STYLE_DEFAULT; private ArrayList bottomNavigationMenuItems = new ArrayList<>(); private int bottomNavigationIndex = -1; + private boolean skipClickEvent = false; /** * Constructs a TiUIView object with the associated proxy. @@ -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) { @@ -268,6 +270,7 @@ public void setNewLabels() break; } parseDataSet(); + skipClickEvent = false; } private void setSelectedIndex(Object value) @@ -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); + } } }