Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fcb35a0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Hide dismissal swipe background before slice gets ready" into qt-dev

parents db6a7027 ce9903e8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,7 +20,8 @@
    android:id="@+id/dismissal_swipe_background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/contextual_card_dismissal_background">
    android:background="@color/contextual_card_dismissal_background"
    android:visibility="gone">

    <ImageView
        android:id="@+id/dismissal_icon_start"
+5 −0
Original line number Diff line number Diff line
@@ -110,7 +110,10 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
            mSliceLiveDataMap.put(uri, sliceLiveData);
        }

        final View swipeBackground = holder.itemView.findViewById(R.id.dismissal_swipe_background);
        sliceLiveData.removeObservers(mLifecycleOwner);
        // set the background to Gone in case the holder is reused.
        swipeBackground.setVisibility(View.GONE);
        sliceLiveData.observe(mLifecycleOwner, slice -> {
            if (slice == null) {
                Log.w(TAG, "Slice is null");
@@ -137,6 +140,8 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
                default:
                    mFullCardHelper.bindView(holder, card, slice);
            }

            swipeBackground.setVisibility(View.VISIBLE);
        });

        switch (holder.getItemViewType()) {
+24 −0
Original line number Diff line number Diff line
@@ -136,6 +136,30 @@ public class SliceContextualCardRendererTest {
        assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
    }

    @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);
    }

    @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);
    }

    @Test
    public void viewClick_keepCard_shouldShowSlice() {
        final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();