Skip to content
This repository was archived by the owner on Apr 26, 2023. It is now read-only.
This repository was archived by the owner on Apr 26, 2023. It is now read-only.

Problem with SwipeRefreshLayout #54

Open

Description

@dostalleos

Hi, I'm using your EnhancedListView and it's great, but I have problem with it in combination with SwipeRefreshLayout from support library. If you swipe verticaly during swiping horizontaly it stops the item at the place and doesn't put it to right place. I'm cliping the image.
2014-08-04 15 54 44

Activity

  1. jcogilvie commented on Aug 26, 2014

    @jcogilvie

    Based on my testing, this only happens when the EnhancedListView is scrolled all the way to the top. A downward dragging motion causes the SwipeRefreshLayout to start its swipe animation.

    One possible solution I could imagine would be exposing mSwiping via getter, and using that value in a custom SwipeRefreshLayout to override SwipeRefreshLayout.canChildScrollUp:

    public boolean canChildScrollUp(){
        if(mEnhancedListView.isSwiping || !super.canChildScrollUp())
              return false;
        else
              return true;
    }
    
  2. jcogilvie commented on Aug 26, 2014

    @jcogilvie

    Confirmed using my fork (goldenspiral):

    package com.my.package;
    
    import de.timroes.android.listview.EnhancedListView;
    import de.timroes.android.listview.EnhancedListView.OnSwipeCallback;
    import android.content.Context;
    import android.support.v4.widget.SwipeRefreshLayout;
    import android.util.AttributeSet;
    
    public class EnhancedSwipeRefreshLayout extends SwipeRefreshLayout {
    
        private EnhancedListView lv;
        private boolean disableSwipeToRefresh;
    
        public EnhancedSwipeRefreshLayout(Context context) {
            super(context);
        }
    
        public EnhancedSwipeRefreshLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public void setEnhancedListViewChild(EnhancedListView v){
            this.lv = v;
            lv.setSwipeCallback(new OnSwipeCallback(){
                @Override
                public void onSwipeBegin(){
                    disableSwipeToRefresh = true;
                }
    
                @Override
                public void onSwipeEnd(){
                    disableSwipeToRefresh = false;
                }
            });
        }
    
        @Override
        public boolean canChildScrollUp(){
    
            // If we return TRUE from here, swipe to refresh is disabled.
            // If it's not disabled, we fall back to whatever super has to say.
            return disableSwipeToRefresh || super.canChildScrollUp();
        }
    }
    
    

    You might be also able to write the callbacks in a different way and just disable the SwipeRefreshLayout where I'm setting the boolean flag here.

  3. dostalleos commented on Aug 26, 2014

    @dostalleos
    Author

    Yes, you are right, that it happens only when EnhancedListView is scrolled all the way to the top.

    Your solution looking good, but there is no method setSwipeCallback and no OnSwipeCallback in EnhancedListView class.

  4. jcogilvie commented on Aug 26, 2014

    @jcogilvie

    I added it in my fork. Goldenspiral/EnhancedListView.
    On Aug 26, 2014 3:47 AM, "Leoš Dostál" notifications@github.com wrote:

    Yes, you are right, that it happens only when EnhancedListView is scrolled
    all the way to the top.

    Your solution looking good, but there is no method setSwipeCallback and no
    OnSwipeCallback in EnhancedListView class.

    —
    Reply to this email directly or view it on GitHub
    #54 (comment)
    .

  5. dostalleos commented on Aug 26, 2014

    @dostalleos
    Author

    Oh, I see, Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions