Open coralinejones1985 opened 8 years ago
is this fix available on the maven repo?
No, it fixed only in my fork.
Even am facing this issue... I have swipeable RecyclerView having buttons. In some of the devices as I swipe from Right to left and as buttons gets visible, it automatically closes the expandable view.
Any help could be appreciated Thanks
@devilabhi You have to add a SwipeListener and a GlobalLayoutListener to your SwipeLayout Add an GlobalLayoutListener to your swipeLayout and keep a variable with the value isOpening> Example
swipeLayout.addSwipeListener(new SimpleSwipeListener() {
@Override
public void onStartOpen(SwipeLayout layout) {
isOpenSwipeLayout = true;
}
@Override
public void onStartClose(SwipeLayout layout) {
isOpenSwipeLayout = false;
}
});
swipeGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (isOpenSwipeLayout) {
// Opens the layout without animation
swipeLayout.open(false);
}
}
};
swipeLayout.getViewTreeObserver().addOnGlobalLayoutListener(swipeGlobalLayoutListener);
@ThijsmvSchaik 's implementation helped me to solve the issue. Here is the full implementation on ViewHolder class. Hope this helps.
@BindView(R.id.swpMyVehicleList)
SwipeLayout swipeLayout;
public TestViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
final boolean[] isOpenSwipeLayout = {false};
swipeLayout.addSwipeListener(new SimpleSwipeListener() {
@Override
public void onStartOpen(SwipeLayout layout) {
isOpenSwipeLayout[0] = true;
}
@Override
public void onStartClose(SwipeLayout layout) {
isOpenSwipeLayout[0] = false;
}
});
ViewTreeObserver.OnGlobalLayoutListener swipeGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (isOpenSwipeLayout[0]) {
// Opens the layout without animation
swipeLayout.open(false);
}
}
};
swipeLayout.getViewTreeObserver().addOnGlobalLayoutListener(swipeGlobalLayoutListener);
}
I also tried your demo, which has the same bug.