mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
14c8882d88
--HG-- rename : mobile/android/base/home/BookmarksPage.java => mobile/android/base/home/BookmarksPanel.java rename : mobile/android/base/home/HistoryPage.java => mobile/android/base/home/HistoryPanel.java rename : mobile/android/base/home/LastTabsPage.java => mobile/android/base/home/LastTabsPanel.java rename : mobile/android/base/home/ListPage.java => mobile/android/base/home/ListPanel.java rename : mobile/android/base/home/MostRecentPage.java => mobile/android/base/home/MostRecentPanel.java rename : mobile/android/base/home/ReadingListPage.java => mobile/android/base/home/ReadingListPanel.java rename : mobile/android/base/home/TopSitesPage.java => mobile/android/base/home/TopSitesPanel.java rename : mobile/android/base/resources/drawable/home_page_title_background.xml => mobile/android/base/resources/drawable/home_panel_title_background.xml rename : mobile/android/base/resources/layout-large-land-v11/home_history_page.xml => mobile/android/base/resources/layout-large-land-v11/home_history_panel.xml rename : mobile/android/base/resources/layout-xlarge-v11/home_history_page.xml => mobile/android/base/resources/layout-xlarge-v11/home_history_panel.xml rename : mobile/android/base/resources/layout/home_bookmarks_page.xml => mobile/android/base/resources/layout/home_bookmarks_panel.xml rename : mobile/android/base/resources/layout/home_history_page.xml => mobile/android/base/resources/layout/home_history_panel.xml rename : mobile/android/base/resources/layout/home_last_tabs_page.xml => mobile/android/base/resources/layout/home_last_tabs_panel.xml rename : mobile/android/base/resources/layout/home_most_recent_page.xml => mobile/android/base/resources/layout/home_most_recent_panel.xml rename : mobile/android/base/resources/layout/home_reading_list_page.xml => mobile/android/base/resources/layout/home_reading_list_panel.xml rename : mobile/android/base/resources/layout/home_top_sites_page.xml => mobile/android/base/resources/layout/home_top_sites_panel.xml rename : mobile/android/base/tests/testBookmarksPage.java => mobile/android/base/tests/testBookmarksPanel.java
84 lines
2.1 KiB
Java
84 lines
2.1 KiB
Java
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.home;
|
|
|
|
import org.mozilla.gecko.home.HomeConfig.PanelConfig;
|
|
import org.mozilla.gecko.home.HomeConfig.OnChangeListener;
|
|
|
|
import android.content.Context;
|
|
import android.support.v4.content.AsyncTaskLoader;
|
|
|
|
import java.util.List;
|
|
|
|
public class HomeConfigLoader extends AsyncTaskLoader<List<PanelConfig>> {
|
|
private final HomeConfig mConfig;
|
|
private List<PanelConfig> mPanelConfigs;
|
|
|
|
public HomeConfigLoader(Context context, HomeConfig homeConfig) {
|
|
super(context);
|
|
mConfig = homeConfig;
|
|
}
|
|
|
|
@Override
|
|
public List<PanelConfig> loadInBackground() {
|
|
return mConfig.load();
|
|
}
|
|
|
|
@Override
|
|
public void deliverResult(List<PanelConfig> panelConfigs) {
|
|
if (isReset()) {
|
|
mPanelConfigs = null;
|
|
return;
|
|
}
|
|
|
|
mPanelConfigs = panelConfigs;
|
|
mConfig.setOnChangeListener(new ForceLoadChangeListener());
|
|
|
|
if (isStarted()) {
|
|
super.deliverResult(panelConfigs);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onStartLoading() {
|
|
if (mPanelConfigs != null) {
|
|
deliverResult(mPanelConfigs);
|
|
}
|
|
|
|
if (takeContentChanged() || mPanelConfigs == null) {
|
|
forceLoad();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onStopLoading() {
|
|
cancelLoad();
|
|
}
|
|
|
|
@Override
|
|
public void onCanceled(List<PanelConfig> panelConfigs) {
|
|
mPanelConfigs = null;
|
|
}
|
|
|
|
@Override
|
|
protected void onReset() {
|
|
super.onReset();
|
|
|
|
// Ensure the loader is stopped.
|
|
onStopLoading();
|
|
|
|
mPanelConfigs = null;
|
|
mConfig.setOnChangeListener(null);
|
|
}
|
|
|
|
private class ForceLoadChangeListener implements OnChangeListener {
|
|
@Override
|
|
public void onChange() {
|
|
onContentChanged();
|
|
}
|
|
}
|
|
}
|