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

Android: Problem with setTimeout and Toolbar on API 16/17

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 6.2.0
    • Component/s: None
    • Labels:
    • Environment:

      OS: Windows 10
      Emulators: Nexus 5 API 16 x86, Nexus 5 API 17 x86

      Description

      Happens on x86 emulators with Android API 16 or 17.
      When calling a timed out methods of Toolbar the application restarts after a native 'corrupted stack' error is logged.

      Application's theme must be set to Theme.Titanium for this example to work.
      Add the following in the <android> tag in tiapp.xml:

        <android 
          xmlns:android="http://schemas.android.com/apk/res/android">
          <manifest>
            <application android:theme="@style/Theme.Titanium"/>
          </manifest>
        </android>
      

      Steps to reproduce:
      1. Run the application.
      2. Click on the "Button" button once.
      3. Wait 3-4 seconds after the overflow menu is shown.

      Test case:

      var window = Ti.UI.createWindow();
       
      var toolbar = Ti.UI.createToolbar({
          extendBackground: false,
          barColor: 'blue',
          width: Ti.UI.FILL,
          top: 0,
          logo: 'logo.png',
          overflowIcon: 'git.png',
          navigationIcon: 'logo2.jpg'
      });
       
      var button = Ti.UI.createButton({
          title: 'Button',
          right: 10,
          top: 0
      });
       
      button.addEventListener('click', function(e) {
          Ti.API.info('BackgroundColor is ' + toolbar.getBackgroundColor());
          Ti.API.info('Title is ' + toolbar.getTitle());
          Ti.API.info('Subtitle is ' + toolbar.getSubtitle());
          Ti.API.info('Logo is ' + JSON.stringify(toolbar.getLogo()));
          Ti.API.info('Overflow icon is ' + JSON.stringify(toolbar.getOverflowIcon()));
          Ti.API.info('Navigation icon is ' + JSON.stringify(toolbar.getNavigationIcon()));
        
          toolbar.showOverflowMenu();
        
          setTimeout(function() {
              Ti.API.info('Is overflow menu showed? - ' + toolbar.isOverflowMenuShowing());
            
              toolbar.hideOverflowMenu();
              toolbar.setLogo('logo2.jpg');
              toolbar.setNavigationIcon('git.png');
              toolbar.setOverflowIcon('logo.png');
              toolbar.collapseActionView();
              toolbar.dismissPopupMenus();
              toolbar.setBarColor('red');
              toolbar.setTitle('New Title');
              toolbar.setTitleTextColor('orange');
              toolbar.setSubtitle('New Subtitle');
              toolbar.setSubtitleTextColor('blue');
            
              Ti.API.info('Content inset end is ' + toolbar.getContentInsetEnd());
              Ti.API.info('Content inset end with actions is ' + toolbar.getContentInsetEndWithActions());
              Ti.API.info('Content inset left is ' + toolbar.getContentInsetLeft());
              Ti.API.info('Content inset right is ' + toolbar.getContentInsetRight());
              Ti.API.info('Content inset start is ' + toolbar.getContentInsetStart());
              Ti.API.info('Content inset start with navigation is ' + toolbar.getContentInsetStartWithNavigation());
          }, 3000);
      });
       
      window.add(toolbar);
       
      window.activity.onCreateOptionsMenu = function(e) {
          var menu = e.menu;
          
          var menuItem = menu.add({
              title: 'Item 1',
              showAsAction: Ti.Android.SHOW_AS_ACTION_NEVER
          });
          
          menuItem.addEventListener('click', function(e) {
              Ti.API.debug('Item 1 was clicked');
          });
          
          var menuItem2 = menu.add({
              title: 'Item 2',
              showAsAction: Ti.Android.SHOW_AS_ACTION_NEVER
          });
          
          var menuItem3 = menu.add({
              title: 'Item 3',
              showAsAction: Ti.Android.SHOW_AS_ACTION_NEVER
          });
          
          var menuItem4 = menu.add({
              title: 'Item 4',
              showAsAction: Ti.Android.SHOW_AS_ACTION_NEVER
          });
      };
       
      window.activity.supportToolbar = toolbar;
       
      var picker = Ti.UI.createPicker();
       
      var data = [];
      data[0]=Ti.UI.createPickerRow({title:'Bananas'});
      data[1]=Ti.UI.createPickerRow({title:'Strawberries'});
      data[2]=Ti.UI.createPickerRow({title:'Mangos'});
      data[3]=Ti.UI.createPickerRow({title:'Grapes'});
       
      picker.add(data);
      toolbar.setItems([picker,button]);
      window.addEventListener('open', function() {
          window.activity.setSupportActionBar(toolbar);
          toolbar.setBarColor('blue');
          toolbar.setTitle('Title');
          toolbar.setTitleTextColor('red');
          toolbar.setSubtitle('Subtitle');
          toolbar.setSubtitleTextColor('green');    
          toolbar.setContentInsetEndWithActions(10);
          toolbar.setContentInsetStartWithNavigation(11);
          toolbar.setContentInsetsAbsolute(12,12);
          toolbar.setContentInsetsRelative(13, 13);
      });
       
      window.open();
      

        Attachments

          Activity

            People

            • Assignee:
              ybanev Yordan Banev
              Reporter:
              ybanev Yordan Banev
              Reviewer:
              Joshua Quick
              Tester:
              Abir Mukherjee
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Source Code