Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to manually reset offsets of bottomview #190

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PulfordJ
Copy link

Using

swipeLayout.close(true, true); 

doesn't appear to guarantee this. I suspect the library assumes the user is manually closing the view and doesn't upset the offset in all or some cases. Adding manual resetting of offset allowed the use of Google Inbox like swipe-to-delete functionality:

Example listener with the new function:

  swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {


            public void onStartOpen(SwipeLayout swipeLayout) {

            }

            @Override
            public void onOpen(SwipeLayout swipeLayout) {

            }

            @Override
            public void onStartClose(SwipeLayout swipeLayout) {

            }

            @Override
            public void onClose(SwipeLayout swipeLayout) {

            }

            @Override
            public void onUpdate(SwipeLayout swipeLayout, int i, int i2) {

            }

            @Override
            public void onHandRelease(SwipeLayout swipeLayout, float xvel, float yvel) {

                //If item is fully open commence delete action.
                if (swipeLayout.getOpenStatus().equals(SwipeLayout.Status.Open)) {
                    Toast.makeText(context, "Item deleted", Toast.LENGTH_SHORT).show();
                   //Action to remove item here.
                }
                //If it is half open then close item, we don't want to delete unless the user
                //scrolls all the way.
                else if (swipeLayout.getOpenStatus().equals(SwipeLayout.Status.Middle)){
                    swipeLayout.close(true, true);
                    //Use resetOffsets to prevent bug
                    // where bottomView scrolls across the item
                    // more and more
                    // on each half-open-release event
                    swipeLayout.resetOffsets();

                }
            }
        });

Of course if you have any idea how to duplicate this functionality without exposing the extra function then go for it or I can do it with guidance/time. I would have attempted this but I think it would have risked bugging out the "smooth" close function parameter .

amartinz and others added 3 commits May 29, 2015 01:59
Change-Id: I9497fb07a9d29d274b6d02ff29c4610fc353225d
Signed-off-by: Alexander Martinz <eviscerationls@gmail.com>
…(true, true) doesn't appear to guarentee this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants