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

How to get a card back? #40

Open
MartinL6 opened this issue Mar 9, 2017 · 1 comment
Open

How to get a card back? #40

MartinL6 opened this issue Mar 9, 2017 · 1 comment

Comments

@MartinL6
Copy link

MartinL6 commented Mar 9, 2017

can we do the opposite swipe to get the card back?

@ghost
Copy link

ghost commented Mar 27, 2017

I agree that there needs to be another function which involves getting the last card back to top or atleast into the view again. I almost found a way to get the last card back, but all it does right now for me is to go back one step and add the view but not viewing it so there is just a clickable view nothing to swipe.
If you want the code for the custom function I built, here it is:
`private void addLastCard() {
int positionOfLastCard;

    if (myAdapter.getCount() > 0) {
        positionOfLastCard = swipeStack.getCurrentPosition() - 1;
    } else {
        positionOfLastCard = adapterIndex;
    }
    if (positionOfLastCard >= 0) {
        LayoutInflater li;
        li = LayoutInflater.from(SWIPE.this);
        View v = li.inflate(R.layout.card, null);
        if (myAdapter.getView(positionOfLastCard, v, null) != null) {
            View newBottomChild = myAdapter.getView(positionOfLastCard, v, null);
            newBottomChild.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            newBottomChild.setTag(R.id.new_view, false);

            Log.d("getView() != null", (myAdapter.getView(positionOfLastCard, v, null) != null) + "");

            swipeStack.addView(newBottomChild);
        }
    }
}`

Feel free to edit the code so the view can be added properly and seen in the cardstack, the code has been modified a few times since i posted it as a comment here.

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

1 participant