3434import android .widget .FrameLayout ;
3535import android .widget .LinearLayout ;
3636
37- import com .handmark .pulltorefresh .library .internal .CallbackFrameLayout .OnSizeChangedListener ;
3837import com .handmark .pulltorefresh .library .internal .FlipLoadingLayout ;
3938import com .handmark .pulltorefresh .library .internal .LoadingLayout ;
4039import com .handmark .pulltorefresh .library .internal .RotateLoadingLayout ;
@@ -92,9 +91,6 @@ public abstract class PullToRefreshBase<T extends View> extends LinearLayout imp
9291 private LoadingLayout mHeaderLayout ;
9392 private LoadingLayout mFooterLayout ;
9493
95- private int mHeaderDimension ;
96- private int mFooterDimension ;
97-
9894 private OnRefreshListener <T > mOnRefreshListener ;
9995 private OnRefreshListener2 <T > mOnRefreshListener2 ;
10096 private OnPullEventListener <T > mOnPullEventListener ;
@@ -146,10 +142,10 @@ public void addView(View child, int index, ViewGroup.LayoutParams params) {
146142 @ Override
147143 public final boolean demo () {
148144 if (mMode .showHeaderLoadingLayout () && isReadyForPullStart ()) {
149- smoothScrollToAndBack (-mHeaderDimension * 2 );
145+ smoothScrollToAndBack (-getHeaderSize () * 2 );
150146 return true ;
151147 } else if (mMode .showFooterLoadingLayout () && isReadyForPullEnd ()) {
152- smoothScrollToAndBack (mFooterDimension * 2 );
148+ smoothScrollToAndBack (getFooterSize () * 2 );
153149 return true ;
154150 }
155151
@@ -587,11 +583,11 @@ void onRefreshing(final boolean doScroll) {
587583 switch (mCurrentMode ) {
588584 case MANUAL_REFRESH_ONLY :
589585 case PULL_FROM_END :
590- smoothScrollTo (mFooterDimension );
586+ smoothScrollTo (getFooterSize () );
591587 break ;
592588 default :
593589 case PULL_FROM_START :
594- smoothScrollTo (-mHeaderDimension );
590+ smoothScrollTo (-getHeaderSize () );
595591 break ;
596592 }
597593 } else {
@@ -724,22 +720,22 @@ protected final void disableLoadingLayoutVisibilityChanges() {
724720 mLayoutVisibilityChangesEnabled = false ;
725721 }
726722
727- protected final int getFooterHeight () {
728- return mFooterDimension ;
729- }
730-
731723 protected final LoadingLayout getFooterLayout () {
732724 return mFooterLayout ;
733725 }
734726
735- protected final int getHeaderHeight () {
736- return mHeaderDimension ;
727+ protected final int getFooterSize () {
728+ return mFooterLayout . getContentSize () ;
737729 }
738730
739731 protected final LoadingLayout getHeaderLayout () {
740732 return mHeaderLayout ;
741733 }
742734
735+ protected final int getHeaderSize () {
736+ return mHeaderLayout .getContentSize ();
737+ }
738+
743739 protected int getPullToRefreshScrollDuration () {
744740 return SMOOTH_SCROLL_DURATION_MS ;
745741 }
@@ -860,8 +856,6 @@ protected final void onSizeChanged(int w, int h, int oldw, int oldh) {
860856 protected final void refreshLoadingViewsSize () {
861857 final int maximumPullScroll = (int ) (getMaximumPullScroll () * 1.2f );
862858
863- mHeaderDimension = mFooterDimension = 0 ;
864-
865859 int pLeft = getPaddingLeft ();
866860 int pTop = getPaddingTop ();
867861 int pRight = getPaddingRight ();
@@ -870,15 +864,13 @@ protected final void refreshLoadingViewsSize() {
870864 switch (getPullToRefreshScrollDirection ()) {
871865 case HORIZONTAL :
872866 if (mMode .showHeaderLoadingLayout ()) {
873- mHeaderDimension = mHeaderLayout .getContentWidth ();
874867 mHeaderLayout .setWidth (maximumPullScroll );
875868 pLeft = -maximumPullScroll ;
876869 } else {
877870 pLeft = 0 ;
878871 }
879872
880873 if (mMode .showFooterLoadingLayout ()) {
881- mFooterDimension = mFooterLayout .getContentWidth ();
882874 mFooterLayout .setWidth (maximumPullScroll );
883875 pRight = -maximumPullScroll ;
884876 } else {
@@ -888,15 +880,13 @@ protected final void refreshLoadingViewsSize() {
888880
889881 case VERTICAL :
890882 if (mMode .showHeaderLoadingLayout ()) {
891- mHeaderDimension = mHeaderLayout .getContentHeight ();
892883 mHeaderLayout .setHeight (maximumPullScroll );
893884 pTop = -maximumPullScroll ;
894885 } else {
895886 pTop = 0 ;
896887 }
897888
898889 if (mMode .showFooterLoadingLayout ()) {
899- mFooterDimension = mFooterLayout .getContentHeight ();
900890 mFooterLayout .setHeight (maximumPullScroll );
901891 pBottom = -maximumPullScroll ;
902892 } else {
@@ -1075,11 +1065,6 @@ private void init(Context context, AttributeSet attrs) {
10751065 mHeaderLayout = createLoadingLayout (context , Mode .PULL_FROM_START , a );
10761066 mFooterLayout = createLoadingLayout (context , Mode .PULL_FROM_END , a );
10771067
1078- // LoadingLayout.OnSizeChangedListener listener = new
1079- // OnLoadingLayoutSizeChangedListener();
1080- // mHeaderLayout.setOnSizeChangedListener(listener);
1081- // mFooterLayout.setOnSizeChangedListener(listener);
1082-
10831068 /**
10841069 * Styleables from XML
10851070 */
@@ -1153,12 +1138,12 @@ private void pullEvent() {
11531138 switch (mCurrentMode ) {
11541139 case PULL_FROM_END :
11551140 newScrollValue = Math .round (Math .max (initialMotionValue - lastMotionValue , 0 ) / FRICTION );
1156- itemDimension = mFooterDimension ;
1141+ itemDimension = getFooterSize () ;
11571142 break ;
11581143 case PULL_FROM_START :
11591144 default :
11601145 newScrollValue = Math .round (Math .min (initialMotionValue - lastMotionValue , 0 ) / FRICTION );
1161- itemDimension = mHeaderDimension ;
1146+ itemDimension = getHeaderSize () ;
11621147 break ;
11631148 }
11641149
@@ -1424,28 +1409,6 @@ public static interface OnLastItemVisibleListener {
14241409
14251410 }
14261411
1427- final class OnLoadingLayoutSizeChangedListener implements OnSizeChangedListener {
1428-
1429- @ Override
1430- public void onSizeChanged (View view , int newWidth , int newHeight ) {
1431- if (DEBUG ) {
1432- String viewString = view == mHeaderLayout ? "Header" : "Footer" ;
1433- Log .d (LOG_TAG , "onSizeChanged. " + viewString + ": " + newWidth + " x " + newHeight );
1434- }
1435-
1436- /**
1437- * We're currently in a layout pass, so we need to post so it gets
1438- * called after the pass has finished.
1439- */
1440- post (new Runnable () {
1441- @ Override
1442- public void run () {
1443- refreshLoadingViewsSize ();
1444- }
1445- });
1446- }
1447- }
1448-
14491412 /**
14501413 * Listener that allows you to be notified when the user has started or
14511414 * finished a touch event. Useful when you want to append extra UI events
0 commit comments