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

Android: scrollableView does not set activity to its views

    Details

      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

        Attachments

          Activity

            People

            • Assignee:
              sunila Sunila
              Reporter:
              farfromrefuge Martin Guillon (Inactive)
              Reviewer:
              Hieu Pham
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Source Code