Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Banes committed Feb 2, 2013
2 parents 12ebe85 + bff78c4 commit 3bd8ef6
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 41 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED

* * *

# Pull To Refresh Views for Android

![Screenshot](https://github.com/chrisbanes/Android-PullToRefresh/raw/master/header_graphic.png)
Expand Down
2 changes: 1 addition & 1 deletion extras/PullToRefreshListFragment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>extras</artifactId>
<version>2.1.1</version>
<version>2.1.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extras/PullToRefreshViewPager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>extras</artifactId>
<version>2.1.1</version>

This comment has been minimized.

Copy link
@sicp618

sicp618 May 15, 2015

古古怪怪

<version>2.1.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extras/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>parent</artifactId>
<version>2.1.1</version>
<version>2.1.2-SNAPSHOT</version>
</parent>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>parent</artifactId>
<version>2.1.1</version>
<version>2.1.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Binary file modified library/res/drawable-hdpi/default_ptr_rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified library/res/drawable-mdpi/default_ptr_rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified library/res/drawable-xhdpi/default_ptr_rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions library/res/values-fi/pull_refresh_strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="pull_to_refresh_pull_label">Päivitä vetämällä alas…</string>
<string name="pull_to_refresh_release_label">Päivitä vapauttamalla…</string>
<string name="pull_to_refresh_refreshing_label">Päivitetään…</string>

<!-- Just use standard Pull Down String when pulling up. These can be set for languages which require it -->
<string name="pull_to_refresh_from_bottom_pull_label">Päivitä vetämällä ylös…</string>
<string name="pull_to_refresh_from_bottom_release_label">@string/pull_to_refresh_release_label</string>
<string name="pull_to_refresh_from_bottom_refreshing_label">@string/pull_to_refresh_refreshing_label</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ public void setAdapter(ListAdapter adapter) {
public final void setEmptyView(View newEmptyView) {
FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();

// If we already have an Empty View, remove it
if (null != mEmptyView) {
refreshableViewWrapper.removeView(mEmptyView);
}

if (null != newEmptyView) {
// New view needs to be clickable so that Android recognizes it as a
// target for Touch Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public abstract class PullToRefreshBase<T extends View> extends LinearLayout imp

static final boolean DEBUG = true;

static final boolean USE_HW_LAYERS = false;

static final String LOG_TAG = "PullToRefresh";

static final float FRICTION = 2.0f;
Expand Down Expand Up @@ -345,22 +347,10 @@ public final boolean onTouchEvent(MotionEvent event) {
if (mIsBeingDragged) {
mIsBeingDragged = false;

if (mState == State.RELEASE_TO_REFRESH) {

if (null != mOnRefreshListener) {
setState(State.REFRESHING, true);
mOnRefreshListener.onRefresh(this);
return true;

} else if (null != mOnRefreshListener2) {
setState(State.REFRESHING, true);
if (mCurrentMode == Mode.PULL_FROM_START) {
mOnRefreshListener2.onPullDownToRefresh(this);
} else if (mCurrentMode == Mode.PULL_FROM_END) {
mOnRefreshListener2.onPullUpToRefresh(this);
}
return true;
}
if (mState == State.RELEASE_TO_REFRESH
&& (null != mOnRefreshListener || null != mOnRefreshListener2)) {
setState(State.REFRESHING, true);
return true;
}

// If we're already refreshing, just scroll back to the top
Expand Down Expand Up @@ -744,19 +734,31 @@ protected void onRefreshing(final boolean doScroll) {

if (doScroll) {
if (mShowViewWhileRefreshing) {

// Call Refresh Listener when the Scroll has finished
OnSmoothScrollFinishedListener listener = new OnSmoothScrollFinishedListener() {
@Override
public void onSmoothScrollFinished() {
callRefreshListener();
}
};

switch (mCurrentMode) {
case MANUAL_REFRESH_ONLY:
case PULL_FROM_END:
smoothScrollTo(getFooterSize());
smoothScrollTo(getFooterSize(), listener);
break;
default:
case PULL_FROM_START:
smoothScrollTo(-getHeaderSize());
smoothScrollTo(-getHeaderSize(), listener);
break;
}
} else {
smoothScrollTo(0);
}
} else {
// We're not scrolling, so just call Refresh Listener now
callRefreshListener();
}
}

Expand Down Expand Up @@ -943,11 +945,15 @@ protected final void refreshRefreshableViewSize(int width, int height) {
*
* @param value - New Scroll value
*/
protected final void setHeaderScroll(final int value) {
protected final void setHeaderScroll(int value) {
if (DEBUG) {
Log.d(LOG_TAG, "setHeaderScroll: " + value);
}

// Clamp value to with pull scroll range
final int maximumPullScroll = getMaximumPullScroll();
value = Math.min(maximumPullScroll, Math.max(-maximumPullScroll, value));

if (mLayoutVisibilityChangesEnabled) {
if (value < 0) {
mHeaderLayout.setVisibility(View.VISIBLE);
Expand All @@ -959,12 +965,15 @@ protected final void setHeaderScroll(final int value) {
}
}

/**
* Use a Hardware Layer on the Refreshable View if we've scrolled at
* all. We don't use them on the Header/Footer Views as they change
* often, which would negate any HW layer performance boost.
*/
ViewCompat.setLayerType(mRefreshableViewWrapper, value != 0 ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE);
if (USE_HW_LAYERS) {
/**
* Use a Hardware Layer on the Refreshable View if we've scrolled at
* all. We don't use them on the Header/Footer Views as they change
* often, which would negate any HW layer performance boost.
*/
ViewCompat.setLayerType(mRefreshableViewWrapper, value != 0 ? View.LAYER_TYPE_HARDWARE
: View.LAYER_TYPE_NONE);
}

switch (getPullToRefreshScrollDirection()) {
case VERTICAL:
Expand All @@ -986,6 +995,17 @@ protected final void smoothScrollTo(int scrollValue) {
smoothScrollTo(scrollValue, getPullToRefreshScrollDuration());
}

/**
* Smooth Scroll to position using the default duration of
* {@value #SMOOTH_SCROLL_DURATION_MS} ms.
*
* @param scrollValue - Position to scroll to
* @param listener - Listener for scroll
*/
protected final void smoothScrollTo(int scrollValue, OnSmoothScrollFinishedListener listener) {
smoothScrollTo(scrollValue, getPullToRefreshScrollDuration(), 0, listener);
}

/**
* Smooth Scroll to position using the longer default duration of
* {@value #SMOOTH_SCROLL_LONG_DURATION_MS} ms.
Expand Down Expand Up @@ -1038,6 +1058,18 @@ private void addRefreshableView(Context context, T refreshableView) {
LayoutParams.MATCH_PARENT));
}

private void callRefreshListener() {
if (null != mOnRefreshListener) {
mOnRefreshListener.onRefresh(this);
} else if (null != mOnRefreshListener2) {
if (mCurrentMode == Mode.PULL_FROM_START) {
mOnRefreshListener2.onPullDownToRefresh(this);
} else if (mCurrentMode == Mode.PULL_FROM_END) {
mOnRefreshListener2.onPullUpToRefresh(this);
}
}
}

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
switch (getPullToRefreshScrollDirection()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ private void setSubHeaderText(CharSequence label) {
mSubHeaderText.setVisibility(View.GONE);
} else {
mSubHeaderText.setText(label);
mSubHeaderText.setVisibility(View.VISIBLE);

// Only set it to Visible if we're GONE, otherwise VISIBLE will
// be set soon
if (View.GONE == mSubHeaderText.getVisibility()) {
mSubHeaderText.setVisibility(View.VISIBLE);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirecti

public void onLoadingDrawableSet(Drawable imageDrawable) {
if (null != imageDrawable) {
mRotationPivotX = imageDrawable.getIntrinsicWidth() / 2f;
mRotationPivotY = imageDrawable.getIntrinsicHeight() / 2f;
mRotationPivotX = Math.round(imageDrawable.getIntrinsicWidth() / 2f);
mRotationPivotY = Math.round(imageDrawable.getIntrinsicHeight() / 2f);
}
}

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>2.1.1</version>
<version>2.1.2-SNAPSHOT</version>
<name>Android-PullToRefresh Project</name>
<description>Implementation of the Pull-to-Refresh UI Pattern for Android.</description>
<url>https://github.com/chrisbanes/Android-PullToRefresh</url>
Expand All @@ -24,7 +24,7 @@
<url>https://github.com/chrisbanes/Android-PullToRefresh</url>
<connection>scm:git:git://github.com/chrisbanes/Android-PullToRefresh.git</connection>
<developerConnection>scm:git:git@github.com:chrisbanes/Android-PullToRefresh.git</developerConnection>
<tag>v2.1.1</tag>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
Expand Down
2 changes: 1 addition & 1 deletion sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.github.chrisbanes.pulltorefresh</groupId>
<artifactId>parent</artifactId>
<version>2.1.1</version>
<version>2.1.2-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion sample/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# project structure.

# Project target.
target=android-15
target=android-16
android.library.reference.1=../library
android.library.reference.2=../extras/PullToRefreshListFragment
android.library.reference.3=../extras/PullToRefreshViewPager

4 comments on commit 3bd8ef6

@teze
Copy link

@teze teze commented on 3bd8ef6 Apr 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test

@JiffyCui
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, When the listview item number can't full screen, how to show top divider line and bottom divider line?

@JiffyCui
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, When the listview item number can't full screen, how to show top divider line and bottom divider line?

@TruongTranSiGlaz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help me check issue Pull up to refresh is OK

But pull down some time it Understand is Pull Up.

Code mPullRefreshGridView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {

    @Override
    public void onPullDownToRefresh(
            PullToRefreshBase<GridView> refreshView) {
        //Load more data
        currentPage++;
        LoadData();
    }

    @Override
    public void onPullUpToRefresh(
            PullToRefreshBase<GridView> refreshView) {
        //Refresh data
        currentPage = 1;
        loadData();
    }

});

Please sign in to comment.