question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

swipeLayout.close() does nothing

See original GitHub issue

Hi,

When I am calling the method close() in a SwipeListener() nothing happen.

Here is a sample code :

            mSwipeLayout.addDrag(SwipeLayout.DragEdge.Right, mHideSwipeView);
            mSwipeLayout.setClickToClose(true);
            mSwipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
                @Override
                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 leftOffset, int rightOffset) {

                }

                @Override
                public void onHandRelease(SwipeLayout swipeLayout, float xvel, float yvel) {
                    if(swipeLayout.getOpenStatus() == SwipeLayout.Status.Open) {
                        onPictureHide();
                        swipeLayout.close();
                    }
                }
            });

This code is in a ViewHolder which is in Adapter which extend RecyclerSwipeAdapter

The goal is to trig an action once the swipe is visible and totally open. Then it closes itself automatically.

Unfortunatly the bottom view does not close… With a swipeLayout.close(false); it works but there is the issue #125 ! Finally with a call on adapter.closeItem(position) it works, but there is a mRecyclerAdapter.notifyDataSetChanged(); which destroy my UX.

Feel free to ask more information ! 😃

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
linfaxincommented, Apr 21, 2015

Try close with a delay:

swipeLayout.postDelay(new Runnable() {
    @Override
    public void run() {
        swipeLayout.close();
    }
}, 50);
3reactions
darzulcommented, Apr 21, 2015

It works fine 😃 thank you

Just a little edit on the method name which is postDelayed()

I will let the issue open because this solution is a kind of hack, but very good for the moment !

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Swipelayout doesn't close - Stack Overflow
swipelayout :library:1.2.0@aar library for swiping my layout but my layout doesn't close onHandRelease() method. It will call when full layout is ...
Read more >
daimajia/AndroidSwipeLayout - Gitter
There is a demo on how to use EditText in SwipeLayout. ... x5 Pro ,the item can not be draged, it seems that...
Read more >
Android Pull/Swipe Down to Refresh - DigitalOcean
On swiping down this listener is triggered and the OnRefresh() method is called. We can override this method according to our needs.
Read more >
Implement swipe to dismiss - Flutter documentation
Implement swipe to dismiss · 1. Create a list of items. Create a data source; Convert the data source into a list ·...
Read more >
com.daimajia.swipe.SwipeLayout.close java code examples
SwipeLayout.close(). /** * smoothly close surface. */ public void close() { close(true, true); }. origin: daimajia/AndroidSwipeLayout ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found