Skip to content

Commit

Permalink
Merge pull request #17 from blackberry-webworks/next-SplashScreenFlic…
Browse files Browse the repository at this point in the history
…kerFix

Add the work around to hide the white flicker after splash screen

Fixes blackberry#12
  • Loading branch information
nukulb committed Sep 29, 2011
2 parents 0de95fd + 9e4127d commit 2b89fa4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions framework/src/WebWorksAppTemplate.as
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ package
import webworks.service.ServiceManager;
import webworks.webkit.WebkitControl;
import webworks.webkit.WebkitEvent;

import flash.events.TimerEvent;

[SWF(width="1024", height="600", frameRate="30", backgroundColor="#000000")]
public class WebWorksAppTemplate extends Sprite
Expand All @@ -58,6 +60,8 @@ package
private var _broker:FunctionBroker;
private var _serviceManager:ServiceManager;

private var _loadingScreenTimer:Timer;

public function WebWorksAppTemplate()
{
if (stage) {
Expand Down Expand Up @@ -112,6 +116,7 @@ package
_transitions = new Transitions(_loadingScreen, _webWindow.viewPort);
_serviceManager = new ServiceManager(_webWindow);
_broker = new FunctionBroker(_webWindow.qnxWebView, _serviceManager);
_loadingScreenTimer = null;

var configProperties:Dictionary = ConfigData.getInstance().properties;
configProperties["serviceManager"] = _serviceManager;
Expand Down Expand Up @@ -234,6 +239,23 @@ package
private function tabLoadComplete(event:WebkitEvent):void
{
trace("HTML LOAD DONE");

var onFirstLaunch:Boolean = ConfigData.getInstance().getProperty(ConfigConstants.ONFIRSTLAUNCH)
if (_webWindow.qnxWebView.visible) {
_loadingScreen.hideIfNecessary();
} else {
// if the WebView is invisible, it means it's set to hidden in order to hide the white flicker;
// we can set the visibility to true but we shouldn't show it (by hiding the loading screen) right now;
// insteadly, we need a timer to hide the loading screen after the visibility change;
// because if not, we will still see the white flicker.
_webWindow.qnxWebView.visible = true;
_loadingScreenTimer = new Timer(400, 1);
_loadingScreenTimer.addEventListener(TimerEvent.TIMER, runOnce);
_loadingScreenTimer.start();
}
}

private function runOnce(event:TimerEvent):void {
_loadingScreen.hideIfNecessary();
}

Expand Down
5 changes: 5 additions & 0 deletions framework/src/webworks/webkit/WebkitControl.as
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ package webworks.webkit
{
var wv:QNXStageWebView = new QNXStageWebView();

// if onFirstLaunch is true, we need hide the QNXStageWebView to hide the white flicker from it
if (ConfigData.getInstance().getProperty(ConfigConstants.ONFIRSTLAUNCH)) {
wv.visible = false;
}

//Apply default properties
for(var webViewProp:String in defaultSettings) {
trace("Applying QNXStageWebView property: " + webViewProp + " = " + defaultSettings[webViewProp]);
Expand Down

0 comments on commit 2b89fa4

Please sign in to comment.