Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011, 2012 Chris Banes. Copyright 2013 Naver Business Platform Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package com.handmark.pulltorefresh.library;
 
 
 
 
 	public PullToRefreshScrollView(Context context) {
 		super(context);
 	}
 
 	public PullToRefreshScrollView(Context contextAttributeSet attrs) {
 		super(contextattrs);
 	}
 
 	public PullToRefreshScrollView(Context contextMode mode) {
 		super(contextmode);
 	}
 
 	public PullToRefreshScrollView(Context contextMode modeClass<? extends LoadingLayoutloadingLayoutClazz) {
 		super(contextmodeloadingLayoutClazz);
 	}
 
 	}
 
 	protected ScrollView createRefreshableView(Context contextAttributeSet attrs) {
 		ScrollView scrollView;
 			scrollView = new InternalScrollViewSDK9(contextattrs);
 		} else {
 			scrollView = new ScrollView(contextattrs);
 		}
 
 		scrollView.setId(..);
 		return scrollView;
 	}
 
 	protected boolean isReadyForPullStart() {
 		return .getScrollY() == 0;
 	}
 
 	protected boolean isReadyForPullEnd() {
 		View scrollViewChild = .getChildAt(0);
 		if (null != scrollViewChild) {
 			return .getScrollY() >= (scrollViewChild.getHeight() - getHeight());
 		}
 		return false;
 	}
 
 	final class InternalScrollViewSDK9 extends ScrollView {
 
 		public InternalScrollViewSDK9(Context contextAttributeSet attrs) {
 			super(contextattrs);
 		}
 
 		protected boolean overScrollBy(int deltaXint deltaYint scrollXint scrollYint scrollRangeX,
 				int scrollRangeYint maxOverScrollXint maxOverScrollYboolean isTouchEvent) {
 
 			final boolean returnValue = super.overScrollBy(deltaXdeltaYscrollXscrollYscrollRangeX,
 					scrollRangeYmaxOverScrollXmaxOverScrollYisTouchEvent);
 
 			// Does all of the hard work...
 			OverscrollHelper.overScrollBy(PullToRefreshScrollView.thisdeltaXscrollXdeltaYscrollY,
 					getScrollRange(), isTouchEvent);
 
 			return returnValue;
 		}

Taken from the AOSP ScrollView source
		private int getScrollRange() {
			int scrollRange = 0;
			if (getChildCount() > 0) {
				View child = getChildAt(0);
				scrollRange = Math.max(0, child.getHeight() - (getHeight() - getPaddingBottom() - getPaddingTop()));
			}
			return scrollRange;
		}
	}