Search in sources :

Example 26 with ContextualCard

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;
}
Also used : ArrayList(java.util.ArrayList) ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 27 with ContextualCard

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);
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 28 with ContextualCard

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);
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 29 with ContextualCard

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);
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 30 with ContextualCard

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);
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Aggregations

ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)35 Test (org.junit.Test)32 RecyclerView (androidx.recyclerview.widget.RecyclerView)21 View (android.view.View)15 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)10 ArrayList (java.util.ArrayList)6 Button (android.widget.Button)4 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Suggestion (android.service.settings.suggestions.Suggestion)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1