Created
May 9, 2015 10:21
-
-
Save Neferetheka/872d7a6d863f76169152 to your computer and use it in GitHub Desktop.
FixedSwipeRefreshLayout
This file contains hidden or 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
import android.content.Context; | |
import android.support.v4.widget.SwipeRefreshLayout; | |
import android.util.AttributeSet; | |
/** | |
* Fix for SwipeRefreshLayout, which doesn't display the loading indicator if the onMeasure method hasn't been called. | |
* From https://code.google.com/p/android/issues/detail?id=77712 | |
*/ | |
public class FixedSwipeRefreshLayout extends SwipeRefreshLayout { | |
private boolean mMeasured = false; | |
private boolean mPreMeasureRefreshing = false; | |
public FixedSwipeRefreshLayout(Context context) { | |
super(context); | |
} | |
public FixedSwipeRefreshLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | |
if (!mMeasured) { | |
mMeasured = true; | |
setRefreshing(mPreMeasureRefreshing); | |
} | |
} | |
@Override | |
public void setRefreshing(boolean refreshing) { | |
if (mMeasured) { | |
super.setRefreshing(refreshing); | |
} else { | |
mPreMeasureRefreshing = refreshing; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment