/*
 * Copyright (C) 2015-2016 QuickAF
 *
 * 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 cn.ieclipse.af.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * listening ScrollView vertical scroll instances
 *
 * @author wangjian
 * @date 2016-08-13
 */
public class VScrollView extends ScrollView {

    public VScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public VScrollView(Context context, AttributeSet attrs, int defStyleAttr) {

        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (mOnScrollChangeListener != null) {
            mOnScrollChangeListener.onVScrollChanged(l, t, oldl, oldt);
        }
    }

    private OnScrollChangeListener mOnScrollChangeListener;

    public void setOnScrollChangeListener(OnScrollChangeListener onScrollChangeListener) {
        this.mOnScrollChangeListener = onScrollChangeListener;
    }

    public interface OnScrollChangeListener {
        /**
         * This is called in response to an internal scroll in this view (i.e., the
         * view scrolled its own contents). This is typically as a result of
         * {@link #scrollBy(int, int)} or {@link #scrollTo(int, int)} having been
         * called.
         *
         * @param l Current horizontal scroll origin.
         * @param t Current vertical scroll origin.
         * @param oldl Previous horizontal scroll origin.
         * @param oldt Previous vertical scroll origin.
         */
        void onVScrollChanged(int l, int t, int oldl, int oldt);
    }
}

@@ -678,25 +678,76 @@
 oid.
-util.AttributeSet
+os.Build;%0Aimport android.util.AttributeSet;%0Aimport android.view.View
 ;%0Aim
@@ -1109,17 +1109,16 @@
 Attr) %7B%0A
-%0A
         
@@ -1287,32 +1287,78 @@
 t, oldl, oldt);%0A
+        if (Build.VERSION.SDK_INT %3C 23) %7B%0A    
         if (mOnS
@@ -1400,16 +1400,20 @@
         
+    
 mOnScrol
@@ -1430,17 +1430,16 @@
 tener.on
-V
 ScrollCh
@@ -1434,34 +1434,39 @@
 r.onScrollChange
-d
 (
+this, 
 l, t, oldl, oldt
@@ -1480,539 +1480,1284 @@
     
-%7D%0A    %7D%0A%0A    private OnScrollChangeListener mOnScrollChangeListener;%0A%0A    public void setOnScrollChangeListener(OnScrollChangeListener onScrollChangeListener) %7B%0A        this.mOnScrollChangeListener = onScrollChangeListener;%0A    %7D%0A%0A    public interface OnScrollChangeListener %7B%0A        /**%0A         * This is called in response to an internal scroll in this view (i.e., the%0A         * view scrolled its own contents). This is typically as a result of
+    %7D%0A        %7D%0A    %7D%0A%0A    public boolean isScroll2Bottom() %7B%0A        View view = getChildAt(0);%0A        if (view.getBottom() - (getScrollY() + getHeight()) == 0) %7B%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A%0A    public boolean isScroll2Top() %7B%0A        return getScrollY() == 0;%0A    %7D%0A%0A    private OnScrollChangeListener mOnScrollChangeListener;%0A%0A    public void setOnScrollChangeListener(OnScrollChangeListener onScrollChangeListener) %7B%0A        this.mOnScrollChangeListener = onScrollChangeListener;%0A    %7D%0A%0A    /**%0A     * Interface definition for a callback to be invoked when the scroll%0A     * X or Y positions of a view change.%0A     * %3Cb%3ENote:%3C/b%3E Some views handle scrolling independently from View and may%0A     * have their own separate listeners for scroll-type events. For example,%0A     * %7B@link android.widget.ListView ListView%7D allows clients to register an%0A     * %7B@link android.widget.ListView#setOnScrollListener(android.widget.AbsListView.OnScrollListener) AbsListView.OnScrollListener%7D%0A     * to listen for changes in list scroll position.
 %0A    
+ *%0A
      * 
-%7B@link #scrollBy(int, int)%7D or %7B@link #scrollTo(int, int)%7D having been
+@see #setOnScrollChangeListener(View.OnScrollChangeListener)%0A     */%0A    public interface OnScrollChangeListener %7B%0A        /**%0A         * Called when the scroll position of a view changes.
 %0A   
@@ -2767,16 +2767,8 @@
    *
- called.
 %0A   
@@ -2766,32 +2766,85 @@
     *%0A         *
+ @param v The view whose scroll position has changed.
 %0A         * @par
@@ -2846,17 +2846,23 @@
  @param 
-l
+scrollX
  Current
@@ -2906,17 +2906,23 @@
  @param 
-t
+scrollY
  Current
@@ -2967,17 +2967,23 @@
 aram old
-l
+ScrollX
  Previou
@@ -3031,17 +3031,23 @@
 aram old
-t
+ScrollY
  Previou
@@ -3099,17 +3099,16 @@
  void on
-V
 ScrollCh
@@ -3107,38 +3107,57 @@
 ScrollChange
-d(int l, int t
+(View v, int scrollX, int scrollY
 , int oldl, 
@@ -3145,33 +3145,39 @@
 scrollY, int old
-l
+ScrollX
 , int oldt);%0A   
@@ -3165,24 +3165,30 @@
 llX, int old
-t
+ScrollY
 );%0A    %7D%0A%7D%0A

change vscrollview