public abstract class PullToRefreshBase<T extends View>
extends LinearLayout
Modifier and Type | Class and Description |
---|---|
static interface |
PullToRefreshBase.OnLastItemVisibleListener |
static interface |
PullToRefreshBase.OnRefreshListener
Simple Listener to listen for any callbacks to Refresh.
|
static interface |
PullToRefreshBase.OnRefreshListener2
An advanced version of the Listener to listen for callbacks to Refresh.
|
(package private) class |
PullToRefreshBase.SmoothScrollRunnable |
Modifier and Type | Field and Description |
---|---|
(package private) static boolean |
DEBUG |
(package private) static float |
FRICTION |
(package private) static java.lang.String |
LOG_TAG |
(package private) static int |
MANUAL_REFRESHING |
private int |
mCurrentMode |
private PullToRefreshBase.SmoothScrollRunnable |
mCurrentSmoothScrollRunnable |
private boolean |
mDisableScrollingWhileRefreshing |
private LoadingLayout |
mFooterLayout |
private Handler |
mHandler |
private int |
mHeaderHeight |
private LoadingLayout |
mHeaderLayout |
private float |
mInitialMotionY |
private boolean |
mIsBeingDragged |
private float |
mLastMotionX |
private float |
mLastMotionY |
private int |
mMode |
static int |
MODE_BOTH |
static int |
MODE_PULL_DOWN_TO_REFRESH |
static int |
MODE_PULL_UP_TO_REFRESH |
private PullToRefreshBase.OnRefreshListener |
mOnRefreshListener |
private PullToRefreshBase.OnRefreshListener2 |
mOnRefreshListener2 |
private boolean |
mPullToRefreshEnabled |
(package private) T |
mRefreshableView |
private boolean |
mShowViewWhileRefreshing |
private int |
mState |
private int |
mTouchSlop |
(package private) static int |
PULL_TO_REFRESH |
(package private) static int |
REFRESHING |
(package private) static int |
RELEASE_TO_REFRESH |
(package private) static java.lang.String |
STATE_CURRENT_MODE |
(package private) static java.lang.String |
STATE_DISABLE_SCROLLING_REFRESHING |
(package private) static java.lang.String |
STATE_MODE |
(package private) static java.lang.String |
STATE_SHOW_REFRESHING_VIEW |
(package private) static java.lang.String |
STATE_STATE |
(package private) static java.lang.String |
STATE_SUPER |
Constructor and Description |
---|
PullToRefreshBase(Context context) |
PullToRefreshBase(Context context,
AttributeSet attrs) |
PullToRefreshBase(Context context,
int mode) |
Modifier and Type | Method and Description |
---|---|
protected void |
addRefreshableView(Context context,
T refreshableView) |
protected abstract T |
createRefreshableView(Context context,
AttributeSet attrs)
This is implemented by derived classes to return the created View.
|
T |
getAdapterView()
Deprecated.
|
int |
getCurrentMode()
Get the mode that this view is currently in.
|
protected LoadingLayout |
getFooterLayout() |
protected int |
getHeaderHeight() |
protected LoadingLayout |
getHeaderLayout() |
int |
getMode()
Get the mode that this view has been set to.
|
T |
getRefreshableView()
Get the Wrapped Refreshable View.
|
boolean |
getShowViewWhileRefreshing()
Get whether the 'Refreshing' View should be automatically shown when
refreshing.
|
protected int |
getState() |
boolean |
hasPullFromTop() |
private void |
init(Context context,
AttributeSet attrs) |
boolean |
isDisableScrollingWhileRefreshing()
Returns whether the widget has disabled scrolling on the Refreshable View
while refreshing.
|
boolean |
isPullToRefreshEnabled()
Whether Pull-to-Refresh is enabled
|
private boolean |
isReadyForPull() |
protected abstract boolean |
isReadyForPullDown()
Implemented by derived class to return whether the View is in a mState
where the user can Pull to Refresh by scrolling down.
|
protected abstract boolean |
isReadyForPullUp()
Implemented by derived class to return whether the View is in a mState
where the user can Pull to Refresh by scrolling up.
|
boolean |
isRefreshing()
Returns whether the Widget is currently in the Refreshing mState
|
private void |
measureView(View child) |
boolean |
onInterceptTouchEvent(MotionEvent event) |
void |
onRefreshComplete()
Mark the current Refresh as complete.
|
protected void |
onRestoreInstanceState(Parcelable state) |
protected Parcelable |
onSaveInstanceState() |
boolean |
onTouchEvent(MotionEvent event) |
private boolean |
pullEvent()
Actions a Pull Event
|
protected void |
resetHeader() |
void |
setDisableScrollingWhileRefreshing(boolean disableScrollingWhileRefreshing)
By default the Widget disabled scrolling on the Refreshable View while
refreshing.
|
protected void |
setHeaderScroll(int y) |
void |
setLastUpdatedLabel(java.lang.CharSequence label)
Set the Last Updated Text.
|
void |
setLongClickable(boolean longClickable) |
void |
setOnRefreshListener(PullToRefreshBase.OnRefreshListener listener)
Set OnRefreshListener for the Widget
|
void |
setOnRefreshListener(PullToRefreshBase.OnRefreshListener2 listener)
Set OnRefreshListener for the Widget
|
void |
setPullLabel(java.lang.String pullLabel)
Set Text to show when the Widget is being Pulled
setPullLabel(releaseLabel, MODE_BOTH) |
void |
setPullLabel(java.lang.String pullLabel,
int mode)
Set Text to show when the Widget is being Pulled
|
void |
setPullToRefreshEnabled(boolean enable)
A mutator to enable/disable Pull-to-Refresh for the current View
|
void |
setRefreshing() |
void |
setRefreshing(boolean doScroll)
Sets the Widget to be in the refresh mState.
|
protected void |
setRefreshingInternal(boolean doScroll) |
void |
setRefreshingLabel(java.lang.String refreshingLabel)
Set Text to show when the Widget is refreshing
setRefreshingLabel(releaseLabel, MODE_BOTH) |
void |
setRefreshingLabel(java.lang.String refreshingLabel,
int mode)
Set Text to show when the Widget is refreshing
|
void |
setReleaseLabel(java.lang.String releaseLabel)
Set Text to show when the Widget is being pulled, and will refresh when
released.
|
void |
setReleaseLabel(java.lang.String releaseLabel,
int mode)
Set Text to show when the Widget is being pulled, and will refresh when
released
|
void |
setShowViewWhileRefreshing(boolean showView)
A mutator to enable/disable whether the 'Refreshing' View should be
automatically shown when refreshing.
|
protected void |
smoothScrollTo(int y) |
static final boolean DEBUG
static final java.lang.String LOG_TAG
static final float FRICTION
static final int PULL_TO_REFRESH
static final int RELEASE_TO_REFRESH
static final int REFRESHING
static final int MANUAL_REFRESHING
public static final int MODE_PULL_DOWN_TO_REFRESH
public static final int MODE_PULL_UP_TO_REFRESH
public static final int MODE_BOTH
static final java.lang.String STATE_STATE
static final java.lang.String STATE_MODE
static final java.lang.String STATE_CURRENT_MODE
static final java.lang.String STATE_DISABLE_SCROLLING_REFRESHING
static final java.lang.String STATE_SHOW_REFRESHING_VIEW
static final java.lang.String STATE_SUPER
private int mTouchSlop
private float mInitialMotionY
private float mLastMotionX
private float mLastMotionY
private boolean mIsBeingDragged
private int mState
private int mMode
private int mCurrentMode
T extends View mRefreshableView
private boolean mPullToRefreshEnabled
private boolean mShowViewWhileRefreshing
private boolean mDisableScrollingWhileRefreshing
private LoadingLayout mHeaderLayout
private LoadingLayout mFooterLayout
private int mHeaderHeight
private final Handler mHandler
private PullToRefreshBase.OnRefreshListener mOnRefreshListener
private PullToRefreshBase.OnRefreshListener2 mOnRefreshListener2
private PullToRefreshBase.SmoothScrollRunnable mCurrentSmoothScrollRunnable
public PullToRefreshBase(Context context)
public PullToRefreshBase(Context context, int mode)
public PullToRefreshBase(Context context, AttributeSet attrs)
public final T getAdapterView()
getRefreshableView()
from now on.public final T getRefreshableView()
public final boolean getShowViewWhileRefreshing()
public final boolean isPullToRefreshEnabled()
public final int getCurrentMode()
MODE_BOTH
.MODE_PULL_DOWN_TO_REFRESH
or
MODE_PULL_UP_TO_REFRESH
public final int getMode()
MODE_BOTH
, you can use getCurrentMode()
to
check which mode the view is currently inMODE_PULL_DOWN_TO_REFRESH
,
MODE_PULL_UP_TO_REFRESH
or MODE_BOTH
public final boolean isDisableScrollingWhileRefreshing()
public final boolean isRefreshing()
public final void setDisableScrollingWhileRefreshing(boolean disableScrollingWhileRefreshing)
disableScrollingWhileRefreshing
- - true if you want to disable
scrolling while refreshingpublic final void onRefreshComplete()
public final void setOnRefreshListener(PullToRefreshBase.OnRefreshListener listener)
listener
- - Listener to be used when the Widget is set to Refreshpublic final void setOnRefreshListener(PullToRefreshBase.OnRefreshListener2 listener)
listener
- - Listener to be used when the Widget is set to Refreshpublic final void setPullToRefreshEnabled(boolean enable)
enable
- Whether Pull-To-Refresh should be usedpublic final void setShowViewWhileRefreshing(boolean showView)
showView
- public void setReleaseLabel(java.lang.String releaseLabel)
setReleaseLabel(releaseLabel, MODE_BOTH)
releaseLabel
- - String to displaypublic void setPullLabel(java.lang.String pullLabel)
setPullLabel(releaseLabel, MODE_BOTH)
releaseLabel
- - String to displaypublic void setRefreshingLabel(java.lang.String refreshingLabel)
setRefreshingLabel(releaseLabel, MODE_BOTH)
releaseLabel
- - String to displaypublic void setReleaseLabel(java.lang.String releaseLabel, int mode)
releaseLabel
- - String to displaymode
- - Either MODE_PULL_DOWN_TO_REFRESH
,
MODE_PULL_UP_TO_REFRESH
or MODE_BOTH
depending on which label you want to changepublic void setPullLabel(java.lang.String pullLabel, int mode)
pullLabel
- - String to displaymode
- - Either MODE_PULL_DOWN_TO_REFRESH
,
MODE_PULL_UP_TO_REFRESH
or MODE_BOTH
depending on which label you want to changepublic void setRefreshingLabel(java.lang.String refreshingLabel, int mode)
refreshingLabel
- - String to displaymode
- - Either MODE_PULL_DOWN_TO_REFRESH
,
MODE_PULL_UP_TO_REFRESH
or MODE_BOTH
depending on which label you want to changepublic final void setRefreshing()
public final void setRefreshing(boolean doScroll)
doScroll
- - true if you want to force a scroll to the Refreshing
view.public void setLastUpdatedLabel(java.lang.CharSequence label)
label
- - Label to setpublic final boolean hasPullFromTop()
public final boolean onTouchEvent(MotionEvent event)
public final boolean onInterceptTouchEvent(MotionEvent event)
protected void addRefreshableView(Context context, T refreshableView)
protected abstract T createRefreshableView(Context context, AttributeSet attrs)
context
- Context to create view withattrs
- AttributeSet from wrapped class. Means that anything you
include in the XML layout declaration will be routed to the
created Viewprotected final LoadingLayout getFooterLayout()
protected final LoadingLayout getHeaderLayout()
protected final int getHeaderHeight()
protected final int getState()
protected abstract boolean isReadyForPullDown()
protected abstract boolean isReadyForPullUp()
protected Parcelable onSaveInstanceState()
protected void onRestoreInstanceState(Parcelable state)
protected void resetHeader()
protected void setRefreshingInternal(boolean doScroll)
protected final void setHeaderScroll(int y)
protected final void smoothScrollTo(int y)
private void init(Context context, AttributeSet attrs)
private void measureView(View child)
private boolean pullEvent()
private boolean isReadyForPull()
public void setLongClickable(boolean longClickable)