Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themeable arrow #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -54,6 +57,8 @@ public class PullToRefreshListView extends ListView implements OnScrollListener
private int mRefreshOriginalTopPadding;
private int mLastMotionY;

private Drawable mArrowDrawable = null;

private boolean mBounceHack;

public PullToRefreshListView(Context context) {
Expand Down Expand Up @@ -101,6 +106,8 @@ private void init(Context context) {
(TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at);

mRefreshViewImage.setMinimumHeight(50);
mArrowDrawable = mRefreshViewImage.getDrawable();

mRefreshView.setOnClickListener(new OnClickRefreshListener());
mRefreshOriginalTopPadding = mRefreshView.getPaddingTop();

Expand Down Expand Up @@ -244,7 +251,7 @@ private void resetHeader() {
// Set refresh view text to the pull label
mRefreshViewText.setText(R.string.pull_to_refresh_tap_label);
// Replace refresh drawable with arrow drawable
mRefreshViewImage.setImageResource(R.drawable.ic_pulltorefresh_arrow);
mRefreshViewImage.setImageDrawable(mArrowDrawable);
// Clear the full rotation animation
mRefreshViewImage.clearAnimation();
// Hide progress bar and arrow.
Expand Down Expand Up @@ -330,6 +337,19 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
}
}

public void setArrowResource(int resId) {
setArrowDrawable(getResources().getDrawable(resId));
}

public void setArrowBitmap(Bitmap arrow) {
setArrowDrawable(new BitmapDrawable(arrow));
}

public void setArrowDrawable(Drawable arrow) {
mArrowDrawable = arrow;
mRefreshViewImage.setImageDrawable(arrow);
}

public void prepareForRefresh() {
resetHeaderPadding();

Expand Down