Skip to content

Commit 424ed33

Browse files
author
Chris Banes
committed
1 parent 13c9077 commit 424ed33

4 files changed

Lines changed: 109 additions & 100 deletions

File tree

library/src/com/handmark/pulltorefresh/library/LoadingLayoutProxy.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ public class LoadingLayoutProxy implements ILoadingLayout {
1515
mLoadingLayouts = new HashSet<LoadingLayout>();
1616
}
1717

18-
void addLayout(LoadingLayout layout) {
18+
/**
19+
* This allows you to add extra LoadingLayout instances to this proxy. This
20+
* is only necessary if you keep your own instances, and want to have them
21+
* included in any
22+
* {@link PullToRefreshBase#createLoadingLayoutProxy(boolean, boolean)
23+
* createLoadingLayoutProxy(...)} calls.
24+
*
25+
* @param layout - LoadingLayout to have included.
26+
*/
27+
public void addLayout(LoadingLayout layout) {
1928
if (null != layout) {
2029
mLoadingLayouts.add(layout);
2130
}

library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public void setShowIndicator(boolean showIndicator) {
248248
;
249249

250250
@Override
251-
void onPullToRefresh() {
251+
protected void onPullToRefresh() {
252252
super.onPullToRefresh();
253253

254254
if (getShowIndicatorInternal()) {
@@ -266,7 +266,7 @@ void onPullToRefresh() {
266266
}
267267
}
268268

269-
void onRefreshing(boolean doScroll) {
269+
protected void onRefreshing(boolean doScroll) {
270270
super.onRefreshing(doScroll);
271271

272272
if (getShowIndicatorInternal()) {
@@ -275,7 +275,7 @@ void onRefreshing(boolean doScroll) {
275275
}
276276

277277
@Override
278-
void onReleaseToRefresh() {
278+
protected void onReleaseToRefresh() {
279279
super.onReleaseToRefresh();
280280

281281
if (getShowIndicatorInternal()) {
@@ -294,7 +294,7 @@ void onReleaseToRefresh() {
294294
}
295295

296296
@Override
297-
void onReset() {
297+
protected void onReset() {
298298
super.onReset();
299299

300300
if (getShowIndicatorInternal()) {

library/src/com/handmark/pulltorefresh/library/PullToRefreshBase.java

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -546,89 +546,6 @@ public final void setShowViewWhileRefreshing(boolean showView) {
546546
*/
547547
public abstract Orientation getPullToRefreshScrollDirection();
548548

549-
/**
550-
* Called when the UI has been to be updated to be in the
551-
* {@link State#PULL_TO_REFRESH} state.
552-
*/
553-
void onPullToRefresh() {
554-
switch (mCurrentMode) {
555-
case PULL_FROM_END:
556-
mFooterLayout.pullToRefresh();
557-
break;
558-
case PULL_FROM_START:
559-
mHeaderLayout.pullToRefresh();
560-
break;
561-
default:
562-
// NO-OP
563-
break;
564-
}
565-
}
566-
567-
/**
568-
* Called when the UI has been to be updated to be in the
569-
* {@link State#REFRESHING} or {@link State#MANUAL_REFRESHING} state.
570-
*
571-
* @param doScroll - Whether the UI should scroll for this event.
572-
*/
573-
void onRefreshing(final boolean doScroll) {
574-
if (mMode.showHeaderLoadingLayout()) {
575-
mHeaderLayout.refreshing();
576-
}
577-
if (mMode.showFooterLoadingLayout()) {
578-
mFooterLayout.refreshing();
579-
}
580-
581-
if (doScroll) {
582-
if (mShowViewWhileRefreshing) {
583-
switch (mCurrentMode) {
584-
case MANUAL_REFRESH_ONLY:
585-
case PULL_FROM_END:
586-
smoothScrollTo(getFooterSize());
587-
break;
588-
default:
589-
case PULL_FROM_START:
590-
smoothScrollTo(-getHeaderSize());
591-
break;
592-
}
593-
} else {
594-
smoothScrollTo(0);
595-
}
596-
}
597-
}
598-
599-
/**
600-
* Called when the UI has been to be updated to be in the
601-
* {@link State#RELEASE_TO_REFRESH} state.
602-
*/
603-
void onReleaseToRefresh() {
604-
switch (mCurrentMode) {
605-
case PULL_FROM_END:
606-
mFooterLayout.releaseToRefresh();
607-
break;
608-
case PULL_FROM_START:
609-
mHeaderLayout.releaseToRefresh();
610-
break;
611-
default:
612-
// NO-OP
613-
break;
614-
}
615-
}
616-
617-
/**
618-
* Called when the UI has been to be updated to be in the
619-
* {@link State#RESET} state.
620-
*/
621-
void onReset() {
622-
mIsBeingDragged = false;
623-
mLayoutVisibilityChangesEnabled = true;
624-
625-
// Always reset both layouts, just in case...
626-
mHeaderLayout.reset();
627-
mFooterLayout.reset();
628-
629-
smoothScrollTo(0);
630-
}
631-
632549
final void setState(State state, final boolean... params) {
633550
mState = state;
634551
if (DEBUG) {
@@ -759,21 +676,21 @@ protected void handleStyledAttributes(TypedArray a) {
759676

760677
/**
761678
* Implemented by derived class to return whether the View is in a state
762-
* where the user can Pull to Refresh by scrolling from the start.
679+
* where the user can Pull to Refresh by scrolling from the end.
763680
*
764-
* @return true if the View is currently the correct state (for example, top
765-
* of a ListView)
681+
* @return true if the View is currently in the correct state (for example,
682+
* bottom of a ListView)
766683
*/
767-
protected abstract boolean isReadyForPullStart();
684+
protected abstract boolean isReadyForPullEnd();
768685

769686
/**
770687
* Implemented by derived class to return whether the View is in a state
771-
* where the user can Pull to Refresh by scrolling from the end.
688+
* where the user can Pull to Refresh by scrolling from the start.
772689
*
773-
* @return true if the View is currently in the correct state (for example,
774-
* bottom of a ListView)
690+
* @return true if the View is currently the correct state (for example, top
691+
* of a ListView)
775692
*/
776-
protected abstract boolean isReadyForPullEnd();
693+
protected abstract boolean isReadyForPullStart();
777694

778695
/**
779696
* Called by {@link #onRestoreInstanceState(Parcelable)} so that derivative
@@ -793,6 +710,89 @@ protected void onPtrRestoreInstanceState(Bundle savedInstanceState) {
793710
protected void onPtrSaveInstanceState(Bundle saveState) {
794711
}
795712

713+
/**
714+
* Called when the UI has been to be updated to be in the
715+
* {@link State#PULL_TO_REFRESH} state.
716+
*/
717+
protected void onPullToRefresh() {
718+
switch (mCurrentMode) {
719+
case PULL_FROM_END:
720+
mFooterLayout.pullToRefresh();
721+
break;
722+
case PULL_FROM_START:
723+
mHeaderLayout.pullToRefresh();
724+
break;
725+
default:
726+
// NO-OP
727+
break;
728+
}
729+
}
730+
731+
/**
732+
* Called when the UI has been to be updated to be in the
733+
* {@link State#REFRESHING} or {@link State#MANUAL_REFRESHING} state.
734+
*
735+
* @param doScroll - Whether the UI should scroll for this event.
736+
*/
737+
protected void onRefreshing(final boolean doScroll) {
738+
if (mMode.showHeaderLoadingLayout()) {
739+
mHeaderLayout.refreshing();
740+
}
741+
if (mMode.showFooterLoadingLayout()) {
742+
mFooterLayout.refreshing();
743+
}
744+
745+
if (doScroll) {
746+
if (mShowViewWhileRefreshing) {
747+
switch (mCurrentMode) {
748+
case MANUAL_REFRESH_ONLY:
749+
case PULL_FROM_END:
750+
smoothScrollTo(getFooterSize());
751+
break;
752+
default:
753+
case PULL_FROM_START:
754+
smoothScrollTo(-getHeaderSize());
755+
break;
756+
}
757+
} else {
758+
smoothScrollTo(0);
759+
}
760+
}
761+
}
762+
763+
/**
764+
* Called when the UI has been to be updated to be in the
765+
* {@link State#RELEASE_TO_REFRESH} state.
766+
*/
767+
protected void onReleaseToRefresh() {
768+
switch (mCurrentMode) {
769+
case PULL_FROM_END:
770+
mFooterLayout.releaseToRefresh();
771+
break;
772+
case PULL_FROM_START:
773+
mHeaderLayout.releaseToRefresh();
774+
break;
775+
default:
776+
// NO-OP
777+
break;
778+
}
779+
}
780+
781+
/**
782+
* Called when the UI has been to be updated to be in the
783+
* {@link State#RESET} state.
784+
*/
785+
protected void onReset() {
786+
mIsBeingDragged = false;
787+
mLayoutVisibilityChangesEnabled = true;
788+
789+
// Always reset both layouts, just in case...
790+
mHeaderLayout.reset();
791+
mFooterLayout.reset();
792+
793+
smoothScrollTo(0);
794+
}
795+
796796
@Override
797797
protected final void onRestoreInstanceState(Parcelable state) {
798798
if (state instanceof Bundle) {
@@ -1383,14 +1383,14 @@ boolean permitsPullToRefresh() {
13831383
/**
13841384
* @return true if this mode wants the Loading Layout Header to be shown
13851385
*/
1386-
boolean showHeaderLoadingLayout() {
1386+
public boolean showHeaderLoadingLayout() {
13871387
return this == PULL_FROM_START || this == BOTH;
13881388
}
13891389

13901390
/**
13911391
* @return true if this mode wants the Loading Layout Footer to be shown
13921392
*/
1393-
boolean showFooterLoadingLayout() {
1393+
public boolean showFooterLoadingLayout() {
13941394
return this == PULL_FROM_END || this == BOTH || this == MANUAL_REFRESH_ONLY;
13951395
}
13961396

library/src/com/handmark/pulltorefresh/library/PullToRefreshListView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public final Orientation getPullToRefreshScrollDirection() {
6363
}
6464

6565
@Override
66-
void onRefreshing(final boolean doScroll) {
66+
protected void onRefreshing(final boolean doScroll) {
6767
/**
6868
* If we're not showing the Refreshing view, or the list is empty, the
6969
* the header/footer views won't show so we use the normal method.
@@ -127,7 +127,7 @@ void onRefreshing(final boolean doScroll) {
127127
}
128128

129129
@Override
130-
void onReset() {
130+
protected void onReset() {
131131
/**
132132
* If the extras are not enabled, just call up to super and return.
133133
*/

0 commit comments

Comments
 (0)