Swipeable-Cards icon indicating copy to clipboard operation
Swipeable-Cards copied to clipboard

Individual ClickListener of Cards set in Adapter

Open sirajsumra92 opened this issue 9 years ago • 4 comments

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?

sirajsumra92 avatar Apr 02 '15 10:04 sirajsumra92

I had similar problems. Check out my blog for further information. http://styssi.blogspot.de/2015/04/tinder-swipe-functionality-with.html

styssi avatar Apr 27 '15 19:04 styssi

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.

sirajsumra92 avatar May 01 '15 12:05 sirajsumra92

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.

NishantSood avatar May 03 '15 15:05 NishantSood

@styssi hi, can i see your adapter class?

Slake07 avatar Aug 03 '15 09:08 Slake07