Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27302

Android: Bottom style TabGroup with more than 5 tabs crashes when swiping left on 5th tab

    Details

      Description

      Summary:
      On Android, if you set up a TabGroup with style TABS_STYLE_BOTTOM_NAVIGATION and more than 5 tabs, then swiping left on the 5th tab will cause a crash with an IndexOutOfBoundsException.

      Note 1:
      Android's bottom style tabs only natively supports up to 5 tabs, making this a minor issue. If you want to use more than 5 tabs, then you have to use the top tab style instead.

      Note 2:
      Titanium correctly renders up to 5 tabs without issue if given more than 5 tabs. We will log the following error message when attempting to do so. We just need a boundary check when switching tabs via gestures.

      [ERROR] :  TiUITabLayoutTabGroup: (main) [190,190] Trying to add more than five tabs in a TabGroup with TABS_STYLE_BOTTOM_NAVIGATION style.
      

      Steps to reproduce:

      1. Build and run the below code on Android.
      2. Tap on the 5th tab.
      3. Put your finger on the center of the screen and drag left.
      4. Notice that the app crashes/hangs.

      function createTab(title) {
      	var window = Ti.UI.createWindow({ title: title });
      	window.add(Ti.UI.createLabel({ text: title + " View" }));
      	var tab = Ti.UI.createTab({
      		title: title,
      		window: window,
      	});
      	return tab;
      }
       
      var tabGroupSettings = {
      	tabs: [
      		createTab("Tab 1"),
      		createTab("Tab 2"),
      		createTab("Tab 3"),
      		createTab("Tab 4"),
      		createTab("Tab 5"),
      		createTab("Tab 6")
      	],
      };
      if (Ti.Platform.name === "android") {
      	tabGroupSettings.shiftMode = false;
      	tabGroupSettings.style = Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION;
      }
      var tabGroup = Ti.UI.createTabGroup(tabGroupSettings);
      tabGroup.open();
      

      Result:
      The app throws the following exception when dragging left on the 5th tab.

      [ERROR] :  E/MessageQueue-JNI: java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
      [ERROR] :  E/MessageQueue-JNI: 	at java.util.ArrayList.get(ArrayList.java:437)
      [ERROR] :  E/MessageQueue-JNI: 	at android.support.v7.view.menu.MenuBuilder.getItem(MenuBuilder.java:741)
      [ERROR] :  E/MessageQueue-JNI: 	at ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.selectTabItemInController(TiUIBottomNavigationTabGroup.java:234)
      [ERROR] :  E/MessageQueue-JNI: 	at ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup$2.onPageSelected(TiUIAbstractTabGroup.java:364)
      [ERROR] :  E/MessageQueue-JNI: 	at android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1941)
      [ERROR] :  E/MessageQueue-JNI: 	at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:680)
      [ERROR] :  E/MessageQueue-JNI: 	at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:664)
      [ERROR] :  E/MessageQueue-JNI: 	at android.support.v4.view.ViewPager.onTouchEvent(ViewPager.java:2257)
      [ERROR] :  E/MessageQueue-JNI: 	at ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup$1.onTouchEvent(TiUIAbstractTabGroup.java:176)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.View.dispatchTouchEvent(View.java:12513)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3024)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2705)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  E/MessageQueue-JNI: 	at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:440)
      [ERROR] :  E/MessageQueue-JNI: 	at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1830)
      [ERROR] :  E/MessageQueue-JNI: 	at android.app.Activity.dispatchTouchEvent(Activity.java:3400)
      [ERROR] :  E/MessageQueue-JNI: 	at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
      [ERROR] :  E/MessageQueue-JNI: 	at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:398)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.View.dispatchPointerEvent(View.java:12752)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5106)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4909)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4426)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4479)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4445)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4585)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4453)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4642)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4426)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4479)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4445)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4453)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4426)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7092)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7061)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7022)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7195)
      [ERROR] :  E/MessageQueue-JNI: 	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:186)
      [ERROR] :  E/MessageQueue-JNI: 	at android.os.MessageQueue.nativePollOnce(Native Method)
      [ERROR] :  E/MessageQueue-JNI: 	at android.os.MessageQueue.next(MessageQueue.java:326)
      [ERROR] :  E/MessageQueue-JNI: 	at android.os.Looper.loop(Looper.java:160)
      [ERROR] :  E/MessageQueue-JNI: 	at android.app.ActivityThread.main(ActivityThread.java:6680)
      [ERROR] :  E/MessageQueue-JNI: 	at java.lang.reflect.Method.in
      [ERROR] :  TiExceptionHandler: (main) [22369,22559] Index: 5, Size: 5
      [ERROR] :  TiExceptionHandler:
      [ERROR] :  TiExceptionHandler:     java.util.ArrayList.get(ArrayList.java:437)
      [ERROR] :  TiExceptionHandler:     android.support.v7.view.menu.MenuBuilder.getItem(MenuBuilder.java:741)
      [ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.selectTabItemInController(TiUIBottomNavigationTabGroup.java:234)
      [ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup$2.onPageSelected(TiUIAbstractTabGroup.java:364)
      [ERROR] :  TiExceptionHandler:     android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1941)
      [ERROR] :  TiExceptionHandler:     android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:680)
      [ERROR] :  TiExceptionHandler:     android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:664)
      [ERROR] :  TiExceptionHandler:     android.support.v4.view.ViewPager.onTouchEvent(ViewPager.java:2257)
      [ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup$1.onTouchEvent(TiUIAbstractTabGroup.java:176)
      [ERROR] :  TiExceptionHandler:     android.view.View.dispatchTouchEvent(View.java:12513)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3024)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2705)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3030)
      [ERROR] :  TiExceptionHandler:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2719)
      [ERROR] :  TiExceptionHandler:     com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:440)
      [ERROR] :  TiExceptionHandler:     com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1830)
      [ERROR] :  TiExceptionHandler:     android.app.Activity.dispatchTouchEvent(Activity.java:3400)
      [ERROR] :  TiExceptionHandler:     android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
      [ERROR] :  TiExceptionHandler:     com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:398)
      [ERROR] :  TiExceptionHandler:     android.view.View.dispatchPointerEvent(View.java:12752)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5106)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4909)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4426)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4479)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4445)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4585)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4453)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4642)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4426)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4479)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4445)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4453)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4426)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7092)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7061)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7022)
      [ERROR] :  TiExceptionHandler:     android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7195)
      [ERROR] :  TiExceptionHandler:     android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:186)
      [ERROR] :  TiExceptionHandler:     android.os.MessageQueue.nativePollOnce(Native Method)
      [ERROR] :  TiExceptionHandler:     android.os.MessageQueue.next(MessageQueue.java:326)
      [ERROR] :  TiExceptionHandler:     android.os.Looper.loop(Looper.java:160)
      [ERROR] :  TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:6680)
      

        Attachments

          Activity

            People

            • Assignee:
              ybanev Yordan Banev
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Joshua Quick
              Tester:
              Keerthi Mahalingam
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code