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

Android: removeEventListener does not work for the CI Builds

    Details

    • Story Points:
      2

      Description

      removeEventListener does not work on android, when used to remove and eventlistener on 'focus' event.

      Run the code below. Do the following:

      open app
      alert comes up - clear it
      click on Win 2's tab
      click on Win 1's tab
      Observed behavior: alert comes up again (the event listener wasn't removed during the call to onFocus ()).

      Expected behavior: the second alert should not come up (the event listener should have been removed during the call to onFocus())

      Thinking that maybe it was because I was calling removeEventListener() from within the event listener function, I also added a button that should remove the event listener from the window. It doesn't work either.

      var tabGroup = Ti.UI.createTabGroup();
       
      var win1 = Ti.UI.createWindow({ backgroundColor: '#fff', title: 'Win 1' });
      tabGroup.addTab(Ti.UI.createTab({
          window: win1,
          title: win1.title
      }));
       
      var win2 = Ti.UI.createWindow({ backgroundColor: '#666', title: 'Win 2' });
      tabGroup.addTab(Ti.UI.createTab({
          window: win2,
          title: win2.title
      }));
       
      var onFocus = function ()
      {
          alert('[focus] size: ' + win1.size.width + ', ' + win1.size.height);    
          win1.removeEventListener ('focus', onFocus);
      }
       
      win1.addEventListener('focus', onFocus);
       
      var btn1 = Titanium.UI.createButton({
          width: 200,
          height: 50,
          title: 'Click me',
      });
       
      btn1.addEventListener('click', function(e) {
          win1.removeEventListener ('focus', onFocus);
      });
      win1.add(btn1);
       
       
      tabGroup.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                opiecyrus Opie Cyrus
                Reporter:
                dgandhi Devang Gandhi
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Integration