Bug 708394: Remove unwanted LayoutInflater [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian
2011-12-07 15:12:51 -08:00
parent 3400c4cb51
commit 68532fad1d
11 changed files with 97 additions and 52 deletions

View File

@@ -79,9 +79,6 @@ public class AboutHomeContent extends LinearLayout {
public AboutHomeContent(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.abouthome_content, this);
}
private static final String LOGTAG = "GeckoAboutHome";

View File

@@ -92,6 +92,7 @@ public class AwesomeBarTabs extends TabHost {
private static enum HistorySection { TODAY, YESTERDAY, WEEK, OLDER };
private Context mContext;
private boolean mInflated;
private OnUrlOpenListener mUrlOpenListener;
private View.OnTouchListener mListTouchListener;
private JSONArray mSearchEngines;
@@ -512,13 +513,21 @@ public class AwesomeBarTabs extends TabHost {
Log.d(LOGTAG, "Creating AwesomeBarTabs");
mContext = context;
mInflated = false;
mSearchEngines = new JSONArray();
}
// Load layout into the custom view
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@Override
protected void onFinishInflate() {
super.onFinishInflate();
inflater.inflate(R.layout.awesomebar_tabs, this);
// HACK: Without this, the onFinishInflate is called twice
// This issue is due to a bug when Android inflates a layout with a
// parent. Fixed in Honeycomb
if (mInflated)
return;
mInflated = true;
// This should be called before adding any tabs
// to the TabHost.

View File

@@ -62,43 +62,51 @@ import android.widget.TextSwitcher;
import android.widget.ViewSwitcher.ViewFactory;
public class BrowserToolbar extends LinearLayout {
final private Button mAwesomeBar;
final private ImageButton mTabs;
final public ImageButton mFavicon;
final public ImageButton mStop;
final public ImageButton mSiteSecurity;
final private AnimationDrawable mProgressSpinner;
final private TextSwitcher mTabsCount;
private Button mAwesomeBar;
private ImageButton mTabs;
public ImageButton mFavicon;
public ImageButton mStop;
public ImageButton mSiteSecurity;
private AnimationDrawable mProgressSpinner;
private TextSwitcher mTabsCount;
final private Context mContext;
final private Handler mHandler;
final private int mColor;
final private int mCounterColor;
private Handler mHandler;
private boolean mInflated;
private int mColor;
private int mCounterColor;
final private int mDuration;
final private TranslateAnimation mSlideUpIn;
final private TranslateAnimation mSlideUpOut;
final private TranslateAnimation mSlideDownIn;
final private TranslateAnimation mSlideDownOut;
private int mDuration;
private TranslateAnimation mSlideUpIn;
private TranslateAnimation mSlideUpOut;
private TranslateAnimation mSlideDownIn;
private TranslateAnimation mSlideDownOut;
private int mCount;
public BrowserToolbar(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mInflated = false;
}
@Override
protected void onFinishInflate () {
super.onFinishInflate();
// HACK: Without this, the onFinishInflate is called twice
// This issue is due to a bug when Android inflates a layout with a
// parent. Fixed in Honeycomb
if (mInflated)
return;
mInflated = true;
// Get the device's highlight color
ContextThemeWrapper wrapper = new ContextThemeWrapper(mContext, android.R.style.TextAppearance);
TypedArray typedArray = wrapper.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorHighlight });
mColor = typedArray.getColor(typedArray.getIndex(0), 0);
// Load layout into the custom view
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.browser_toolbar, this);
mAwesomeBar = (Button) findViewById(R.id.awesome_bar);
mAwesomeBar.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
@@ -135,6 +143,7 @@ public class BrowserToolbar extends LinearLayout {
mCounterColor = 0x99ffffff;
mTabsCount = (TextSwitcher) findViewById(R.id.tabs_count);
mTabsCount.removeAllViews();
mTabsCount.setFactory(new ViewFactory() {
public View makeView() {
TextView text = new TextView(mContext);
@@ -142,11 +151,11 @@ public class BrowserToolbar extends LinearLayout {
text.setTextSize(16);
text.setTextColor(mCounterColor);
text.setTypeface(text.getTypeface(), Typeface.BOLD);
return text;
return (View) text;
}
});
mCount = 0;
mTabsCount.setText("0");
mCount = 0;
mFavicon = (ImageButton) findViewById(R.id.favicon);
mSiteSecurity = (ImageButton) findViewById(R.id.site_security);

View File

@@ -56,11 +56,13 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
private LinearLayout mChoicesLayout;
private TextView mTextView;
private Button mButton;
private LayoutParams mLayoutParams;
static private LayoutParams mLayoutParams;
public Tab mTab;
// value used to identify the notification
private String mValue;
static private LayoutInflater mInflater;
private int mPersistence = 0;
private long mTimeout = 0;
@@ -73,15 +75,16 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
setOrientation(VERTICAL);
setBackgroundResource(R.drawable.doorhanger_shadow_bg);
// Load layout into the custom view
LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.doorhanger, this);
if (mInflater == null)
mInflater = LayoutInflater.from(mContext);
mInflater.inflate(R.layout.doorhanger, this);
hide();
mTextView = (TextView) findViewById(R.id.doorhanger_title);
mChoicesLayout = (LinearLayout) findViewById(R.id.doorhanger_choices);
if (mLayoutParams == null)
mLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT,
1.0f);

View File

@@ -69,7 +69,7 @@ public class DoorHangerPopup extends PopupWindow {
setOutsideTouchable(true);
setWindowLayoutMode(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = LayoutInflater.from(mContext);
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.doorhangerpopup, null);
mContent = (LinearLayout) layout.findViewById(R.id.doorhanger_container);

View File

@@ -76,6 +76,11 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
private PromptInput[] mInputs;
private AlertDialog mDialog = null;
private static LayoutInflater mInflater;
PromptService() {
mInflater = LayoutInflater.from(GeckoApp.mAppContext);
}
private class PromptButton {
public String label = "";
@@ -189,8 +194,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
PromptListAdapter adapter = new PromptListAdapter(GeckoApp.mAppContext, resourceId, aMenuList);
if (mSelected != null && mSelected.length > 0) {
if (aMultipleSelection) {
LayoutInflater inflater = GeckoApp.mAppContext.getLayoutInflater();
adapter.listView = (ListView) inflater.inflate(R.layout.select_dialog_list, null);
adapter.listView = (ListView) mInflater.inflate(R.layout.select_dialog_list, null);
adapter.listView.setOnItemClickListener(this);
builder.setInverseBackgroundForced(true);
adapter.listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
@@ -432,8 +436,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
if (item.isGroup) {
resourceId = R.layout.list_item_header;
}
LayoutInflater inflater = GeckoApp.mAppContext.getLayoutInflater();
View row = inflater.inflate(resourceId, null);
View row = mInflater.inflate(resourceId, null);
if (!item.isGroup){
try {
CheckedTextView ct = (CheckedTextView)row.findViewById(android.R.id.text1);

View File

@@ -37,6 +37,10 @@
<org.mozilla.gecko.AwesomeBarTabs android:id="@+id/awesomebar_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
<include layout="@layout/awesomebar_tabs"/>
</org.mozilla.gecko.AwesomeBarTabs>
</LinearLayout>

View File

@@ -18,7 +18,11 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:isScrollContainer="true"/>
android:isScrollContainer="true">
<include layout="@layout/abouthome_content"/>
</org.mozilla.gecko.AboutHomeContent>
</RelativeLayout>

View File

@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mozilla.gecko.BrowserToolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/browser_toolbar"
style="@style/BrowserToolbar"/>
style="@style/BrowserToolbar">
<include layout="@layout/browser_toolbar"/>
</org.mozilla.gecko.BrowserToolbar>

View File

@@ -36,6 +36,10 @@
<org.mozilla.gecko.AwesomeBarTabs android:id="@+id/awesomebar_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
<include layout="@layout/awesomebar_tabs"/>
</org.mozilla.gecko.AwesomeBarTabs>
</LinearLayout>

View File

@@ -4,7 +4,11 @@
style="@style/Screen">
<org.mozilla.gecko.BrowserToolbar android:id="@+id/browser_toolbar"
style="@style/BrowserToolbar"/>
style="@style/BrowserToolbar">
<include layout="@layout/browser_toolbar"/>
</org.mozilla.gecko.BrowserToolbar>
<RelativeLayout android:id="@+id/gecko_layout"
android:layout_width="fill_parent"
@@ -21,7 +25,11 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:isScrollContainer="true"/>
android:isScrollContainer="true">
<include layout="@layout/abouthome_content"/>
</org.mozilla.gecko.AboutHomeContent>
</RelativeLayout>