Search in sources :

Example 51 with ViewParent

use of android.view.ViewParent in project yield-layout by evant.

the class YieldLayout method inflate.

private void inflate() {
    ViewParent viewParent = null;
    View currentView = this;
    if (mLayoutView != null) {
        currentView = mLayoutView;
        viewParent = mLayoutView.getParent();
    }
    if (viewParent == null) {
        viewParent = getParent();
    }
    if (viewParent == null) {
        return;
    }
    if (!(viewParent instanceof ViewGroup)) {
        throw new IllegalStateException("YieldLayout must have a non-null ViewGroup viewParent (Instead parent was: '" + viewParent + "')");
    }
    ViewGroup parent = (ViewGroup) viewParent;
    inflate(currentView, parent, true);
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 52 with ViewParent

use of android.view.ViewParent in project UltimateAndroid by cymcsg.

the class SwipeLayout method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabledInAdapterView() || !isEnabled())
        return true;
    if (!isSwipeEnabled())
        return super.onTouchEvent(event);
    int action = event.getActionMasked();
    ViewParent parent = getParent();
    gestureDetector.onTouchEvent(event);
    Status status = getOpenStatus();
    ViewGroup touching = null;
    if (status == Status.Close) {
        touching = getSurfaceView();
    } else if (status == Status.Open) {
        touching = getBottomView();
    }
    switch(action) {
        case MotionEvent.ACTION_DOWN:
            mDragHelper.processTouchEvent(event);
            parent.requestDisallowInterceptTouchEvent(true);
            sX = event.getRawX();
            sY = event.getRawY();
            if (touching != null)
                touching.setPressed(true);
            return true;
        case MotionEvent.ACTION_MOVE:
            {
                if (sX == -1 || sY == -1) {
                    // Trick:
                    // When in nested mode, we need to send a constructed ACTION_DOWN MotionEvent to mDragHelper, to help
                    // it initialize itself.
                    event.setAction(MotionEvent.ACTION_DOWN);
                    mDragHelper.processTouchEvent(event);
                    parent.requestDisallowInterceptTouchEvent(true);
                    sX = event.getRawX();
                    sY = event.getRawY();
                    return true;
                }
                float distanceX = event.getRawX() - sX;
                float distanceY = event.getRawY() - sY;
                float angle = Math.abs(distanceY / distanceX);
                angle = (float) Math.toDegrees(Math.atan(angle));
                boolean doNothing = false;
                if (mDragEdge == DragEdge.Right) {
                    boolean suitable = (status == Status.Open && distanceX > 0) || (status == Status.Close && distanceX < 0);
                    suitable = suitable || (status == Status.Middle);
                    if (angle > 30 || !suitable) {
                        doNothing = true;
                    }
                }
                if (mDragEdge == DragEdge.Left) {
                    boolean suitable = (status == Status.Open && distanceX < 0) || (status == Status.Close && distanceX > 0);
                    suitable = suitable || status == Status.Middle;
                    if (angle > 30 || !suitable) {
                        doNothing = true;
                    }
                }
                if (mDragEdge == DragEdge.Top) {
                    boolean suitable = (status == Status.Open && distanceY < 0) || (status == Status.Close && distanceY > 0);
                    suitable = suitable || status == Status.Middle;
                    if (angle < 60 || !suitable) {
                        doNothing = true;
                    }
                }
                if (mDragEdge == DragEdge.Bottom) {
                    boolean suitable = (status == Status.Open && distanceY > 0) || (status == Status.Close && distanceY < 0);
                    suitable = suitable || status == Status.Middle;
                    if (angle < 60 || !suitable) {
                        doNothing = true;
                    }
                }
                if (doNothing) {
                    parent.requestDisallowInterceptTouchEvent(false);
                    return false;
                } else {
                    if (touching != null) {
                        touching.setPressed(false);
                    }
                    parent.requestDisallowInterceptTouchEvent(true);
                    mDragHelper.processTouchEvent(event);
                }
                break;
            }
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            {
                sX = -1;
                sY = -1;
                if (touching != null) {
                    touching.setPressed(false);
                }
            }
        default:
            parent.requestDisallowInterceptTouchEvent(true);
            mDragHelper.processTouchEvent(event);
    }
    return true;
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 53 with ViewParent

use of android.view.ViewParent in project cw-omnibus by commonsguy.

the class IcsListPopupWindow method dismiss.

public void dismiss() {
    mPopup.dismiss();
    if (mPromptView != null) {
        final ViewParent parent = mPromptView.getParent();
        if (parent instanceof ViewGroup) {
            final ViewGroup group = (ViewGroup) parent;
            group.removeView(mPromptView);
        }
    }
    mPopup.setContentView(null);
    mDropDownList = null;
    mHandler.removeCallbacks(mResizePopupRunnable);
}
Also used : ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup)

Example 54 with ViewParent

use of android.view.ViewParent in project Launcher3 by chislon.

the class PagedView method focusableViewAvailable.

/**
     * If one of our descendant views decides that it could be focused now, only
     * pass that along if it's on the current page.
     *
     * This happens when live folders requery, and if they're off page, they
     * end up calling requestFocus, which pulls it on page.
     */
@Override
public void focusableViewAvailable(View focused) {
    View current = getPageAt(mCurrentPage);
    View v = focused;
    while (true) {
        if (v == current) {
            super.focusableViewAvailable(focused);
            return;
        }
        if (v == this) {
            return;
        }
        ViewParent parent = v.getParent();
        if (parent instanceof View) {
            v = (View) v.getParent();
        } else {
            return;
        }
    }
}
Also used : ViewParent(android.view.ViewParent) View(android.view.View)

Example 55 with ViewParent

use of android.view.ViewParent in project Launcher3 by chislon.

the class PagedView method getPageForView.

public int getPageForView(View v) {
    int result = -1;
    if (v != null) {
        ViewParent vp = v.getParent();
        int count = getChildCount();
        for (int i = 0; i < count; i++) {
            if (vp == getPageAt(i)) {
                return i;
            }
        }
    }
    return result;
}
Also used : ViewParent(android.view.ViewParent)

Aggregations

ViewParent (android.view.ViewParent)409 ViewGroup (android.view.ViewGroup)185 View (android.view.View)156 ImageView (android.widget.ImageView)36 Rect (android.graphics.Rect)32 VelocityTracker (android.view.VelocityTracker)32 TextView (android.widget.TextView)24 FrameLayout (android.widget.FrameLayout)17 SuppressLint (android.annotation.SuppressLint)16 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)14 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)13 ViewTreeObserver (android.view.ViewTreeObserver)12 LayoutParams (android.view.WindowManager.LayoutParams)11 Description (org.hamcrest.Description)11 ExpandableNotificationRow (com.android.systemui.statusbar.ExpandableNotificationRow)10 SignalClusterView (com.android.systemui.statusbar.SignalClusterView)10 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)10 MotionEvent (android.view.MotionEvent)9 EditText (android.widget.EditText)9