Fix crash with qc

 Bug: 5439827

Change-Id: Ic561a5c7689410dd917e01c27e9b454a8722f957
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index 45b1dcc..14b1e84 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -110,7 +110,8 @@
     }
 
     public void refreshAdapter() {
-        mAdapter.notifyDataSetChanged();
+        mScroller.handleDataChanged(
+                mUiController.getTabControl().getTabPosition(mUi.getActiveTab()));
     }
 
     private void init() {
diff --git a/src/com/android/browser/NavTabScroller.java b/src/com/android/browser/NavTabScroller.java
index 8251928..1dfddff 100644
--- a/src/com/android/browser/NavTabScroller.java
+++ b/src/com/android/browser/NavTabScroller.java
@@ -213,7 +213,7 @@
         handleDataChanged(INVALID_POSITION);
     }
 
-    protected void handleDataChanged(int newscroll) {
+    void handleDataChanged(int newscroll) {
         int scroll = getScrollValue();
         if (mGapAnimator != null) {
             mGapAnimator.cancel();
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index ddb4e0e..d39909e 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -324,8 +324,7 @@
             mAnimScreen = new AnimScreen(mActivity);
         }
         mAnimScreen.set(getTitleBar(), getWebView());
-        final View animView = mAnimScreen.mMain;
-        mCustomViewContainer.addView(animView, COVER_SCREEN_PARAMS);
+        mCustomViewContainer.addView(mAnimScreen.mMain, COVER_SCREEN_PARAMS);
         mCustomViewContainer.setVisibility(View.VISIBLE);
         mCustomViewContainer.bringToFront();
         int fromLeft = 0;
@@ -356,7 +355,8 @@
                 1f, 0f);
         ObjectAnimator sx = ObjectAnimator.ofFloat(mAnimScreen, "scaleFactor",
                 1f, scaleFactor);
-        ObjectAnimator blend1 = ObjectAnimator.ofFloat(mAnimScreen.mMain, "alpha", 1, 0);
+        ObjectAnimator blend1 = ObjectAnimator.ofFloat(mAnimScreen.mMain,
+                "alpha", 1f, 0f);
         blend1.setDuration(100);
 
         inanim.playTogether(tx, ty, tr, tb, sx, title);
@@ -364,7 +364,7 @@
         set1.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator anim) {
-                mCustomViewContainer.removeView(animView);
+                mCustomViewContainer.removeView(mAnimScreen.mMain);
                 finishAnimationIn();
                 mUiController.setBlockEvents(false);
             }
@@ -512,15 +512,19 @@
         }
 
         public void set(TitleBar tbar, WebView web) {
-            if (mTitleBarBitmap == null
-                    || mTitleBarBitmap.getWidth() != tbar.getWidth()
-                    || mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) {
-                mTitleBarBitmap = Bitmap.createBitmap(tbar.getWidth(),
-                        tbar.getEmbeddedHeight(), Bitmap.Config.RGB_565);
+            if (tbar.getWidth() > 0 && tbar.getEmbeddedHeight() > 0) {
+                if (mTitleBarBitmap == null
+                        || mTitleBarBitmap.getWidth() != tbar.getWidth()
+                        || mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) {
+                    mTitleBarBitmap = Bitmap.createBitmap(tbar.getWidth(),
+                            tbar.getEmbeddedHeight(), Bitmap.Config.RGB_565);
+                }
+                Canvas c = new Canvas(mTitleBarBitmap);
+                tbar.draw(c);
+                c.setBitmap(null);
+            } else {
+                mTitleBarBitmap = null;
             }
-            Canvas c = new Canvas(mTitleBarBitmap);
-            tbar.draw(c);
-            c.setBitmap(null);
             mTitle.setImageBitmap(mTitleBarBitmap);
             mTitle.setVisibility(View.VISIBLE);
             int h = web.getHeight() - tbar.getEmbeddedHeight();
@@ -530,7 +534,7 @@
                 mContentBitmap = Bitmap.createBitmap(web.getWidth(), h,
                         Bitmap.Config.RGB_565);
             }
-            c.setBitmap(mContentBitmap);
+            Canvas c = new Canvas(mContentBitmap);
             int tx = web.getScrollX();
             int ty = web.getScrollY();
             c.translate(-tx, -ty - tbar.getEmbeddedHeight());