From dfb1b5c312cbfac159fbae4d7277330dad71d6e0 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Wed, 21 Aug 2024 10:57:43 +0200 Subject: [PATCH] feat(android): fire `selected` event again when clicking the same Tab again (#14094) * feat(android): new 'reselected' event on a Tab * check for listener * reselected -> selected * docs --- .../ui/widget/tabgroup/TiUITabLayoutTabGroup.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java index a4d35f234a3..97d81da263e 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/widget/tabgroup/TiUITabLayoutTabGroup.java @@ -6,6 +6,7 @@ */ package ti.modules.titanium.ui.widget.tabgroup; +import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.common.Log; import org.appcelerator.titanium.TiBaseActivity; import org.appcelerator.titanium.TiC; @@ -412,6 +413,17 @@ public void onTabUnselected(TabLayout.Tab tab) @Override public void onTabReselected(TabLayout.Tab tab) { + if (tab != null) { + int index = tab.getPosition(); + if ((index >= 0) && (index < this.tabs.size())) { + TiViewProxy tabProxy = this.tabs.get(index).getProxy(); + if (tabProxy != null && tabProxy.hasListeners(TiC.EVENT_SELECTED)) { + KrollDict data = new KrollDict(); + data.put("index", index); + tabProxy.fireEvent(TiC.EVENT_SELECTED, data, false); + } + } + } } public void setTabMode(int value)