Search in sources :

Example 1 with Suggestion

use of android.service.settings.suggestions.Suggestion in project android_packages_apps_Settings by omnirom.

the class LegacySuggestionContextualCardController method loadSuggestions.

private void loadSuggestions() {
    ThreadUtils.postOnBackgroundThread(() -> {
        if (mSuggestionController == null || mCardUpdateListener == null) {
            return;
        }
        final List<Suggestion> suggestions = mSuggestionController.getSuggestions();
        final String suggestionCount = suggestions == null ? "null" : String.valueOf(suggestions.size());
        Log.d(TAG, "Loaded suggests: " + suggestionCount);
        final List<ContextualCard> cards = new ArrayList<>();
        if (suggestions != null) {
            // Convert suggestion to ContextualCard
            for (Suggestion suggestion : suggestions) {
                final LegacySuggestionContextualCard.Builder cardBuilder = new LegacySuggestionContextualCard.Builder();
                if (suggestion.getIcon() != null) {
                    cardBuilder.setIconDrawable(suggestion.getIcon().loadDrawable(mContext));
                }
                cardBuilder.setPendingIntent(suggestion.getPendingIntent()).setSuggestion(suggestion).setName(suggestion.getId()).setTitleText(suggestion.getTitle().toString()).setSummaryText(suggestion.getSummary().toString()).setViewType(LegacySuggestionContextualCardRenderer.VIEW_TYPE);
                cards.add(cardBuilder.build());
            }
        }
        mSuggestions.clear();
        mSuggestions.addAll(cards);
        updateAdapter();
    });
}
Also used : Suggestion(android.service.settings.suggestions.Suggestion) ArrayList(java.util.ArrayList) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard)

Example 2 with Suggestion

use of android.service.settings.suggestions.Suggestion in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LegacySuggestionContextualCardController method loadSuggestions.

private void loadSuggestions() {
    ThreadUtils.postOnBackgroundThread(() -> {
        if (mSuggestionController == null || mCardUpdateListener == null) {
            return;
        }
        final List<Suggestion> suggestions = mSuggestionController.getSuggestions();
        final String suggestionCount = suggestions == null ? "null" : String.valueOf(suggestions.size());
        Log.d(TAG, "Loaded suggests: " + suggestionCount);
        final List<ContextualCard> cards = new ArrayList<>();
        if (suggestions != null) {
            // Convert suggestion to ContextualCard
            for (Suggestion suggestion : suggestions) {
                final LegacySuggestionContextualCard.Builder cardBuilder = new LegacySuggestionContextualCard.Builder();
                if (suggestion.getIcon() != null) {
                    cardBuilder.setIconDrawable(suggestion.getIcon().loadDrawable(mContext));
                }
                cardBuilder.setPendingIntent(suggestion.getPendingIntent()).setSuggestion(suggestion).setName(suggestion.getId()).setTitleText(suggestion.getTitle().toString()).setSummaryText(suggestion.getSummary().toString()).setViewType(LegacySuggestionContextualCardRenderer.VIEW_TYPE);
                cards.add(cardBuilder.build());
            }
        }
        mSuggestions.clear();
        mSuggestions.addAll(cards);
        updateAdapter();
    });
}
Also used : Suggestion(android.service.settings.suggestions.Suggestion) ArrayList(java.util.ArrayList) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard)

Aggregations

Suggestion (android.service.settings.suggestions.Suggestion)2 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)2 ArrayList (java.util.ArrayList)2