chthai64/SwipeRevealLayout

Add Close Swipe Row when just touching another Row like IPhone list handler.

cottonmega opened this issue · 4 comments

Thank you for providing your SwipeRevealLayout library. I have integrated your library into my existing ListView application replacing my Listviews with RecyclerViews and your library. But I have a question, I want the swipe library to work the same way on Android as it does on swipe on Apple IOS lists like mail . I want/need to learn how to detect and record when a row has been swiped open (e.g. myrow.IsCurrentlySwipedOpen = “true”) and use that condition later on, so that when the user just touches a row somewhere else in the list , the row that is swiped open will close (with no other action, just close) . I have already implemented the “only one row swiped at a time” feature which works just fine , but I am having a bit of trouble figuring out the best way to handle closing the swiped open row when I just touch another row (like on my Apple IPhone). If this could be conditional (e.g. xml - app:swipeCloseOnTouch=”true”) like the swipe edge from left, right, top or bottom currently is now (e.g. xml - app:dragEdge=”right”) , that would satisfy the developers who may not want the swiped row closed when someone simply touches another row. Thanks for any assistance for this close on touch feature and how to implement it currently or adding it as a new feature to the library. Thanks Roy Cotton

Never mind on my question. Using these links with some additional changes to the code I was able to make swipe on Android work exactly like Apple IPhone swipe using Apple Mail app as the model for how I wanted Android app swipe to work. This allows the two platforms UI (Android and IPhone) to look and work the same the same for either environment.

https://android-pratap.blogspot.com/2015/07/swipe-recyclerview-using.html?m=1

https://github.com/daimajia/AndroidSwipeLayout/
.

Hi Roy,

could you give me some hints what changes you have made to the AndroidSwipeLayout? I have the same problem at the moment.

Thanks and best regards

Marcel

Marcel, I was a bit surprised to get your email through github. I am surprised that I went back and commented my original github comment, a comment to myself. I never received a reply from the original author or anyone else on the changes necessary to my original question, which was how to make an Android ListView/RecyclerView work exactly like an view iPhone for swipe to reveal buttons and row handlers to handle the opening and closing of list rows on touch or swipe. My goal was to make an Android app and its IPhone twin UI work exactly the same. The Android purists will probably say that you should not try to do this, but I ignore the purists. Like many developers , I am/was somewhat careless in how I documented the changes I made to get this code to work like I wanted it to work , but I happily give the changed project to you (as a zip file) so that hopefully you can unzip it, load it into Android Studio , review it and get it running , and use it of pieces of it to include in whatever you are doing in your project.

So here are the details (the changed project) , and if you get this to work for your codebase, all I ask in return is that you let me know that you got this zip file of the project and if you also get the code to work. This is the code project I originally made changes to, before I moved this into my real code base. So just consider this to be a test project to get the swipe working like I wanted it to work.

The main details are this

I changed the xml source for the row to display 2 buttons instead of 3 buttons. Look at the file for details. (file – swipe_row_item.xml

I changed and added code to keep track of row swiping in SwipeRecyclerViewAdapter.java (see to close the rows on scrolling up or down , or touching a row to close and open row (this was months ago and of course I did not put enough comments in to understand the changes that I made, but if you get it running you will see that in fact, it works)

See/Review/Search For in SwipeRecyclerViewAdapter.java for these items and handler changes I made

int swipedCountTotal = 0;
boolean swipedCountOpenedBefore = false;
boolean swipedCountClosedBefore = false;

I also use Toast for the button click handlers after you swipe (More and Delete Button handlers)

I also used a toast for a click event on the surface of a row (not the buttons after swipe) but the top row surface, uncomment the toast in method viewHolder.swipeLayout.getSurfaceView().setOnClickListener( to see the click handler.

I probably will go back and make some additional comments to myself so I can follow my own code changes for this.

SwipeRecyclerViewNewBase050319.zip

Happy coding and I hope this helps you, please do let me know that you got this zip and do let me know if you get it to work for your code base . Roy/rgc/cottonmega

From: MarcelBreska [mailto:notifications@github.com]
Sent: Saturday, November 30, 2019 5:21 AM
To: chthai64/SwipeRevealLayout
Cc: cottonmega; Author
Subject: Re: [chthai64/SwipeRevealLayout] Add Close Swipe Row when just touching another Row like IPhone list handler. (#100)

Hi Roy,
could you give me some hints what changes you have made to the AndroidSwipeLayout? I have the same problem at the moment.
Thanks and best regards
Marcel

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.