PlaceHolderView sort, Swipe Stack Head Callback, Fix Expand ChildView Order
PlaceHolderView Sort
Now we can apply sort to the views added to the PlaceHolderView. This will refresh the views with new sort order.
Example: If the View Items added to the PlaceHolderView is of class ItemView, then we have to supply a Comparator that defines the comparison between the itemView objects. Here the itemView's title string is being compared for the sorting.
NOTE: Check item1 and item2 are of type ItemView for this example. This is required because any type of View Item class can be added into the PlaceHolderView
placeHolderView.sort(new Comparator<Object>() {
@Override
public int compare(Object item1, Object item2) {
if (item1 instanceof ItemView && item2 instanceof ItemView) {
ItemView view1 = (ItemView) item1;
ItemView view2 = (ItemView) item2;
return view1.getTitle().compareTo(view2.getTitle());
}
return 0;
}
});SwipeHead Callback
SwipePlaceHolderView will now provide SwipeHead annotation for callback when a card comes on top of the stack.
@SwipeHead
private void onSwipeHeadCard() {
// do something when the card comes on the top
}Example: In the below example link, the cards below the top card are blurred and when a card come on the top then it's blur removed.
Link: TinderCard
ExpandabePlaceHolderView Reverse Add Fix
The child views were getting added in reverse order and hence it is fixed now.