New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TIMOB-17016-Since Android restore fragments on orientation change, make ... #5836
Conversation
…ke sure the properties are set correctly
|
||
public TiUIActionBarTabGroup(TabGroupProxy proxy, TiBaseActivity activity) { | ||
super(proxy, activity); | ||
|
||
tabActivity = new WeakReference<TiBaseActivity>(activity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the activity should already be set with the proxy. You just need to call proxy.getActivity() to get the activity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had tried this but the activity that is returned from the TabGroupProxy is the main application activity and not the window activity. The window activity is stored in the variable tabGroupActivity and is exposed through getWindowActivity but it is protected method.
Functional looks good, just a minor comment. |
|
||
public TiUIActionBarTab(TabProxy proxy, ActionBar.Tab tab) { | ||
super(proxy); | ||
|
||
tabTag = TAB_TAG_NAME + proxy.getTabGroup().getTabIndex(proxy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabTag needs to be updated for remaining tabs when a tab is removed. If you run this test case, click delete tab2, then add tab4, then open and close window 2, it will crash.
var tabWin1 = Ti.UI.createWindow({title : 'TW1',backgroundColor:'blue'});
var tabWin2 = Ti.UI.createWindow({title : 'TW2',backgroundColor:'red'});
var tabWin3 = Ti.UI.createWindow({title : 'TW3',backgroundColor:'green'});
var tabWin4 = Ti.UI.createWindow({title : 'TW4',backgroundColor:'yellow'});
var tab1 = Ti.UI.createTab({window : tabWin1,title : 'Tab 1'});
var tab2 = Ti.UI.createTab({window : tabWin2,title : 'Tab 2'});
var tab3 = Ti.UI.createTab({window : tabWin3,title : 'Tab 3'});
var tab4 = Ti.UI.createTab({window : tabWin4,title : 'Tab 4'});
var tabGroup = Ti.UI.createTabGroup({tabs : [tab1,tab2,tab3]});
var win2 = Ti.UI.createWindow({title: 'Window 2'});
var openWindowButton = Ti.UI.createButton({widht:Ti.UI.SIZE,height:Ti.UI.SIZE,title:'Open window2'});
var deleteTabButton = Ti.UI.createButton({top: 10, title: 'Delete Tab2'});
var addTabButton = Ti.UI.createButton({bottom: 10, title: 'Add Tab4'});
tabWin1.add(deleteTabButton);
tabWin1.add(openWindowButton);
tabWin1.add(addTabButton);
var closeWindowButton = Ti.UI.createButton({widht:Ti.UI.SIZE,height:Ti.UI.SIZE,title:'Close window2'});
win2.add(closeWindowButton);
openWindowButton.addEventListener('click',function(e){win2.open();});
deleteTabButton.addEventListener('click', function(e){tabGroup.removeTab(tab2)});
addTabButton.addEventListener('click', function(e){tabGroup.addTab(tab4)});
closeWindowButton.addEventListener('click',function(e){win2.close();});
tabGroup.open();
Updated the PR to use incremental index to generate the tag name |
Moved the code that assign tag value to proxy |
Functionally test failed. Still crashes occasionally with the test case I posted. |
Any update on this? |
I strongly suggest you take care of this one first: #5651 |
Hieu, |
I would prefer if #5651 be merged first since it is a large PR and much of the fragment handling changes. I confirmed the bug exists there too, unfortunately. In my opinion it will be less overall effort to merge the scrollable tabs and then fix this issue. |
Ok, I can reproduce this crash effectively now. First, uninstall your app, then do a fresh install. Once you run my test case, click on 'Tab 2', then 'Tab 3' so they're all loaded. Then click on 'Tab 1', then tap on 'Delete Tab2', then 'Open window2', and 'Close window2', app will crash with this error: E/TiApplication(17533): Caused by: java.lang.NullPointerException |
… fragment manager also
Fixed the crash issue after the tab is removed. |
@hieupham007 where is your test case app? unable to find it, thanks. |
@mokesmokes, It was in one of my comments in this PR, but I posted it in the ticket. |
CR + FR looks good to me. |
TIMOB-17016-Since Android restore fragments on orientation change, make ...
Added empty constructor so that Android can restore the state. Since Android restore fragments on orientation change, make sure the properties are set correctly
https://jira.appcelerator.org/browse/TIMOB-17016