@@ -0,0 +1,3078 @@
+import android.content.Context;%0Aimport android.support.v4.widget.NestedScrollView;%0Aimport android.util.AttributeSet;%0Aimport android.view.MotionEvent;%0Aimport android.view.View;%0A%0A/**%0A * Created by shinechen on 10/13/15.%0A */%0Apublic class LockableNestedScrollView extends NestedScrollView %7B%0A    private static final String TAG = %22LockableNestedSV%22;%0A%0A    public interface ScrollViewListener %7B%0A        void onScrollChanged(NestedScrollView scrollView, int x, int y, int oldx, int oldy);%0A    %7D%0A%0A    /// Whether the scroll view is scrollable.%0A    private boolean mScrollable = true;%0A    /// Whether the scroll view have higher priority to consume scrolling before its decedents.%0A    private boolean mScrollBeforeDecedents = true;%0A    private ScrollViewListener mScrollViewListener = null;%0A%0A    public LockableNestedScrollView(Context context) %7B%0A        super(context);%0A    %7D%0A%0A    public LockableNestedScrollView(Context context, AttributeSet attrs) %7B%0A        super(context, attrs);%0A    %7D%0A%0A    public LockableNestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) %7B%0A        super(context, attrs, defStyleAttr);%0A    %7D%0A%0A    @Override%0A    public boolean onTouchEvent(MotionEvent ev) %7B%0A        switch (ev.getAction()) %7B%0A            case MotionEvent.ACTION_DOWN:%0A                // Pass touch event to super if scrollable%0A                if (mScrollable) %7B%0A                    return super.onTouchEvent(ev);%0A                %7D%0A%0A                return false;%0A            default:%0A                return super.onTouchEvent(ev);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean onInterceptTouchEvent(MotionEvent ev) %7B%0A        // Do nothing with intercepted touch events if not scrollable%0A        if (!mScrollable) %7B%0A            return false;%0A        %7D%0A        return super.onInterceptTouchEvent(ev);%0A    %7D%0A%0A    public void setScrollable(boolean scrollable) %7B%0A        mScrollable = scrollable;%0A    %7D%0A%0A    public boolean isScrollable() %7B%0A        return mScrollable;%0A    %7D%0A%0A    public boolean isScrollBeforeDecedents() %7B%0A        return mScrollBeforeDecedents;%0A    %7D%0A%0A    public void setScrollBeforeDecedents(boolean scrollBeforeDecedents) %7B%0A        this.mScrollBeforeDecedents = scrollBeforeDecedents;%0A    %7D%0A%0A    @Override%0A    public void onScrollChanged(int x, int y, int oldx, int oldy) %7B%0A        super.onScrollChanged(x, y, oldx, oldy);%0A        if (mScrollViewListener != null) %7B%0A            mScrollViewListener.onScrollChanged(this, x, y, oldx, oldy);%0A        %7D%0A    %7D%0A%0A    public void setScrollViewListener(ScrollViewListener listener) %7B%0A        mScrollViewListener = listener;%0A    %7D%0A%0A    @Override%0A    public void onNestedPreScroll(View target, int dx, int dy, int%5B%5D consumed) %7B%0A%0A        if (!mScrollBeforeDecedents) %7B%0A            // Do nothing, default behavior.%0A            return;%0A        %7D%0A%0A        // Scroll the parent scroll view prior to the inner one%0A        int totalHeight = getChildAt(0).getHeight();%0A        if (getScrollY() + getHeight() %3C totalHeight) %7B%0A            scrollBy(dx, dy);%0A            consumed%5B0%5D = dx;%0A            consumed%5B1%5D = dy;%0A        %7D%0A    %7D%0A%7D%0A

Add Lockable NestedScrollView