mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 889621 - Lazy load all fragments in about:home (r=sriram)
This commit is contained in:
parent
1e4abd2b5a
commit
bd007fdc19
@ -152,11 +152,7 @@ public class BookmarksPage extends HomeFragment {
|
||||
// Create callbacks before the initial loader is started.
|
||||
mLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
mThumbnailsLoaderCallbacks = new ThumbnailsLoaderCallbacks();
|
||||
|
||||
// Reconnect to the loader only if present.
|
||||
final LoaderManager manager = getLoaderManager();
|
||||
manager.initLoader(BOOKMARKS_LIST_LOADER_ID, null, mLoaderCallbacks);
|
||||
manager.initLoader(TOP_BOOKMARKS_LOADER_ID, null, mLoaderCallbacks);
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -291,6 +287,13 @@ public class BookmarksPage extends HomeFragment {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
final LoaderManager manager = getLoaderManager();
|
||||
manager.initLoader(BOOKMARKS_LIST_LOADER_ID, null, mLoaderCallbacks);
|
||||
manager.initLoader(TOP_BOOKMARKS_LOADER_ID, null, mLoaderCallbacks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for pinning bookmarks.
|
||||
*/
|
||||
|
@ -246,9 +246,7 @@ public class BrowserSearch extends HomeFragment
|
||||
|
||||
// Create callbacks before the initial loader is started
|
||||
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
|
||||
// Reconnect to the loader only if present
|
||||
getLoaderManager().initLoader(SEARCH_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,6 +261,11 @@ public class BrowserSearch extends HomeFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(SEARCH_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
private void handleAutocomplete(String searchTerm, Cursor c) {
|
||||
if (TextUtils.isEmpty(mSearchTerm) || c == null || mAutocompleteHandler == null) {
|
||||
return;
|
||||
|
@ -150,8 +150,11 @@ public class HistoryPage extends HomeFragment {
|
||||
|
||||
// Create callbacks before the initial loader is started
|
||||
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
// Reconnect to the loader only if present
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(HISTORY_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ import android.widget.Toast;
|
||||
* HomeFragment is an empty fragment that can be added to the HomePager.
|
||||
* Subclasses can add their own views.
|
||||
*/
|
||||
class HomeFragment extends Fragment {
|
||||
abstract class HomeFragment extends Fragment {
|
||||
// Log Tag.
|
||||
private static final String LOGTAG="GeckoHomeFragment";
|
||||
|
||||
@ -184,4 +184,20 @@ class HomeFragment extends Fragment {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint (boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
protected abstract void load();
|
||||
|
||||
protected void loadIfVisible() {
|
||||
if (!isVisible() || !getUserVisibleHint()) {
|
||||
return;
|
||||
}
|
||||
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
@ -145,8 +145,11 @@ public class LastTabsPage extends HomeFragment {
|
||||
|
||||
// Create callbacks before the initial loader is started
|
||||
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
// Reconnect to the loader only if present
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(LAST_TABS_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,11 @@ public class ReadingListPage extends HomeFragment {
|
||||
|
||||
// Create callbacks before the initial loader is started.
|
||||
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
// Reconnect to the loader only if it's present.
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(READING_LIST_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,11 @@ public class VisitedPage extends HomeFragment {
|
||||
|
||||
// Create callbacks before the initial loader is started
|
||||
mCursorLoaderCallbacks = new CursorLoaderCallbacks();
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
// Reconnect to the loader only if present
|
||||
@Override
|
||||
protected void load() {
|
||||
getLoaderManager().initLoader(FRECENCY_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user