use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionContextualCardControllerTest method getConditionalCards_hasTwoConditionCardsAndExpanded_shouldGetTwoHalfWidthCards.
@Test
public void getConditionalCards_hasTwoConditionCardsAndExpanded_shouldGetTwoHalfWidthCards() {
mController.setIsExpanded(true);
final Map<Integer, List<ContextualCard>> conditionalCards = mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
assertThat(conditionalCards).hasSize(3);
assertThat(conditionalCards.get(CardType.CONDITIONAL)).hasSize(2);
for (ContextualCard card : conditionalCards.get(CardType.CONDITIONAL)) {
assertThat(card.getViewType()).isEqualTo(ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH);
}
assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionFooterContextualCardRendererTest method bindView_shouldSetClickListener.
@Test
public void bindView_shouldSetClickListener() {
final RecyclerView recyclerView = new RecyclerView(mContext);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
final ContextualCard card = generateConditionFooterContextualCard();
final View view = LayoutInflater.from(mContext).inflate(card.getViewType(), recyclerView, false);
final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(view, card.getViewType());
when(mControllerRendererPool.getController(mContext, ContextualCard.CardType.CONDITIONAL_FOOTER)).thenReturn(mController);
mRenderer.bindView(viewHolder, card);
assertThat(viewHolder.itemView).isNotNull();
assertThat(viewHolder.itemView.hasOnClickListeners()).isTrue();
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionHeaderContextualCardRendererTest method bindView_shouldSetClickListener.
@Test
public void bindView_shouldSetClickListener() {
final RecyclerView recyclerView = new RecyclerView(mActivity);
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
final ContextualCard card = generateConditionHeaderContextualCard();
final View view = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(view, card.getViewType());
when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.CONDITIONAL_HEADER)).thenReturn(mController);
mRenderer.bindView(viewHolder, generateConditionHeaderContextualCard());
assertThat(viewHolder.itemView).isNotNull();
assertThat(viewHolder.itemView.hasOnClickListeners()).isTrue();
}
use of com.android.settings.homepage.contextualcards.ContextualCard 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();
});
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContextualCardLogUtils method buildCardListLog.
/**
* Serialize List of {@link ContextualCard} to string
*/
public static String buildCardListLog(List<ContextualCard> cards) {
final StringBuilder log = new StringBuilder();
log.append(cards.size());
for (ContextualCard card : cards) {
log.append("|").append(card.getTextSliceUri()).append("|").append(card.getRankingScore());
}
return log.toString();
}
Aggregations