daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.38k stars 2.67k forks source link

when I swipe to open item, it auto closed in some phones #250

Open ben-ying opened 8 years ago

ben-ying commented 8 years ago

when I swipe to open item, it auto closed in some phones? BTW, are there any methods to prevent close listview item when I call adapter.notifyDataChanged?

ben-ying commented 8 years ago

Reappear this issue in your main page demo. But in listview or gridview demo it works.

ben-ying commented 8 years ago

I fixed the issue by cloning the project and added it as a library, but it doesn't by adding "com.daimajia.swipelayout:library:1.2.0@aar" in gradle file.

MelerosPaw commented 8 years ago

I solved it by commenting line safeBottomView() in method onLayout():

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int childCount = getChildCount();
    if (childCount != 2) {
        throw new IllegalStateException("You need 2  views in SwipeLayout");
    }
    if (!(getChildAt(0) instanceof ViewGroup) || !(getChildAt(1) instanceof ViewGroup)) {
        throw new IllegalArgumentException("The 2 children in SwipeLayout must be an instance of ViewGroup");
    }

    if (mShowMode == ShowMode.PullOut)
        layoutPullOut();
    else if (mShowMode == ShowMode.LayDown)
        layoutLayDown();
//        safeBottomView();

    if (mOnLayoutListeners != null)
        for (int i = 0; i < mOnLayoutListeners.size(); i++) {
            mOnLayoutListeners.get(i).onLayout(this);
        }
  }
Zhuinden commented 8 years ago

This problem is reproduced in Lenovo A5500-H

Confirmed that above fix works.

himank1991 commented 8 years ago

safeBottomView(); if i comment this onclick item and longpress and double tap function dont work properly as swipe layout comes every time .

sr-devphp commented 8 years ago

I also found this issue when I swipe to open item, it auto closed in Lollipop 5.0

linq8261 commented 8 years ago

红米note2,也是这个问题。

HirayClay commented 8 years ago

it shakes when i swipe left to open ,acting like a bug.I test on Meizu MX5(Chinese cellphone,which phone seems to modify much android ui,may be it is the reason it happened so)

Zhuinden commented 8 years ago
private void updateBottomViews() {
    View currentBottomView = getCurrentBottomView();
    if(currentBottomView != null) {
        if(mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
            mDragDistance = currentBottomView.getMeasuredWidth() - dp2px(getCurrentOffset());
        } else {
            mDragDistance = currentBottomView.getMeasuredHeight() - dp2px(getCurrentOffset());
        }
    }

    if(mShowMode == ShowMode.PullOut) {
        layoutPullOut();
    } else if(mShowMode == ShowMode.LayDown) {
        layoutLayDown();
    }

    //safeBottomView();
}
briantes commented 8 years ago

Same error on Conkertab SX5. Some solutions? I need longpress too.

fh127 commented 8 years ago

Hi, I have the same error in a Lenovo Tablet, Does this library have a new update to solve the problem?

thanks

Zhuinden commented 8 years ago

@fh127 do what I did -_-

briantes commented 8 years ago

I have resolved this issue but whitout change the code as Zhuinden said. I followed the instructions "how to use" and "SwipeAdapter usage" and It worked good. I didn't use the component as It must be used. Now It works good.
The only question is sometimes (randomly) I can't swipe the layout to open the options. But It's absolutly random and I don't know why.

ThijsmvSchaik commented 8 years ago

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);
EpariNigam commented 8 years ago

I also faced the issue, what to do unable to understand.

Zhuinden commented 8 years ago

@EpariNigam do what I did

EpariNigam commented 8 years ago

@Zhuinden I already commented that line still facing issue.

ThijsmvSchaik commented 8 years ago

@Zhuinden You have to do two things. 1:

2:

If you still don't understand this method please reply with a github link to your code.

Greetings, Thijs van Schaik

osancus commented 7 years ago

Had same problem on acer b3-a30 10" tablet. @ThijsmvSchaik solution worked like a charm, the only draw back is that i have to giveup the animation.

stephanemathis commented 7 years ago

I simply removed the safeBottomView() and it works like a charm.

abhilash88 commented 7 years ago

how did you remove the safe bottom view? i think the library has the files locked

Zhuinden commented 7 years ago

By cloning the library and adding it to my project and removing the line

aik117 commented 6 years ago

i have tried this solution and many others but whenever i call textview.settext in onUpdate method the swipe closes itself automatically. I have even added the library as a module in my project and commented the method safeBottomViews() in updateBottomViews() in SwipeLayout.java but nothing seems to work. This library is very good no doubt but this issue is getting on my nerves now. Please if anyone got a solution then let me know. Thanks.

Zhuinden commented 6 years ago

@aik117 I used this library because we needed it to work on API 10, but now that even the support library doesn't work below API 14, it's probably best if you just implement this behavior yourself with https://github.com/blipinsk/ViewPropertyObjectAnimator and translate

aik117 commented 6 years ago

@Zhuinden thanks for replying i have been trying alot with this library. Now i will try this viewproperty library and see how to fix it in my code and will let you know.

MedveDomg commented 6 years ago

reproduced bug on meizu m2 note, why fix @Zhuinden still didn't add to library? I don't want to fork(

Zhuinden commented 6 years ago

This isn't my library 😄