Swipeable-Cards
Swipeable-Cards copied to clipboard
Individual ClickListener of Cards set in Adapter
I am using these awesome Library. I have used the CardModels and set it in Apadter. But I am unable to get the Unique ClickListener of Particular Card.
I have this code in the Container Class as: mTopCard = getChildAt(getChildCount() - 2); CardModel cardModel = (CardModel) getAdapter().getItem(mNextAdapterPosition - 1);
I have used everywhere 'mNextAdapterPosition - 1' where i have these code. Here is my clicklistener and Adapter Code:
UserModel userModel = rawItems.get(it); CardModel cardModel = new CardModel(userModel);
cardModel.setOnClickListener(
new CardModel.OnClickListener() {
@Override
public void OnClickListener() {
Intent intent = new Intent(
getActivity(),
Browse_ProfilePicture.class);
startActivity(intent);
}
});
cardModel.setOnCardDimissedListener(
new CardModel.OnCardDimissedListener() {
@Override
public void onLike() {
Log.e("userid", user.getUserId() + "");
Toast.makeText(getActivity(), "Liked",
Toast.LENGTH_LONG).show();
}
@Override
public void onDislike() {
Toast.makeText(getActivity(),
"Disliked", Toast.LENGTH_LONG)
.show();
}
});
adapter.add(cardModel);
As shown i am setting CardModel in Unique Adapter, Then also in Like log, I am getting only 1 user ID, Last User ID. I want unique User ID.
Does Anyone have idea how can i solve this issue?
I had similar problems. Check out my blog for further information. http://styssi.blogspot.de/2015/04/tinder-swipe-functionality-with.html
Hi,
I Solved these Issue in my Project. But Now I stuck in some new thing. And I think may be you can help me.
If I have Stack of 10 Cards or any number of Cards, I Just want to show 1 Card at a time, there is one variable in Library mMaxVisible, I set it to my required Number, But after Swiping 1 or 2 times it Crashes my app.
Please Guide with these Issue if you have any idea on these. It would be a big help.
sirajsumra
I think you can easily overcome this issue by just generating one card at one time and generating another card to show from the lot with the OnCardDismissedListener() callback, very simple as much as I got your problem.
@styssi hi, can i see your adapter class?