Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15280] Android: can't reopen tab group

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-20T21:04:38.000+0000
Affected Version/sRelease 3.1.2
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API, Release 3.2.0
ComponentsAndroid
LabelsTab, qe-closed-3.2.0, qe-testadded, regression, tabgroup
ReporterMostafizur Rahman
AssigneePing Wang
Created2013-09-19T09:11:22.000+0000
Updated2013-09-26T23:05:47.000+0000

Description

On SDK 3.1.0, I can close and reopen a tabgroup. On SDK 3.1.2, I can't do it any more. It's a login/logout mechanism I implement. Users can log in/log out as many times as they want. In the sample code, click "Log out" to close the tab group. Click "Log in" to reopen the tab group. You'll see you can do this on 3.1.0, but not 3.1.2. We are about to release this app, so it's kind of urgent. If possible, please fix it or provide a workaround asap (without changing this mechanism too much). Thank you.
var tabGroup = Titanium.UI.createTabGroup();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});

var tab1 = Titanium.UI.createTab({  
    title:'Tab 1',
    window:win1
});

var btn = Ti.UI.createButton({title:'Log out'});
btn.addEventListener('click',function(){
    tabGroup.close();
});
win1.add(btn);

//
// create controls tab and root window
//
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',
    font:{fontSize:20,fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto'
});

win2.add(label2);

//
//  add tabs
//
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  

var loginWin = Ti.UI.createWindow({exitOnClose:true,navBarHidden:false,title:'Login'});
btn2 = Ti.UI.createButton({title:'Log in'});
loginWin.add(btn2);
loginWin.addEventListener('click',function(){
    tabGroup.open();
});
loginWin.open();
loginWin.addEventListener('open',function(){
    tabGroup.open();
});

Comments

  1. Ping Wang 2013-09-19

    There is a bug in the tabgroup.close() method even before 3.1.2.GA. I attached a modified test case below. By running that test case with 3.1.1.GA, we can see the tabgroup's "open" event is fired but no "close" event is fired after clicking the "Log out" button. This bug will eventually lead to a memory leak. After we fixed TIMOB-14751, this bug is exposed. Since the tabgroup does not fire the "close" event, we don't allow it to open again. That's why the tabgroup can not reopen.
       var tabGroup = Titanium.UI.createTabGroup();
        
        
       //
       // create base UI tab and root window
       //
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
        
       var tab1 = Titanium.UI.createTab({  
           title:'Tab 1',
           window:win1
       });
        
       var btn = Ti.UI.createButton({title:'Log out'});
       btn.addEventListener('click',function(){
           tabGroup.close();
       });
       win1.add(btn);
        
       //
       // create controls tab and root window
       //
       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',
           font:{fontSize:20,fontFamily:'Helvetica Neue'},
           textAlign:'center',
           width:'auto'
       });
        
       win2.add(label2);
        
       //
       //  add tabs
       //
       tabGroup.addTab(tab1);  
       tabGroup.addTab(tab2);
       
       tabGroup.addEventListener("open", function(){
       	Ti.API.info("********************* tabGroup open");
       });
       tabGroup.addEventListener("close", function(){
       	Ti.API.info("********************* tabGroup close");
       });
        
       var loginWin = Ti.UI.createWindow({exitOnClose:true,navBarHidden:false,title:'Login'});
       btn2 = Ti.UI.createButton({title:'Log in'});
       loginWin.add(btn2);
       loginWin.addEventListener('click',function(){
           tabGroup.open();
       });
       loginWin.open();
       loginWin.addEventListener('open',function(){
           tabGroup.open();
       });
       
  2. Ping Wang 2013-09-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/4716
  3. Olga Romero 2013-09-26

    Tested and verified the ability to log in/log out as many times as I want Appcelerator Studio, build: 3.1.3.201309132456 Titanium SDK 3.2.0.v20130926123242 CLI 3.2.0 Devices: Nexus7 Android version 4.3 Nexus4 Android version 4.3

JSON Source