Open vladut-lp opened 8 years ago
Hello. I've faced with the very similar problem. I need to restore the expand state of SwipeLayout when screen is rotated. I would like to hear any ideas
Hi,
I have found a newbie workaround... but it is not what I'm looking for. At the end of my "onBindViewHolder" method on recycleradapter, I have added a handler to delay the open action. What I really want, is to show the user that he can swipe left the list items. So I want that when the items are inflated, the layout to be opened, and after 1 second to close them. Here is my first try to achieve that :
try { final Handler handlerOpen = new Handler(); handlerOpen.postDelayed(new Runnable() { @Override public void run() { itemSwipe.open(false, false); } }, 100);
final Handler handlerClose = new Handler();
handlerClose.postDelayed(new Runnable()
{
@Override
public void run() {
itemSwipe.close();
}
}, 1000);
} catch (Exception e) { Log.e("RecycleAdapter", "On bind view error: " + e.getMessage()); }
It seems to work... but I'm pretty sure it's far from the best method to do what I want.
I have another idea where I would change the SwipeLayout class (add a method) where I set a boolean (animateAtFirst), true, and a int/float animationTime to specify how long should the layout stay "opened". On SwipeLayout , somewhere (I'm not really sure where, on view initialization, maybe after is inflated) I should check this property and if it's true, on the view initialization I should change the main and back layout positions, and also start a handler (waiting animation time I set on the new method) to "close" the swipeLayout.
Does that makes sense ?
Thanks ! Ps : Sorry for the code's look.... insert code function is useless, or I don't know how to use it.
a better approach is to do this. This ensures the layout is opened once the SwipeLayout is initialized.
swipeLayout.post(new Runnable() {
@Override
public void run() {
swipeLayout.open();
}});
Hi,
I am trying to inflate all my list items opened (dragged to left), but I don't really know how. On the xml there is no property to set for the view to be created like that. I have also tried to call open(false, false) or simple open() on method "onBindViewHolder" of my RecyclerViewAdapter, but with no success. I suppose when I call it, the item is not yet inflated.
Any ideas ?
Thanks, Vladut