use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConditionManager method getDisplayableCards.
/**
* Returns a list of {@link ContextualCard}s eligible for display.
*/
public List<ContextualCard> getDisplayableCards() {
final List<ContextualCard> cards = new ArrayList<>();
final List<Future<ContextualCard>> displayableCards = new ArrayList<>();
// Check displayable future
for (ConditionalCardController card : mCardControllers) {
final DisplayableChecker checker = new DisplayableChecker(getController(card.getId()));
displayableCards.add(ThreadUtils.postOnBackgroundThread(checker));
}
// Collect future and add displayable cards
for (Future<ContextualCard> cardFuture : displayableCards) {
try {
final ContextualCard card = cardFuture.get(DISPLAYABLE_CHECKER_TIMEOUT_MS, TimeUnit.MILLISECONDS);
if (card != null) {
cards.add(card);
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
Log.w(TAG, "Failed to get displayable state for card, likely timeout. Skipping", e);
}
}
return cards;
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceContextualCardRendererTest method bindView_beforeSuccessfulSliceBinding_shouldHideSwipeBackground.
@Test
public void bindView_beforeSuccessfulSliceBinding_shouldHideSwipeBackground() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final ContextualCard card = buildContextualCard(TEST_SLICE_URI);
final View swipeBg = viewHolder.itemView.findViewById(R.id.dismissal_swipe_background);
mRenderer.bindView(viewHolder, card);
assertThat(swipeBg.getVisibility()).isEqualTo(View.GONE);
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceContextualCardRendererTest method onStop_cardIsInDismissalView_shouldResetToSliceView.
@Test
public void onStop_cardIsInDismissalView_shouldResetToSliceView() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final View sliceView = viewHolder.itemView.findViewById(R.id.slice_view);
final View dismissalView = viewHolder.itemView.findViewById(R.id.dismissal_view);
final ContextualCard card = buildContextualCard(TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
mRenderer.bindView(viewHolder, card);
assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
mRenderer.onStop();
assertThat(sliceView.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(dismissalView.getVisibility()).isEqualTo(View.GONE);
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceContextualCardRendererTest method bindView_isPendingDismiss_shouldShowDismissalView.
@Test
public void bindView_isPendingDismiss_shouldShowDismissalView() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final View dismissalView = viewHolder.itemView.findViewById(R.id.dismissal_view);
final ContextualCard card = buildContextualCard(TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
mRenderer.bindView(viewHolder, card);
assertThat(dismissalView.getVisibility()).isEqualTo(View.VISIBLE);
}
use of com.android.settings.homepage.contextualcards.ContextualCard in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceContextualCardRendererTest method bindView_reuseViewHolder_shouldHideSwipeBackgroundBeforeSliceBinding.
@Test
public void bindView_reuseViewHolder_shouldHideSwipeBackgroundBeforeSliceBinding() {
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
final ContextualCard card = buildContextualCard(TEST_SLICE_URI);
final View swipeBg = viewHolder.itemView.findViewById(R.id.dismissal_swipe_background);
swipeBg.setVisibility(View.VISIBLE);
mRenderer.mSliceLiveDataMap.put(TEST_SLICE_URI, mSliceLiveData);
mRenderer.bindView(viewHolder, card);
assertThat(swipeBg.getVisibility()).isEqualTo(View.GONE);
}
Aggregations