mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 721354 - Factor out code to load top sites in AboutHomeContent (r=blassey)
This commit is contained in:
parent
fe13e169df
commit
809bddf2c8
@ -241,42 +241,46 @@ public class AboutHomeContent extends ScrollView {
|
||||
return NUMBER_OF_COLS_PORTRAIT;
|
||||
}
|
||||
|
||||
private void loadTopSites(Activity activity) {
|
||||
if (mCursor != null)
|
||||
activity.stopManagingCursor(mCursor);
|
||||
|
||||
// Ensure we initialize GeckoApp's startup mode in
|
||||
// background thread before we use it when updating
|
||||
// the top sites section layout in main thread.
|
||||
final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode();
|
||||
|
||||
// The isSyncSetup method should not be called on
|
||||
// UI thread as it touches disk to access a sqlite DB.
|
||||
final boolean syncIsSetup = isSyncSetup();
|
||||
|
||||
ContentResolver resolver = GeckoApp.mAppContext.getContentResolver();
|
||||
mCursor = BrowserDB.getTopSites(resolver, NUMBER_OF_TOP_SITES_PORTRAIT);
|
||||
activity.startManagingCursor(mCursor);
|
||||
|
||||
mTopSitesAdapter = new TopSitesCursorAdapter(activity,
|
||||
R.layout.abouthome_topsite_item,
|
||||
mCursor,
|
||||
new String[] { URLColumns.TITLE,
|
||||
URLColumns.THUMBNAIL },
|
||||
new int[] { R.id.title, R.id.thumbnail });
|
||||
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
mTopSitesGrid.setNumColumns(getNumberOfColumns());
|
||||
|
||||
mTopSitesGrid.setAdapter(mTopSitesAdapter);
|
||||
mTopSitesAdapter.setViewBinder(new TopSitesViewBinder());
|
||||
|
||||
updateLayout(startupMode, syncIsSetup);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void init(final Activity activity) {
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
if (mCursor != null)
|
||||
activity.stopManagingCursor(mCursor);
|
||||
|
||||
// Ensure we initialize GeckoApp's startup mode in
|
||||
// background thread before we use it when updating
|
||||
// the top sites section layout in main thread.
|
||||
final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode();
|
||||
|
||||
// The isSyncSetup method should not be called on
|
||||
// UI thread as it touches disk to access a sqlite DB.
|
||||
final boolean syncIsSetup = isSyncSetup();
|
||||
|
||||
ContentResolver resolver = GeckoApp.mAppContext.getContentResolver();
|
||||
mCursor = BrowserDB.getTopSites(resolver, NUMBER_OF_TOP_SITES_PORTRAIT);
|
||||
activity.startManagingCursor(mCursor);
|
||||
|
||||
mTopSitesAdapter = new TopSitesCursorAdapter(activity,
|
||||
R.layout.abouthome_topsite_item,
|
||||
mCursor,
|
||||
new String[] { URLColumns.TITLE,
|
||||
URLColumns.THUMBNAIL },
|
||||
new int[] { R.id.title, R.id.thumbnail });
|
||||
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
mTopSitesGrid.setNumColumns(getNumberOfColumns());
|
||||
|
||||
mTopSitesGrid.setAdapter(mTopSitesAdapter);
|
||||
mTopSitesAdapter.setViewBinder(new TopSitesViewBinder());
|
||||
|
||||
updateLayout(startupMode, syncIsSetup);
|
||||
}
|
||||
});
|
||||
loadTopSites(activity);
|
||||
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
|
Loading…
Reference in New Issue
Block a user