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

Android: Getting/Setting TabGroup "activeTab" property before open causes a crash as of 8.0.0.RC

    Details

    • Story Points:
      8
    • Sprint:
      2019 Sprint 4, 2019 Sprint 5, 2019 Sprint 6

      Description

      Summary:
      Getting or setting the TabGroup "activeTab" property (or calling getActiveTab() or setActiveTab() methods) before the TabGroup has been opened causes a crash on Android as of Titanium 8.0.0.RC.

      Steps to reproduce

      1. Build and run the below code via Titanium 8.0.0.RC on Android.
      2. Notice the app crashes on startup.

      Testcase

      var tabGroup = Ti.UI.createTabGroup();
       
      var win1 = Titanium.UI.createWindow({
          title: 'Tab 1',
          backgroundColor: '#fff'
      });
      var tab1 = Titanium.UI.createTab({
          title: 'Tab 1',
          window: win1
      });
       
      var label1 = Titanium.UI.createLabel({
          color: '#999',
          text: 'I am Window 1',
          textAlign: 'center',
          width: 'auto'
      });
       
      win1.add(label1);
      var win2 = Titanium.UI.createWindow({
          title: 'Tab 2',
          backgroundColor: '#fff'
      });
      var tab2 = Titanium.UI.createTab({
          title: 'Tab 2',
          window: win2
      });
       
      var label2 = Titanium.UI.createLabel({
          color: '#999',
          text: 'I am Window 2',
          textAlign: 'center',
          width: 'auto'
      });
       
      win2.add(label2);
      tabGroup.addTab(tab1);
      tabGroup.addTab(tab2);
      tabGroup.activeTab = 1;
      Ti.API.info("### activeTab: " + tabGroup.activeTab);
      tabGroup.open();
      

      Expected
      No error is thrown and the seconf tab is in focus

      Actual

      [ERROR] TiExceptionHandler: (main) [70,70] Attempt to invoke virtual method 'void ti.modules.titanium.ui.widget.tabgroup.TiUITab.onSelectionChange(boolean)' on a null object reference
      [ERROR] TiExceptionHandler:
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TabProxy.onSelectionChanged(TabProxy.java:220)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.onTabSelected(TabGroupProxy.java:551)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.onTabSelected(TabGroupProxy.java:521)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUITabLayoutTabGroup.onTabSelected(TiUITabLayoutTabGroup.java:232)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1165)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout.selectTab(TabLayout.java:1158)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout.selectTab(TabLayout.java:1128)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1427)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout.addTab(TabLayout.java:483)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout.addTab(TabLayout.java:465)
      [ERROR] TiExceptionHandler:     android.support.design.widget.TabLayout.addTab(TabLayout.java:444)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUITabLayoutTabGroup.addTabItemInController(TiUITabLayoutTabGroup.java:159)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup.addTab(TiUIAbstractTabGroup.java:199)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:442)
      [ERROR] TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.windowCreated(TabGroupProxy.java:416)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:33)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:624)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:767)
      [ERROR] TiExceptionHandler:     org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:21)
      [ERROR] TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:6975)
      [ERROR] TiExceptionHandler:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
      [ERROR] TiExceptionHandler:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
      [ERROR] TiExceptionHandler:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
      [ERROR] TiExceptionHandler:     android.app.ActivityThread.-wrap11(Unknown Source:0)
      [ERROR] TiExceptionHandler:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
      [ERROR] TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:105)
      [ERROR] TiExceptionHandler:     android.os.Looper.loop(Looper.java:164)
      [ERROR] TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:6541)
      [ERROR] TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
      [ERROR] TiExceptionHandler:     com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
      [ERROR] TiExceptionHandler:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
      

      Note:
      It will crash when set via a Ti.UI.createTabGroup() creation property as well.

      Work-Around:
      You can set the active tab after the TabGroup has been opened as shown below.

      tabGroup.addEventListener("open", function() {
      	tabGroup.activeTab = 1;
      });
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ybanev Yordan Banev
                Reporter:
                jlongton Josh Longton
                Reviewer:
                Joshua Quick
                Tester:
                Keerthi Mahalingam (Inactive)
              • Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-21049
                    Sync status:
                    PENDING
                    Last received:
                    Last sent:

                    Git Source Code