Created
January 25, 2015 23:09
-
-
Save illarionov/ecb10eacb91d6aa0ddc9 to your computer and use it in GitHub Desktop.
MySwipeRefreshLayout for https://code.google.com/p/android/issues/detail?id=80227
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.swiperefreshtest; | |
import android.content.Context; | |
import android.support.v4.widget.SwipeRefreshLayout; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.AbsListView; | |
public class MySwipeRefreshLayout extends SwipeRefreshLayout | |
{ | |
public MySwipeRefreshLayout(Context context) { | |
super(context); | |
} | |
public MySwipeRefreshLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
public boolean canChildScrollUp() { | |
View target = getChildAt(0); | |
if (target instanceof AbsListView) { | |
final AbsListView absListView = (AbsListView) target; | |
return absListView.getChildCount() > 0 | |
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) | |
.getTop() < absListView.getPaddingTop()); | |
} else { | |
return target.getScrollY() > 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment