本文整理汇总了Java中org.chromium.chrome.browser.ntp.snippets.SnippetsBridge类的典型用法代码示例。如果您正苦于以下问题:Java SnippetsBridge类的具体用法?Java SnippetsBridge怎么用?Java SnippetsBridge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SnippetsBridge类属于org.chromium.chrome.browser.ntp.snippets包,在下文中一共展示了SnippetsBridge类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSuggestions
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
public void addSuggestions(List<SnippetArticle> suggestions, @CategoryStatusEnum int status) {
if (!SnippetsBridge.isCategoryStatusAvailable(status)) mSuggestionsList.clear();
mProgressIndicator.setVisible(SnippetsBridge.isCategoryLoading(status));
Log.d(TAG, "addSuggestions: current number of suggestions: %d",
mSuggestionsList.getItemCount());
int sizeBefore = suggestions.size();
// TODO(dgn): remove once the backend stops sending duplicates.
if (suggestions.removeAll(mSuggestionsList.mSuggestions)) {
Log.d(TAG, "addSuggestions: Removed duplicates from incoming suggestions. "
+ "Count changed from %d to %d",
sizeBefore, suggestions.size());
}
mSuggestionsList.addAll(suggestions);
for (SnippetArticle article : suggestions) {
if (!article.requiresExactOfflinePage()) {
updateSnippetOfflineAvailability(article);
}
}
refreshChildrenVisibility();
}
示例2: resetSections
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
/**
* Resets the sections, reloading the whole new tab page content.
* @param alwaysAllowEmptySections Whether sections are always allowed to be displayed when
* they are empty, even when they are normally not.
*/
private void resetSections(boolean alwaysAllowEmptySections) {
removeAllSections();
SuggestionsSource suggestionsSource = mUiDelegate.getSuggestionsSource();
int[] categories = suggestionsSource.getCategories();
int[] suggestionsPerCategory = new int[categories.length];
int visibleCategoriesCount = 0;
int categoryIndex = 0;
for (int category : categories) {
int categoryStatus = suggestionsSource.getCategoryStatus(category);
int suggestionsCount = 0;
if (SnippetsBridge.isCategoryEnabled(categoryStatus)) {
suggestionsCount = resetSection(category, categoryStatus, alwaysAllowEmptySections);
if (mSections.get(category) != null) ++visibleCategoriesCount;
}
suggestionsPerCategory[categoryIndex] = suggestionsCount;
++categoryIndex;
}
maybeHideArticlesHeader();
mUiDelegate.getEventReporter().onPageShown(
categories, suggestionsPerCategory, visibleCategoriesCount);
}
示例3: canProcessSuggestions
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
/**
* Returns whether the category is able to process the suggestions. The category might decide
* not to show incoming suggestions later, but this check ensures it's in a basic state
* compatible with displaying content.
*/
private boolean canProcessSuggestions(@CategoryInt int category, @CategoryStatus int status) {
// If the category was blacklisted, we note that there might be new content to show.
mBlacklistedCategories.remove(category);
// We never want to add suggestions from unknown categories.
if (!mSections.containsKey(category)) return false;
// The status may have changed while the suggestions were loading, perhaps they should not
// be displayed any more.
if (!SnippetsBridge.isCategoryEnabled(status)) {
Log.w(TAG, "Received suggestions for a disabled category (id=%d, status=%d)", category,
status);
return false;
}
return true;
}
示例4: onCreate
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.suggestions_preferences);
setHasOptionsMenu(true);
finishSwitchInitialisation();
boolean isEnabled = SnippetsBridge.areRemoteSuggestionsEnabled();
mIsEnabled = !isEnabled; // Opposite so that we trigger side effects below.
updatePreferences(isEnabled);
@LaunchSource
int launchSource =
getActivity().getIntent().getIntExtra(LAUNCH_SOURCE_EXTRA, LAUNCH_SOURCE_SETTINGS);
if (launchSource == LAUNCH_SOURCE_NOTIFICATION) {
ContentSuggestionsNotificationHelper.recordNotificationAction(
ContentSuggestionsNotificationAction.OPEN_SETTINGS);
}
}
示例5: updatePreferences
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
/**
* Switches preference screens depending on whether the remote suggestions are enabled/disabled.
* @param isEnabled Indicates whether the remote suggestions are enabled.
*/
public void updatePreferences(boolean isEnabled) {
if (mIsEnabled == isEnabled) return;
mFeatureSwitch.setChecked(isEnabled);
mIsEnabled = isEnabled;
if (canShowNotificationsSwitch()) {
mFeatureSwitch.setSummaryOn(R.string.suggestions_feature_switch_on_summary);
setNotificationsPrefState(true);
mNotificationsSwitch.setChecked(
SnippetsBridge.areContentSuggestionsNotificationsEnabled());
setCaveatsPrefState(false);
} else {
mFeatureSwitch.setSummaryOn(R.string.text_on);
setNotificationsPrefState(false);
setCaveatsPrefState(true);
}
}
示例6: canLoadSuggestions
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
private boolean canLoadSuggestions(@CategoryInt int category, @CategoryStatusEnum int status) {
// We never want to add suggestions from unknown categories.
if (!mSections.containsKey(category)) return false;
// The status may have changed while the suggestions were loading, perhaps they should not
// be displayed any more.
if (!SnippetsBridge.isCategoryEnabled(status)) {
Log.w(TAG, "Received suggestions for a disabled category (id=%d, status=%d)", category,
status);
return false;
}
return true;
}
示例7: setStatus
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
/** Sets the status for the section. Some statuses can cause the suggestions to be cleared. */
public void setStatus(@CategoryStatus int status) {
if (!SnippetsBridge.isCategoryStatusAvailable(status)) {
clearData();
Log.d(TAG, "setStatus: unavailable status, cleared suggestions.");
}
mProgressIndicator.setVisible(SnippetsBridge.isCategoryLoading(status));
}
示例8: fetchSnippets
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
@VisibleForTesting
protected void fetchSnippets() {
// Do not force regular background fetches.
SnippetsBridge.fetchSnippets(/*forceRequest=*/false);
}
示例9: rescheduleFetching
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
@VisibleForTesting
protected void rescheduleFetching() {
SnippetsBridge.rescheduleFetching();
}
示例10: setStatus
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
/** Sets the status for the section. Some statuses can cause the suggestions to be cleared. */
public void setStatus(@CategoryStatusEnum int status) {
if (!SnippetsBridge.isCategoryStatusAvailable(status)) mSuggestionsList.clear();
mProgressIndicator.setVisible(SnippetsBridge.isCategoryLoading(status));
refreshChildrenVisibility();
}
示例11: reloadSnippets
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
/** Start a request for new snippets. */
public void reloadSnippets() {
SnippetsBridge.fetchSnippets(/*forceRequest=*/true);
}
示例12: endRecording
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
private void endRecording(Tab removeObserverFromTab) {
if (removeObserverFromTab != null) removeObserverFromTab.removeObserver(this);
RecordUserAction.record("MobileNTP.Snippets.VisitEnd");
long visitTimeMs = SystemClock.elapsedRealtime() - mStartTimeMs;
SnippetsBridge.onSuggestionTargetVisited(mCategory, visitTimeMs);
}
示例13: fetchSnippets
import org.chromium.chrome.browser.ntp.snippets.SnippetsBridge; //导入依赖的package包/类
@VisibleForTesting
protected void fetchSnippets() {
SnippetsBridge.fetchRemoteSuggestionsFromBackground();
}