package com.handmark.pulltorefresh.library;

import android.annotation.TargetApi;
import android.view.View;

import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;

@TargetApi(9)
final class OverscrollHelper {

	static void overScrollBy(PullToRefreshBase<?> view, int deltaY, int scrollY, boolean isTouchEvent) {

		// Check that OverScroll is enabled
		if (view.isPullToRefreshOverScrollEnabled()) {
			final Mode mode = view.getMode();

			// Check that we're not disabled, and the event isn't from touch
			if (mode != Mode.DISABLED && !isTouchEvent) {
				final int newY = (deltaY + scrollY);

				if (newY != 0) {
					// Check the mode supports the overscroll direction, and
					// then move scroll
					if ((mode.canPullDown() && newY < 0) || (mode.canPullUp() && newY > 0)) {
						view.setHeaderScroll(view.getScrollY() + newY);
					}
				} else {
					// Means we've stopped overscrolling, so scroll back to 0
					view.smoothScrollTo(0, PullToRefreshBase.SMOOTH_SCROLL_LONG_DURATION_MS);
				}
			}
		}
	}
	
	static boolean isAndroidOverScrollEnabled(View view) {
		return view.getOverScrollMode() != View.OVER_SCROLL_NEVER;
	}
}

@@ -75,16 +75,41 @@
 getApi;%0A
+import android.util.Log;%0A
 import a
@@ -238,16 +238,69 @@
 Helper %7B
+%0A%09%0A%09static final String LOG_TAG = %22OverscrollHelper%22;
 %0A%0A%09stati
@@ -678,16 +678,141 @@
 crollY);
+%0A%09%09%09%09%0A%09%09%09%09if (PullToRefreshBase.DEBUG) %7B%0A%09%09%09%09%09Log.d(LOG_TAG, %22OverScroll. DeltaY: %22 + deltaY + %22 ScrollY: %22 + scrollY);%0A%09%09%09%09%7D
 %0A%0A%09%09%09%09if

Add Debug to OverScrollHelper