我正在使用yuyakaido的库CardStackView,但似乎无法使CardStackListener正常工作。这是该库的链接:https://github.com/yuyakaido/CardStackView#callbacks。我已将其实现到我的Fragment中。
滑动效果正常,但没有回调函数。我是否漏掉了什么?
编辑: 我正在使用gradle:
public class PendingFragment extends Fragment implements CardStackListener{
private CardStackLayoutManager manager;
private CardStackView cardStackView;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View mView = inflater.inflate(R.layout.fragment_pending, container, false);
manager = new CardStackLayoutManager(getActivity());
manager.setStackFrom(StackFrom.Top);
manager.setVisibleCount(3);
manager.setCanScrollVertical(false);
cardStackView = mView.findViewById(R.id.pendingList_cardStackView);
cardStackView.setLayoutManager(manager);
}
@Override
public void onCardDragging(Direction direction, float ratio) {
}
@Override
public void onCardSwiped(Direction direction) {
Log.e("PendingFragment", "onCardSwiped: " + direction );
if(direction == Direction.Right){
Toast.makeText(getActivity(), "Accepted", Toast.LENGTH_SHORT).show();
}else if(direction == Direction.Left){
Toast.makeText(getActivity(), "Rejected", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCardRewound() {
}
@Override
public void onCardCanceled() {
}
@Override
public void onCardAppeared(View view, int position) {
}
@Override
public void onCardDisappeared(View view, int position) {
}
}
滑动效果正常,但没有回调函数。我是否漏掉了什么?
编辑: 我正在使用gradle:
implementation "com.yuyakaido.android:card-stack-view:2.2.0"
。
我还在使用FirebaseRecyclerAdapter作为我的适配器。