package cbgm.de.listapi.data;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;

/**
 * Custom ListView to block scrolling action
 * @author Christian Bergmann
 */

public class CBListView extends ListView {
    private int mPosition;
    private boolean shouldBlockScroll = false;

    public CBListView(Context context) {
        super(context);
    }

    public CBListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CBListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        final int actionMasked = ev.getActionMasked() & MotionEvent.ACTION_MASK;

        if (actionMasked == MotionEvent.ACTION_DOWN) {
            mPosition = pointToPosition((int) ev.getX(), (int) ev.getY());
            return super.dispatchTouchEvent(ev);
        }

        if (actionMasked == MotionEvent.ACTION_MOVE) {
            return this.shouldBlockScroll || super.dispatchTouchEvent(ev);
        }

        if (actionMasked == MotionEvent.ACTION_UP) {

            if (pointToPosition((int) ev.getX(), (int) ev.getY()) == mPosition) {
                super.dispatchTouchEvent(ev);
            } else {
                setPressed(false);
                invalidate();
                return true;
            }
        }

        return super.dispatchTouchEvent(ev);
    }

    /**
     * Set true to block scrolling
     * @param shouldBlockScroll true blocks
     */
    public void setShouldScroll(final boolean shouldBlockScroll) {
        this.shouldBlockScroll = shouldBlockScroll;
    }
}

@@ -287,35 +287,8 @@
 w %7B%0A
-    private int mPosition;%0A
     
@@ -719,22 +719,16 @@
 t action
-Masked
  = ev.ge
@@ -793,642 +793,123 @@
 tion
-Masked == MotionEvent.ACTION_DOWN) %7B%0A            mPosition = pointToPosition((int) ev.getX(), (int) ev.getY());%0A            return super.dispatchTouchEvent(ev);%0A        %7D%0A%0A        if (actionMasked == MotionEvent.ACTION_MOVE) %7B%0A            return this.shouldBlockScroll %7C%7C super.dispatchTouchEvent(ev);%0A        %7D%0A%0A        if (actionMasked == MotionEvent.ACTION_UP) %7B%0A%0A            if (pointToPosition((int) ev.getX(), (int) ev.getY()) == mPosition) %7B%0A                super.dispatchTouchEvent(ev);%0A            %7D else %7B%0A                setPressed(false);%0A                invalidate();%0A                return true;%0A            %7D%0A        %7D%0A
+ == MotionEvent.ACTION_MOVE) %7B%0A            return this.shouldBlockScroll %7C%7C super.dispatchTouchEvent(ev);%0A        %7D
 %0A   

Update listview