From 70c4c15d751e7abd3c7ef0cf032bb251f9ed98b0 Mon Sep 17 00:00:00 2001 From: William Bae Date: Sun, 9 Mar 2014 01:35:51 +0900 Subject: [PATCH 1/3] Added themeability for arrow --- .../android/widget/PullToRefreshListView.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java index 315ebf6..9a0250f 100644 --- a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java +++ b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java @@ -54,6 +54,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) { @@ -101,6 +103,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(); @@ -244,7 +248,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. @@ -330,6 +334,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(); From 8a53cb8337c9c8d79baae474650115e85a35873b Mon Sep 17 00:00:00 2001 From: William Bae Date: Sun, 9 Mar 2014 01:43:13 +0900 Subject: [PATCH 2/3] Fixed a little wrong spacing A tab used instead of 4-spaces in one of the lines. --- .../com/markupartist/android/widget/PullToRefreshListView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java index 9a0250f..8df8626 100644 --- a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java +++ b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java @@ -343,7 +343,7 @@ public void setArrowBitmap(Bitmap arrow) { } public void setArrowDrawable(Drawable arrow) { - mArrowDrawable = arrow; + mArrowDrawable = arrow; mRefreshViewImage.setImageDrawable(arrow); } From 1184f8657338ea551930a28f96ae3ad2dfa04d3d Mon Sep 17 00:00:00 2001 From: William Bae Date: Sun, 9 Mar 2014 15:29:32 +0900 Subject: [PATCH 3/3] Fixed missing imports --- .../com/markupartist/android/widget/PullToRefreshListView.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java index 8df8626..d745df7 100644 --- a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java +++ b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java @@ -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;