@@ -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
0 commit comments