yuyakaido / CardStackView

📱Tinder like swipeable card view for Android
Apache License 2.0
2.36k stars 448 forks source link

How to get the position where card was swiped ? #317

Open eflexcode opened 4 years ago

eflexcode commented 4 years ago

if a card was swiped right how can i also know the position so i can so i can get user details and notify user that some one like him/she

dbof10 commented 4 years ago

my case I have to keep a field onCardSwipe(position)

anubhav11march commented 4 years ago

you can update the current card position by @Override public void onCardAppeared(View view, int position) { currentPos = position; }

BabarShamsi-mset commented 2 years ago

Simple you just have to make sure your class is implementing CardStackListener

And that's how you can do this:

lateinit var cardStackLayoutManager: CardStackLayoutManager

And onViewCreated method just initialise like this

cardStackLayoutManager = CardStackLayoutManager(context, this)

So you would have call back for this method on this card change

 override fun onCardAppeared(view: View?, position: Int) {
        if (position == cardStackAdapter.itemCount - 1) {
            cardStackLayoutManager.setSwipeableMethod(SwipeableMethod.None)
            cardStackView.rewind()
        }
        else {
            cardStackLayoutManager.setSwipeableMethod(SwipeableMethod.Manual)
        }
    }

@eflexcode