Wait for WebView to be ready when hiding NavScreen
When hiding the NavScreen, don't fade out the CustomerViewContainer
until the WebView is ready. This avoids exposing the
Tab that is still not ready for display and results in flashing.
Change-Id: Ie92db545251ab45121fdf1d90a0b1648fa3a00c0
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index 5aefc92..477f006 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -423,21 +423,59 @@
fromBottom, toBottom);
ObjectAnimator scale = ObjectAnimator.ofFloat(mAnimScreen, "scaleFactor",
1f, scaleFactor);
- ObjectAnimator otheralpha = ObjectAnimator.ofFloat(mCustomViewContainer, "alpha", 1f, 0f);
- otheralpha.setDuration(100);
set2.playTogether(l, t, r, b, scale);
set2.setDuration(200);
AnimatorSet combo = new AnimatorSet();
- combo.playSequentially(set1, set2, otheralpha);
+ combo.playSequentially(set1, set2);
combo.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
+ checkTabReady();
+ }
+ });
+ combo.start();
+ }
+
+ private void checkTabReady() {
+ boolean isready = true;
+ Tab tab = mUiController.getTabControl().getCurrentTab();
+ if (tab == null)
+ isready = false;
+ else {
+ BrowserWebView webview = (BrowserWebView)tab.getWebView();
+ if (webview == null)
+ isready = false;
+ else
+ isready = webview.isReady();
+ }
+ android.os.Handler handler = mCustomViewContainer.getHandler();
+ if (!isready) {
+ handler.postDelayed(new Runnable() {
+ public void run() {
+ checkTabReady();
+ }
+ }, 17); //WebView is not ready. check again in for next frame.
+ return;
+ }
+ handler.postDelayed(new Runnable() {
+ public void run() {
+ fadeOutCustomViewContainer();
+ }
+ }, 33); //WebView is ready, but give it extra 2 frame's time to display and finish the swaps
+ }
+
+ private void fadeOutCustomViewContainer() {
+ ObjectAnimator otheralpha = ObjectAnimator.ofFloat(mCustomViewContainer, "alpha", 1f, 0f);
+ otheralpha.setDuration(100);
+ otheralpha.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator anim) {
mCustomViewContainer.removeView(mAnimScreen.mMain);
finishAnimateOut();
mUiController.setBlockEvents(false);
}
});
- combo.start();
+ otheralpha.start();
}
private void finishAnimateOut() {