@@ -0,0 +1,2458 @@
+/*%0A * Copyright 2014 Kevin Quan (kevin.quan@gmail.com)%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.kevinquan.android.ui;%0A%0Aimport android.view.MotionEvent;%0Aimport android.view.View;%0Aimport android.view.View.OnTouchListener;%0A%0A/**%0A * This listener can help programatically prevent scroll when desired.  For example, it may be undesirable to allow scrolling when animating a ListView.%0A * %0A * If used with a ListView, it is useful to also disable OnItemClickListener when scroll is disabled, as an attempt to scroll could be registered as%0A * a click.%0A * %0A * @author Kevin Quan (kevin.quan@gmail.com)%0A *%0A */%0Apublic class DisableScrollOnTouchListener implements OnTouchListener %7B%0A%0A    @SuppressWarnings(%22unused%22)%0A    private static final String TAG = DisableScrollOnTouchListener.class.getSimpleName();%0A    %0A    protected boolean mIsDisableScroll;%0A    protected OnTouchListener mOnTouchListener;%0A    %0A    public DisableScrollOnTouchListener() %7B%0A        mIsDisableScroll = true;%0A    %7D%0A    %0A    public DisableScrollOnTouchListener(OnTouchListener actualOnTouchListener) %7B%0A        mIsDisableScroll = true;%0A        mOnTouchListener = actualOnTouchListener;%0A    %7D%0A%0A    @Override%0A    public boolean onTouch(View v, MotionEvent event) %7B%0A        if (!mIsDisableScroll && mOnTouchListener != null) %7B%0A            return mOnTouchListener.onTouch(v, event);%0A        %7D else if (mIsDisableScroll && event.getAction() == MotionEvent.ACTION_MOVE) %7B%0A            // Consume scroll event%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A%0A    public DisableScrollOnTouchListener setConsumeScroll(boolean consumeScroll) %7B%0A        mIsDisableScroll = consumeScroll;%0A        return this;%0A    %7D%0A%0A    public DisableScrollOnTouchListener setOnTouchListener(OnTouchListener onTouchListener) %7B%0A        mOnTouchListener = onTouchListener;%0A        return this;%0A    %7D%0A%0A    public boolean isDisablingScroll() %7B%0A        return mIsDisableScroll;%0A    %7D%0A%0A%7D%0A

Add helper to disable scrolling