Skip to content

Commit

Permalink
disable refresh on the attacher
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Aug 26, 2014
1 parent 082c13f commit 1868cc5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.wordpress.android.util.R;

import uk.co.senab.actionbarpulltorefresh.library.DefaultHeaderTransformer;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher;
import uk.co.senab.actionbarpulltorefresh.library.sdk.Compat;

public class PullToRefreshHeaderTransformer extends DefaultHeaderTransformer {
Expand All @@ -21,6 +22,7 @@ public class PullToRefreshHeaderTransformer extends DefaultHeaderTransformer {
private OnTopScrollChangedListener mOnTopScrollChangedListener;
private boolean mIsNetworkRefreshMode;
private Context mContext;
private PullToRefreshAttacher mPullToRefreshAttacher;

public interface OnTopScrollChangedListener {
public void onTopScrollChanged(boolean scrolledOnTop);
Expand Down Expand Up @@ -53,10 +55,21 @@ public boolean hideHeaderView() {
return super.hideHeaderView();
}

public void setPullToRefreshAttacher(PullToRefreshAttacher pullToRefreshAttacher) {
mPullToRefreshAttacher = pullToRefreshAttacher;
}

private void setRefreshDisabled(boolean disabled) {
if (mPullToRefreshAttacher != null) {
mPullToRefreshAttacher.setRefreshDisabled(disabled);
}
}

@Override
public boolean showHeaderView() {
// Workaround to avoid this bug https://github.com/chrisbanes/ActionBar-PullToRefresh/issues/265
// Note, that also remove the alpha animation
setRefreshDisabled(false);
resetContentLayoutAlpha();

boolean changeVis = mHeaderView.getVisibility() != View.VISIBLE;
Expand All @@ -67,6 +80,7 @@ public boolean showHeaderView() {
} else {
// Network mode enabled and network not available: show a different PTR label
setPullText(mContext.getText(R.string.pull_to_refresh_pull_no_network_label));
setRefreshDisabled(true);
}
mHeaderView.setVisibility(View.VISIBLE);
AnimatorSet animSet = new AnimatorSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public boolean isReadyForPull(View view, float v, float v2) {
setupWizard.setup(mPullToRefreshLayout);
// set network refresh mode as default
setNetworkRefreshMode(true);
mHeaderTransformer.setPullToRefreshAttacher(mPullToRefreshLayout.getAttacher());
}

/**
Expand Down

0 comments on commit 1868cc5

Please sign in to comment.