[TIMOB-14399] Android: scrollableView does not set activity to its views
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-09-30T19:44:39.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 20, 2013 Sprint 20 API, Release 3.2.0 |
Components | Android |
Labels | android, module_scrollableview, qe-manualtest, qe-testadded, scrollableview, webview |
Reporter | Martin Guillon |
Assignee | Sunila |
Created | 2013-06-19T08:21:53.000+0000 |
Updated | 2014-11-20T22:09:24.000+0000 |
Description
*Steps to reproduce*
1. Run the sample code
2. Click on the button
3. It opens a window which contains a webview with a blue background. The webview is inside a scrollableview.
4. Upon opening you will see the webview being removed (strangely also the html content is still there …)
*Test case*
var win = Ti.UI.createWindow({
backgroundColor : 'white',
fullscreen : false,
navBarHidden : true,
exitOnClose : true
});
var html = "<html><head><script>function showMessage(e) {Ti.API.info('showMessage: ' + e);};</script></head><body>Hello world</body></html>"
var button = Ti.UI.createButton({
title : 'open',
bottom : '30'
});
button.addEventListener('click', function() {
var win2 = Ti.UI.createWindow({
backgroundColor : 'yellow',
fullscreen : false,
navBarHidden : true
});
var webview2 = Ti.UI.createWebView({
backgroundColor : 'blue',
width : 100,
height : 100,
html : html,
showScrollbars : false,
scalesPageToFit : true,
enableZoomControls : false,
touchEnabled : false
});
webview2.addEventListener('load', function() {
webview2.evalJS('showMessage(\"Hello!2\");');
})
var scrollableview = Ti.UI.createScrollableView({
views : [webview2]
})
win2.add(scrollableview);
win2.open();
win.close();
});
win.add(button);
win.open();
*Solution*
It took me a day to find out what was happening. The reason is that the scrollableView does not call setActivity on its views.
It matters in this sample because i close the first window when opening the second one.
So this is what happens:
- create win2
- create webview : activity set to current activity = activity of win
- open win2: setActivity called on the scrollableview but not its views
- createView is called on the webview. there the WebviewProxy add a LifeCycleEvent on it s activity which is the one from win
- close win: it s activity is destroyed WebviewProxy
- onDestroy is wrongly called on the WebviewProxy
Will add a PR
Pull request https://github.com/appcelerator/titanium_mobile/pull/4402
Could you clarify what you mean by "Upon opening you will see the webview being removed (strangely also the html content is still there …)" - I don't see any visual indication of this, the web view with the blue background is visible. Tested on Samsung Galaxy S2 2.3.6, Ti SDK 3.1.1 GA. Just need to be sure.
@Daniel: look at the background colors. It should be blue (webview) and it will be yellow). And i dont know about 2.3.6. As mentioned in my bug request it s been tested on > 4.0 But seeing that it is an obvious bug you should see it too.
Additional changes as per the comment in the original pull request https://github.com/appcelerator/titanium_mobile/pull/4668
PR https://github.com/appcelerator/titanium_mobile/pull/4728 merged. Resolving.
Test Environment - Appc Studio - 3.2.0.201310181700 SDK - 3.2.0.v20131021142445 acs - 1.0.7 alloy - 1.2.2 titanium - 3.2.0 titanium-code-processor - 1.0.3 Xcode - 5.0 OS - Mountain Lion (10.8.5) Devices - Nexus 7(v4.2.1), Galaxy Note (v2.3.6) Result - Now its working fine. hence closing this issue.