Last active
August 29, 2015 14:19
-
-
Save brh/e1cb70283f4a0d839978 to your computer and use it in GitHub Desktop.
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
import android.content.Context; | |
import android.support.v4.widget.SwipeRefreshLayout; | |
import android.util.AttributeSet; | |
import your.R; | |
/** | |
* Created by Bobby Hargett | |
*/ | |
public class SaneSwipeRefreshLayout extends SwipeRefreshLayout { | |
private boolean isFirstTime = true; | |
public SaneSwipeRefreshLayout(Context context) { | |
super(context); | |
defaultSetup(); | |
} | |
public SaneSwipeRefreshLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
defaultSetup(); | |
} | |
private void defaultSetup() { | |
setColorSchemeResources(R.color.allscriptsGreen, R.color.red, | |
R.color.progress1, R.color.blackColor); | |
} | |
@Override | |
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { | |
super.onLayout(changed, left, top, right, bottom); | |
if ( isFirstTime ){ | |
isFirstTime = false; | |
// most apps want to set refreshing as soon as screen shows, but if you do this with SwipeRefreshLayout | |
// it will be ignored if onMeasure hasn't been called, so this works around that silliness. | |
if ( isRefreshing() ){ | |
setRefreshing(false); | |
setRefreshing(true); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment