Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Load Previous Card #65

Open
joshvarun opened this issue Jun 19, 2018 · 3 comments
Open

Load Previous Card #65

joshvarun opened this issue Jun 19, 2018 · 3 comments

Comments

@joshvarun
Copy link

Hi,

Is there anyway I can load the previous card back on the screen?

@karan26796
Copy link

Ya man, been struggling with the same.
You'd have to add the previous item into the array list again at the top position and then update the adapter.
Haven't found the right logic to do that yet though.

@tundisi
Copy link

tundisi commented Oct 12, 2018

Hello @joshvarun @karan26796 in the adapter add an array with the deleted objects and create two methods that are the following:

private List<String> mData;
private List< String> mDataDeleted;

public void next(){
    mDataDeleted.add(mData.get(0));
    mData.remove(0);
}

public void back(){
    mData.add(0,mDataDeleted.get(mDataDeleted.size()-1));
    mDataDeleted.remove(mDataDeleted.size()-1);
} 

I realized that the adapter does not remove the element from the list, so when I swipe the intercept and call the next method that is in the adapter.

swipeStack.setListener(new SwipeStack.SwipeStackListener() {
            @Override
            public void onViewSwipedToLeft(int i) {
                swipeStackAdapter.next();
            }

            @Override
            public void onViewSwipedToRight(int i) {
                swipeStackAdapter.next();
            }

            @Override
            public void onStackEmpty() {
            }
        });

finally when I click on the back button I call the back method of the adapter and update everything with resetStack()

@OnClick(R.id.btnBack)
public void back(){
     swipeStackAdapter.back();
     swipeStack.resetStack();
}

I hope I help you

hug, greetings

@balavishnu
Copy link

@tundisi Thank you. Your solution worked. Only problem is that the "back" Animation is not smooth, is there any way to make it smooth?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants