cardslib
cardslib copied to clipboard
card.setOnExpandAnimatorStartListener doesn't work
CustomCardExpand cardExpand = new CustomCardExpand(getContext(), R.layout.card_item_inner_expand_layout, message);
card.addCardExpand(cardExpand);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().setupCardElement(ViewToClickToExpand.CardElementUI.CARD);
card.setViewToClickToExpand(viewToClickToExpand);
card.setSwipeable(false);
card.setOnExpandAnimatorStartListener(new Card.OnExpandAnimatorStartListener() {
@Override
public void onExpandStart(Card card) {
ToastUtils.show("Expand start"); //this doesn't work
}
});
card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {
@Override
public void onExpandEnd(Card card) {
ToastUtils.show("Expand End"); //this works
}
});
I have problem with card.setOnExpandAnimatorStartListener.
Add code card.doToogleExpand();
I've also encountered this issue. The same bug applies to the collapse-start listener. The fix is very simple, though: getting the ExpandCollapseHelper class to register a listener over the expand-animation that also overrides the onAnimationStart() method. In that method, the user's listener should be invoked. For example:
class ExpandCollapseHelper {
// ...
private static void animateExpanding(final ExpandContainerHelper helper) {
// ...
// ...
helper.getCardView().getExpandAnimator().addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
if (helper.card.getOnExpandAnimatorStartListener() != null)
helper.card.getOnExpandAnimatorStartListener().onExpandStart(helper.card);
}
@Override
public void onAnimationEnd(Animator animation) {
// ...
}
// ...