Example usage for android.view ViewGroup onTouchEvent

List of usage examples for android.view ViewGroup onTouchEvent

Introduction

In this page you can find the example usage for android.view ViewGroup onTouchEvent.

Prototype

public boolean onTouchEvent(MotionEvent event) 

Source Link

Document

Implement this method to handle touch screen motion events.

Usage

From source file:com.parrot.cyclops.CameraView.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    logdebug("onTouchEvent");
    ViewParent parent = this.getParent();
    if (parent != null) {
        ViewGroup vg = (ViewGroup) parent;
        return vg.onTouchEvent(ev);
    }//from w  ww  .  jav  a 2  s .  c om
    return super.onTouchEvent(ev);
}

From source file:com.grottworkshop.gwsswipelayout.SwipeLayout.java

/**
 * if the ViewGroup children want to handle this event.
 * @param v the v/*from   w w w. j  av a  2  s .  co m*/
 * @param event the event
 * @return v
 */
private View childNeedHandleTouchEvent(ViewGroup v, MotionEvent event) {
    if (v == null)
        return null;
    if (v.onTouchEvent(event))
        return v;

    int childCount = v.getChildCount();
    for (int i = childCount - 1; i >= 0; i--) {
        View child = v.getChildAt(i);
        if (child instanceof ViewGroup) {
            View grandChild = childNeedHandleTouchEvent((ViewGroup) child, event);
            if (grandChild != null)
                return grandChild;
        } else {
            if (childNeedHandleTouchEvent(v.getChildAt(i), event))
                return v.getChildAt(i);
        }
    }
    return null;
}