当前位置: 首页>>代码示例>>Java>>正文


Java Rect.contains方法代码示例

本文整理汇总了Java中android.graphics.Rect.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.contains方法的具体用法?Java Rect.contains怎么用?Java Rect.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Rect的用法示例。


在下文中一共展示了Rect.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findClickableViewInChild

import android.graphics.Rect; //导入方法依赖的package包/类
private boolean findClickableViewInChild(View view, int x, int y) {
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            final Rect rect = new Rect();
            child.getHitRect(rect);

            final boolean contains = rect.contains(x, y);
            if (contains) {
                return findClickableViewInChild(child, x - rect.left, y - rect.top);
            }
        }
    } else if (view != childView) {
        return (view.isEnabled() && (view.isClickable() || view.isLongClickable() || view.isFocusableInTouchMode()));
    }

    return view.isFocusableInTouchMode();
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:20,代码来源:MaterialRippleLayout.java

示例2: dispatchTouchEvent

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        View v = getCurrentFocus();
        if ( v instanceof EditText) {
            Rect outRect = new Rect();
            v.getGlobalVisibleRect(outRect);
            if (!outRect.contains((int)event.getRawX(), (int)event.getRawY())) {
                v.clearFocus();
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }
    }
    return super.dispatchTouchEvent( event );
}
 
开发者ID:Pritom14,项目名称:Password-Storage,代码行数:17,代码来源:RegistrationActivity.java

示例3: findAccessibilityNodeInfosByBounds

import android.graphics.Rect; //导入方法依赖的package包/类
private void findAccessibilityNodeInfosByBounds(UiObject root, List<UiObject> list) {
    if (root == null)
        return;
    Rect rect = new Rect();
    root.getBoundsInScreen(rect);
    if (rect.equals(mBoundsInScreen)) {
        list.add(root);
    }
    int oldSize = list.size();
    for (int i = 0; i < root.getChildCount(); i++) {
        UiObject child = root.child(i);
        if (child == null)
            continue;
        findAccessibilityNodeInfosByBounds(child, list);
    }
    if (oldSize == list.size() && rect.contains(mBoundsInScreen)) {
        list.add(root);
    }
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:20,代码来源:FilterAction.java

示例4: myPointToPosition

import android.graphics.Rect; //导入方法依赖的package包/类
private int myPointToPosition(int x, int y) {

        if (y < 0) {
            // when dragging off the top of the screen, calculate position
            // by going back from a visible item
            int pos = myPointToPosition(x, y + mItemHeightNormal);
            if (pos > 0) {
                return pos - 1;
            }
        }

        Rect frame = mTempRect;
        final int count = getChildCount();
        for (int i = count - 1; i >= 0; i--) {
            final View child = getChildAt(i);
            child.getHitRect(frame);
            if (frame.contains(x, y)) {
                return getFirstVisiblePosition() + i;
            }
        }
        return INVALID_POSITION;
    }
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:23,代码来源:TouchInterceptor.java

示例5: onRequestChildRectangleOnScreen

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
    public boolean onRequestChildRectangleOnScreen(CoordinatorLayout parent, View child,
            Rect rectangle, boolean immediate) {
  final AppBarLayout header = findFirstDependency(parent.getDependencies(child));
  if (header != null) {
    // Offset the rect by the child's left/top
    rectangle.offset(child.getLeft(), child.getTop());

    final Rect parentRect = mTempRect1;
    parentRect.set(0, 0, parent.getWidth(), parent.getHeight());

    if (!parentRect.contains(rectangle)) {
      // If the rectangle can not be fully seen the visible bounds, collapse
      // the AppBarLayout
      header.setExpanded(false, !immediate);
      return true;
    }
  }
  return false;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:21,代码来源:AppBarLayout.java

示例6: findDropTarget

import android.graphics.Rect; //导入方法依赖的package包/类
private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
    final Rect r = mRectTemp;

    final ArrayList<DropTarget> dropTargets = mDropTargets;
    final int count = dropTargets.size();
    for (int i=count-1; i>=0; i--) {
        DropTarget target = dropTargets.get(i);
        if (!target.isDropEnabled())
            continue;

        target.getHitRectRelativeToDragLayer(r);

        mDragObject.x = x;
        mDragObject.y = y;
        if (r.contains(x, y)) {

            dropCoordinates[0] = x;
            dropCoordinates[1] = y;
            mLauncher.getDragLayer().mapCoordInSelfToDescendent((View) target, dropCoordinates);

            return target;
        }
    }
    return null;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:26,代码来源:DragController.java

示例7: findChild

import android.graphics.Rect; //导入方法依赖的package包/类
private TagView findChild(int x, int y)
{
    final int cCount = getChildCount();
    for (int i = 0; i < cCount; i++)
    {
        TagView v = (TagView) getChildAt(i);
        if (v.getVisibility() == View.GONE) continue;
        Rect outRect = new Rect();
        v.getHitRect(outRect);
        if (outRect.contains(x, y))
        {
            return v;
        }
    }
    return null;
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:17,代码来源:TagFlowLayout.java

示例8: closeKeyboardWhenRequired

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Closes the keyboard when required, if the motion event does not point to a text field
 *
 * @param activity the activity
 * @param event    the event
 */
public static void closeKeyboardWhenRequired(Activity activity, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        View v = activity.getCurrentFocus();
        if (v instanceof EditText) {
            Rect outRect = new Rect();
            v.getGlobalVisibleRect(outRect);
            if (!outRect.contains((int) event.getRawX(), (int) event.getRawY())) {
                v.clearFocus();
                InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                }
            }
        }
    }
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:23,代码来源:Widget.java

示例9: touchIsCloseToSelection

import android.graphics.Rect; //导入方法依赖的package包/类
private boolean touchIsCloseToSelection(int x, int y, int start, int end) {

            final int distanceAwayDp = 40; // dp
            int distanceAwayPx = (int) (distanceAwayDp * getResources().getDisplayMetrics().density);

            // test if near selection start
            Rect selectionStart = getCursorRect(start);
            Rect nearbyStart = new Rect(
                    selectionStart.left - distanceAwayPx,
                    selectionStart.top - distanceAwayPx,
                    selectionStart.right + distanceAwayPx,
                    selectionStart.bottom + distanceAwayPx);
            if (nearbyStart.contains(x, y)) return true;

            if (end == start) return false;

            // test if near selection end
            Rect selectionEnd = getCursorRect(end);
            Rect nearbyEnd = new Rect(
                    selectionEnd.left - distanceAwayPx,
                    selectionEnd.top - distanceAwayPx,
                    selectionEnd.right + distanceAwayPx,
                    selectionEnd.bottom + distanceAwayPx);
            if (nearbyEnd.contains(x, y)) return true;
            return false;
        }
 
开发者ID:suragch,项目名称:mongol-library,代码行数:27,代码来源:MongolEditText.java

示例10: findChild

import android.graphics.Rect; //导入方法依赖的package包/类
private TagView findChild(int x, int y) {
    int cCount = getChildCount();
    for (int i = 0; i < cCount; i++) {
        TagView v = (TagView) getChildAt(i);
        if (v.getVisibility() != 8) {
            Rect outRect = new Rect();
            v.getHitRect(outRect);
            if (outRect.contains(x, y)) {
                return v;
            }
        }
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:TagFlowLayout.java

示例11: isPointInChildBounds

import android.graphics.Rect; //导入方法依赖的package包/类
/**
   * Check if a given point in the CoordinatorLayout's coordinates are within the view bounds
   * of the given direct child view.
 *
 * @param child child view to test
 * @param x X coordinate to test, in the CoordinatorLayout's coordinate system
 * @param y Y coordinate to test, in the CoordinatorLayout's coordinate system
 * @return true if the point is within the child view's bounds, false otherwise
 */
public boolean isPointInChildBounds(View child, int x, int y) {
  final Rect r = acquireTempRect();
  getDescendantRect(child, r);
  try {
    return r.contains(x, y);
  } finally {
    releaseTempRect(r);
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:19,代码来源:CoordinatorLayout.java

示例12: findChildByPoint

import android.graphics.Rect; //导入方法依赖的package包/类
private View findChildByPoint(int x, int y) {
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        Rect rect = new Rect();
        child.getHitRect(rect);
        if (rect.contains(x, y)) {
            return child;
        }
    }
    return null;
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:13,代码来源:BigBangLayout.java

示例13: findHeaderPositionUnder

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Gets the position of the header under the specified (x, y) coordinates.
 *
 * @param x x-coordinate
 * @param y y-coordinate
 * @return position of header, or -1 if not found
 */
public int findHeaderPositionUnder(int x, int y) {
    for (int i = 0; i < mHeaderRects.size(); i++) {
        Rect rect = mHeaderRects.get(mHeaderRects.keyAt(i));
        if (rect.contains(x, y)) {
            return mHeaderRects.keyAt(i);
        }
    }
    return -1;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:StickyRecyclerHeadersDecoration.java

示例14: onTouchEvent

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    updateSourcePartial();

    // The logic below is mostly copied from the parent class, since we
    // can't update private mBounds variable.

    // http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;
    // f=core/java/android/view/TouchDelegate.java;hb=eclair#l98

    final Rect sourcePartial = mSourcePartial;
    final View target = mTarget;

    int x = (int)event.getX();
    int y = (int)event.getY();

    boolean sendToDelegate = false;
    boolean hit = true;
    boolean handled = false;

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        if (sourcePartial.contains(x, y)) {
            mDelegateTargeted = true;
            sendToDelegate = true;
        }
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_MOVE:
        sendToDelegate = mDelegateTargeted;
        if (sendToDelegate) {
            if (!sourcePartial.contains(x, y)) {
                hit = false;
            }
        }
        break;
    case MotionEvent.ACTION_CANCEL:
        sendToDelegate = mDelegateTargeted;
        mDelegateTargeted = false;
        break;
    }

    if (sendToDelegate) {
        if (hit) {
            event.setLocation(target.getWidth() / 2, target.getHeight() / 2);
        } else {
            event.setLocation(-1, -1);
        }
        handled = target.dispatchTouchEvent(event);
    }
    return handled;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:53,代码来源:FractionalTouchDelegate.java

示例15: isOnTouchRect

import android.graphics.Rect; //导入方法依赖的package包/类
private boolean isOnTouchRect(View view, MotionEvent event) {
    int rawX = (int) event.getRawX();
    int rawY = (int) event.getRawY();
    int[] xy = new int[2];
    view.getLocationOnScreen(xy);
    Rect rect = new Rect();
    rect.set(xy[0], xy[1], xy[0] + view.getWidth(), xy[1] + view.getHeight());
    return rect.contains(rawX, rawY);
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:10,代码来源:TouchEventHandler.java


注:本文中的android.graphics.Rect.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。