Change TitleBar RelativeLayout to LinearLayout
Moving from RelativeLayout to LinearLayout improves
the UI layout time by 50%
This change also contains lazy initialization of
some of the Drawables in BaseUi.
Change-Id: Ie6d3f845098a79bc47e21a0d21f2a8d3ab97237a
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 354e901..fbb5ad0 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -87,7 +87,7 @@
private Drawable mLockIconSecure;
private Drawable mLockIconMixed;
- protected Drawable mGenericFavicon;
+ private Drawable mGenericFavicon;
protected FrameLayout mContentView;
protected FrameLayout mCustomViewContainer;
@@ -121,8 +121,6 @@
Resources res = mActivity.getResources();
mInputManager = (InputMethodManager)
browser.getSystemService(Activity.INPUT_METHOD_SERVICE);
- mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark);
- mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark);
FrameLayout frameLayout = (FrameLayout) mActivity.getWindow()
.getDecorView().findViewById(android.R.id.content);
LayoutInflater.from(mActivity)
@@ -136,8 +134,6 @@
mErrorConsoleContainer = (LinearLayout) frameLayout
.findViewById(R.id.error_console);
setFullscreen(BrowserSettings.getInstance().useFullscreen());
- mGenericFavicon = res.getDrawable(
- R.drawable.app_web_browser_sm);
mTitleBar = new TitleBar(mActivity, mUiController, this,
mContentView);
mTitleBar.setProgress(100);
@@ -152,6 +148,27 @@
}
}
+ private Drawable getLockIconSecure() {
+ if (mLockIconSecure == null) {
+ mLockIconSecure = mActivity.getResources().getDrawable(R.drawable.ic_secure_holo_dark);
+ }
+ return mLockIconSecure;
+ }
+
+ private Drawable getLockIconMixed() {
+ if (mLockIconMixed == null) {
+ mLockIconMixed = mActivity.getResources().getDrawable(R.drawable.ic_secure_partial_holo_dark);
+ }
+ return mLockIconMixed;
+ }
+
+ protected Drawable getGenericFavicon() {
+ if (mGenericFavicon == null) {
+ mGenericFavicon = mActivity.getResources().getDrawable(R.drawable.app_web_browser_sm);
+ }
+ return mGenericFavicon;
+ }
+
// lifecycle
public void onPause() {
@@ -631,12 +648,12 @@
private void updateLockIconImage(SecurityState securityState) {
Drawable d = null;
if (securityState == SecurityState.SECURITY_STATE_SECURE) {
- d = mLockIconSecure;
+ d = getLockIconSecure();
} else if (securityState == SecurityState.SECURITY_STATE_MIXED
|| securityState == SecurityState.SECURITY_STATE_BAD_CERTIFICATE) {
// TODO: It would be good to have different icons for insecure vs mixed content.
// See http://b/5403800
- d = mLockIconMixed;
+ d = getLockIconMixed();
}
mNavigationBar.setLock(d);
}
@@ -813,7 +830,7 @@
PaintDrawable p = new PaintDrawable(Color.WHITE);
array[1] = p;
if (icon == null) {
- array[2] = mGenericFavicon;
+ array[2] = getGenericFavicon();
} else {
array[2] = new BitmapDrawable(icon);
}