4747import com .bumptech .glide .integration .recyclerview .RecyclerViewPreloader ;
4848import com .bumptech .glide .util .ViewPreloadSizeProvider ;
4949import com .google .android .material .bottomsheet .BottomSheetDialog ;
50+ import com .google .android .material .card .MaterialCardView ;
5051import com .google .android .material .chip .Chip ;
5152import com .google .android .material .chip .ChipGroup ;
5253import com .google .android .material .divider .MaterialDividerItemDecoration ;
54+ import com .google .android .material .shape .CornerFamily ;
55+ import com .google .android .material .shape .ShapeAppearanceModel ;
5356import com .google .common .base .Strings ;
5457
5558import java .util .Collection ;
@@ -639,6 +642,27 @@ public interface Listener {
639642 void onEntryListTouch ();
640643 }
641644
645+ private void decorateFavoriteEntries (@ NonNull View view , @ NonNull RecyclerView parent ) {
646+ int adapterPosition = parent .getChildAdapterPosition (view );
647+ int entryIndex = _adapter .translateEntryPosToIndex (adapterPosition );
648+ int totalFavorites = _adapter .getShownFavoritesCount ();
649+
650+ if (entryIndex < totalFavorites ) {
651+ ShapeAppearanceModel model = ((MaterialCardView )view ).getShapeAppearanceModel ();
652+ ShapeAppearanceModel .Builder builder = model .toBuilder ();
653+ if ((entryIndex == 0 && totalFavorites > 1 ) || (entryIndex < (totalFavorites - 1 ))) {
654+ builder .setBottomLeftCorner (CornerFamily .ROUNDED , 0 );
655+ builder .setBottomRightCorner (CornerFamily .ROUNDED , 0 );
656+ }
657+ if (entryIndex > 0 ) {
658+ builder .setTopLeftCorner (CornerFamily .ROUNDED , 0 );
659+ builder .setTopRightCorner (CornerFamily .ROUNDED , 0 );
660+ }
661+
662+ ((MaterialCardView )view ).setShapeAppearanceModel (builder .build ());
663+ }
664+ }
665+
642666 private class CompactDividerDecoration extends MaterialDividerItemDecoration {
643667 public CompactDividerDecoration () {
644668 super (requireContext (), DividerItemDecoration .VERTICAL );
@@ -661,6 +685,8 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
661685 return ;
662686 }
663687
688+ decorateFavoriteEntries (view , parent );
689+
664690 super .getItemOffsets (outRect , view , parent , state );
665691 }
666692 }
@@ -713,6 +739,8 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
713739 if (entryIndex == totalFavorites ) {
714740 outRect .top = _height ;
715741 }
742+
743+ decorateFavoriteEntries (view , parent );
716744 }
717745
718746 // The last entry should never have a bottom margin
0 commit comments