Hide dismissal swipe background before slice gets ready
Only make swipe background visible once slice has a successfual binding. Bug: 131843256 Test: robotests Change-Id: I7866873a217e8ca882634a48108939022713c87b
This commit is contained in:
@@ -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"
|
||||
|
@@ -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()) {
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user