backout changeset 3f050eb4f8ac (bug 711184)

This commit is contained in:
Brad Lassey 2011-12-20 01:53:34 -05:00
parent 9f94635cd8
commit 02923e6b84
3 changed files with 55 additions and 50 deletions

View File

@ -62,7 +62,6 @@ import android.text.SpannableString;
import android.text.style.UnderlineSpan; import android.text.style.UnderlineSpan;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -82,6 +81,8 @@ public class AboutHomeContent extends ScrollView {
private static final int NUMBER_OF_COLS_PORTRAIT = 2; private static final int NUMBER_OF_COLS_PORTRAIT = 2;
private static final int NUMBER_OF_COLS_LANDSCAPE = 3; private static final int NUMBER_OF_COLS_LANDSCAPE = 3;
private boolean mInflated;
private Cursor mCursor; private Cursor mCursor;
UriLoadCallback mUriLoadCallback = null; UriLoadCallback mUriLoadCallback = null;
@ -97,45 +98,50 @@ public class AboutHomeContent extends ScrollView {
public AboutHomeContent(Context context, AttributeSet attrs) { public AboutHomeContent(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mInflated = false;
} }
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
synchronized (this) {
if (mTopSitesGrid != null && mAddonsList != null)
return;
mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid); // HACK: Without this, the onFinishInflate is called twice
mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() { // This issue is due to a bug when Android inflates a layout with a
public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // parent. Fixed in Honeycomb
Cursor c = (Cursor) parent.getItemAtPosition(position); if (mInflated)
return;
String spec = c.getString(c.getColumnIndex(URLColumns.URL)); mInflated = true;
Log.i(LOGTAG, "clicked: " + spec);
if (mUriLoadCallback != null) mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid);
mUriLoadCallback.callback(spec); mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
} public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
}); Cursor c = (Cursor) parent.getItemAtPosition(position);
mAddonsList = (ListView) findViewById(R.id.recommended_addons_list); String spec = c.getString(c.getColumnIndex(URLColumns.URL));
Log.i(LOGTAG, "clicked: " + spec);
TextView allTopSitesText = (TextView) findViewById(R.id.all_top_sites_text); if (mUriLoadCallback != null)
allTopSitesText.setOnClickListener(new View.OnClickListener() { mUriLoadCallback.callback(spec);
public void onClick(View v) { }
GeckoApp.mAppContext.showAwesomebar(AwesomeBar.Type.EDIT); });
}
});
TextView allAddonsText = (TextView) findViewById(R.id.all_addons_text); mAddonsList = (ListView) findViewById(R.id.recommended_addons_list);
allAddonsText.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { TextView allTopSitesText = (TextView) findViewById(R.id.all_top_sites_text);
if (mUriLoadCallback != null) allTopSitesText.setOnClickListener(new View.OnClickListener() {
mUriLoadCallback.callback("about:addons"); public void onClick(View v) {
} GeckoApp.mAppContext.showAwesomebar(AwesomeBar.Type.EDIT);
}); }
} });
TextView allAddonsText = (TextView) findViewById(R.id.all_addons_text);
allAddonsText.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mUriLoadCallback != null)
mUriLoadCallback.callback("about:addons");
}
});
} }
private int getNumberOfTopSites() { private int getNumberOfTopSites() {
@ -155,11 +161,7 @@ public class AboutHomeContent extends ScrollView {
} }
void init(final Activity activity) { void init(final Activity activity) {
LayoutInflater inflater = GeckoAppShell.getHandler().post(new Runnable() {
(LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.abouthome_content, this);
final Runnable generateCursorsRunnable = new Runnable() {
public void run() { public void run() {
if (mCursor != null) if (mCursor != null)
activity.stopManagingCursor(mCursor); activity.stopManagingCursor(mCursor);
@ -191,14 +193,7 @@ public class AboutHomeContent extends ScrollView {
readRecommendedAddons(activity); readRecommendedAddons(activity);
} }
}; });
Runnable finishInflateRunnable = new Runnable() {
public void run() {
onFinishInflate();
GeckoAppShell.getHandler().post(generateCursorsRunnable);
}
};
GeckoApp.mAppContext.mMainHandler.post(finishInflateRunnable);
} }
public void setUriLoadCallback(UriLoadCallback uriLoadCallback) { public void setUriLoadCallback(UriLoadCallback uriLoadCallback) {
@ -310,14 +305,14 @@ public class AboutHomeContent extends ScrollView {
// This is to ensure that the GridView always has a size that shows // This is to ensure that the GridView always has a size that shows
// all items with no need for scrolling. // all items with no need for scrolling.
int expandedHeightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, int expandedHeightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST); MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandedHeightSpec); super.onMeasure(widthMeasureSpec, expandedHeightSpec);
} }
} }
public class TopSitesCursorAdapter extends SimpleCursorAdapter { public class TopSitesCursorAdapter extends SimpleCursorAdapter {
public TopSitesCursorAdapter(Context context, int layout, Cursor c, public TopSitesCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) { String[] from, int[] to) {
super(context, layout, c, from, to); super(context, layout, c, from, to);
} }
@ -389,7 +384,7 @@ public class AboutHomeContent extends ScrollView {
// This is to ensure that the ListView always has a size that shows // This is to ensure that the ListView always has a size that shows
// all items with no need for scrolling. // all items with no need for scrolling.
int expandedHeightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, int expandedHeightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST); MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandedHeightSpec); super.onMeasure(widthMeasureSpec, expandedHeightSpec);
} }
} }

View File

@ -1011,8 +1011,8 @@ abstract public class GeckoApp
public void run() { public void run() {
mAutoCompletePopup.hide(); mAutoCompletePopup.hide();
if (mAboutHomeContent == null && mShow) { if (mAboutHomeContent == null) {
mAboutHomeContent = new AboutHomeContent(GeckoApp.mAppContext, null); mAboutHomeContent = (AboutHomeContent) findViewById(R.id.abouthome_content);
mAboutHomeContent.init(GeckoApp.mAppContext); mAboutHomeContent.init(GeckoApp.mAppContext);
mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() { mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() {
public void callback(String url) { public void callback(String url) {
@ -1020,10 +1020,8 @@ abstract public class GeckoApp
loadUrl(url, AwesomeBar.Type.EDIT); loadUrl(url, AwesomeBar.Type.EDIT);
} }
}); });
mGeckoLayout.addView(mAboutHomeContent);
} }
if (mAboutHomeContent != null) mAboutHomeContent.setVisibility(mShow ? View.VISIBLE : View.GONE);
mAboutHomeContent.setVisibility(mShow ? View.VISIBLE : View.GONE);
} }
} }

View File

@ -20,6 +20,18 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"/> android:layout_height="fill_parent"/>
<org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:isScrollContainer="true"
android:visibility="gone">
<include layout="@layout/abouthome_content"/>
</org.mozilla.gecko.AboutHomeContent>
<org.mozilla.gecko.AutoCompletePopup android:id="@+id/autocomplete_popup" <org.mozilla.gecko.AutoCompletePopup android:id="@+id/autocomplete_popup"
style="@android:style/Widget.ListView.White" style="@android:style/Widget.ListView.White"
android:layout_width="fill_parent" android:layout_width="fill_parent"