Java Code Examples for org.chromium.chrome.browser.ntp.snippets.SnippetsBridge#isCategoryEnabled()

The following examples show how to use org.chromium.chrome.browser.ntp.snippets.SnippetsBridge#isCategoryEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SectionList.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: SectionList.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: NewTabPageAdapter.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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;
}