List of usage examples for android.graphics Rect contains
public boolean contains(int x, int y)
From source file:com.android.launcher2.Workspace.java
public void onDragOver(DragObject d) { // Skip drag over events while we are dragging over side pages if (mInScrollArea || mIsSwitchingState || mState == State.SMALL) return;//from w w w .java 2 s .c om Rect r = new Rect(); CellLayout layout = null; ItemInfo item = (ItemInfo) d.dragInfo; // Ensure that we have proper spans for the item that we are dropping if (item.spanX < 0 || item.spanY < 0) throw new RuntimeException("Improper spans found"); mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView, mDragViewVisualCenter); final View child = (mDragInfo == null) ? null : mDragInfo.cell; // Identify whether we have dragged over a side page if (isSmall()) { if (mLauncher.getHotseat() != null && !isExternalDragWidget(d)) { mLauncher.getHotseat().getHitRect(r); if (r.contains(d.x, d.y)) { layout = mLauncher.getHotseat().getLayout(); } } if (layout == null) { layout = findMatchingPageForDragOver(d.dragView, d.x, d.y, false); } if (layout != mDragTargetLayout) { setCurrentDropLayout(layout); setCurrentDragOverlappingLayout(layout); boolean isInSpringLoadedMode = (mState == State.SPRING_LOADED); if (isInSpringLoadedMode) { if (mLauncher.isHotseatLayout(layout)) { mSpringLoadedDragController.cancel(); } else { mSpringLoadedDragController.setAlarm(mDragTargetLayout); } } } } else { // Test to see if we are over the hotseat otherwise just use the current page if (mLauncher.getHotseat() != null && !isDragWidget(d)) { mLauncher.getHotseat().getHitRect(r); if (r.contains(d.x, d.y)) { layout = mLauncher.getHotseat().getLayout(); } } if (layout == null) { layout = getCurrentDropLayout(); } if (layout != mDragTargetLayout) { setCurrentDropLayout(layout); setCurrentDragOverlappingLayout(layout); } } // Handle the drag over if (mDragTargetLayout != null) { // We want the point to be mapped to the dragTarget. if (mLauncher.isHotseatLayout(mDragTargetLayout)) { mapPointFromSelfToHotseatLayout(mLauncher.getHotseat(), mDragViewVisualCenter); } else { mapPointFromSelfToChild(mDragTargetLayout, mDragViewVisualCenter, null); } ItemInfo info = (ItemInfo) d.dragInfo; mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX, item.spanY, mDragTargetLayout, mTargetCell); setCurrentDropOverCell(mTargetCell[0], mTargetCell[1]); float targetCellDistance = mDragTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell); final View dragOverView = mDragTargetLayout.getChildAt(mTargetCell[0], mTargetCell[1]); manageFolderFeedback(info, mDragTargetLayout, mTargetCell, targetCellDistance, dragOverView); int minSpanX = item.spanX; int minSpanY = item.spanY; if (item.minSpanX > 0 && item.minSpanY > 0) { minSpanX = item.minSpanX; minSpanY = item.minSpanY; } boolean nearestDropOccupied = mDragTargetLayout.isNearestDropLocationOccupied( (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX, item.spanY, child, mTargetCell); if (!nearestDropOccupied) { mDragTargetLayout.visualizeDropLocation(child, mDragOutline, (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], mTargetCell[0], mTargetCell[1], item.spanX, item.spanY, false, d.dragView.getDragVisualizeOffset(), d.dragView.getDragRegion()); } else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER) && !mReorderAlarm.alarmPending() && (mLastReorderX != mTargetCell[0] || mLastReorderY != mTargetCell[1])) { // Otherwise, if we aren't adding to or creating a folder and there's no pending // reorder, then we schedule a reorder ReorderAlarmListener listener = new ReorderAlarmListener(mDragViewVisualCenter, minSpanX, minSpanY, item.spanX, item.spanY, d.dragView, child); mReorderAlarm.setOnAlarmListener(listener); mReorderAlarm.setAlarm(REORDER_TIMEOUT); } if (mDragMode == DRAG_MODE_CREATE_FOLDER || mDragMode == DRAG_MODE_ADD_TO_FOLDER || !nearestDropOccupied) { if (mDragTargetLayout != null) { mDragTargetLayout.revertTempState(); } } } }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
@Override public boolean onEnterScrollArea(int x, int y, int direction) { // Ignore the scroll area if we are dragging over the hot seat boolean isPortrait = !mLauncher.getDeviceProfile().isLandscape; if (mLauncher.getHotseat() != null && isPortrait) { Rect r = new Rect(); mLauncher.getHotseat().getHitRect(r); if (r.contains(x, y)) { return false; }// ww w. java2s. c om } boolean result = false; if (!workspaceInModalState() && !mIsSwitchingState && getOpenFolder() == null) { mInScrollArea = true; final int page = getNextPage() + (direction == DragController.SCROLL_LEFT ? -1 : 1); // We always want to exit the current layout to ensure parity of enter / exit setCurrentDropLayout(null); if (0 <= page && page < getChildCount()) { // Ensure that we are not dragging over to the custom content screen if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) { return false; } CellLayout layout = (CellLayout) getChildAt(page); setCurrentDragOverlappingLayout(layout); // Workspace is responsible for drawing the edge glow on adjacent pages, // so we need to redraw the workspace when this may have changed. invalidate(); result = true; } } return result; }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
@Override public boolean onEnterScrollArea(int x, int y, int direction) { // Ignore the scroll area if we are dragging over the hot seat boolean isPortrait = !LauncherAppState.isScreenLandscape(getContext()); if (mLauncher.getHotseat() != null && isPortrait) { Rect r = new Rect(); mLauncher.getHotseat().getHitRect(r); if (r.contains(x, y)) { return false; }//from w w w . j a v a 2s . c om } boolean result = false; if (!isSmall() && !mIsSwitchingState && getOpenFolder() == null) { mInScrollArea = true; final int page = getNextPage() + (direction == DragController.SCROLL_LEFT ? -1 : 1); // We always want to exit the current layout to ensure parity of // enter / exit setCurrentDropLayout(null); if (0 <= page && page < getChildCount()) { // Ensure that we are not dragging over to the custom content // screen if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) { return false; } CellLayout layout = (CellLayout) getChildAt(page); setCurrentDragOverlappingLayout(layout); // Workspace is responsible for drawing the edge glow on // adjacent pages, // so we need to redraw the workspace when this may have // changed. invalidate(); result = true; } } return result; }
From source file:cc.flydev.launcher.Workspace.java
boolean isPointInSelfOverHotseat(int x, int y, Rect r) { if (r == null) { r = new Rect(); }/*ww w. java 2 s .c o m*/ mTempPt[0] = x; mTempPt[1] = y; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); r = grid.getHotseatRect(); if (r.contains(mTempPt[0], mTempPt[1])) { return true; } return false; }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
boolean isPointInSelfOverHotseat(int x, int y, Rect r) { if (r == null) { r = new Rect(); }/*from w ww . j a v a2 s. c om*/ mTempPt[0] = x; mTempPt[1] = y; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true); DeviceProfile grid = mLauncher.getDeviceProfile(); r = grid.getHotseatRect(); if (r.contains(mTempPt[0], mTempPt[1])) { return true; } return false; }
From source file:com.zyk.launcher.Workspace.java
@Override public boolean onEnterScrollArea(int x, int y, int direction) { // Ignore the scroll area if we are dragging over the hot seat boolean isPortrait = !LauncherAppState.isScreenLandscape(getContext()); if (mLauncher.getHotseat() != null && isPortrait) { Rect r = new Rect(); mLauncher.getHotseat().getHitRect(r); if (r.contains(x, y)) { return false; }/* w ww. ja va 2 s.c om*/ } boolean result = false; if (!workspaceInModalState() && !mIsSwitchingState && mDragUtils.getOpenFolder() == null) { mInScrollArea = true; final int page = getNextPage() + (direction == DragController.SCROLL_LEFT ? -1 : 1); // We always want to exit the current layout to ensure parity of enter / exit setCurrentDropLayout(null); if (0 <= page && page < getChildCount()) { // Ensure that we are not dragging over to the custom content screen if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) { return false; } CellLayout layout = (CellLayout) getChildAt(page); setCurrentDragOverlappingLayout(layout); // Workspace is responsible for drawing the edge glow on adjacent pages, // so we need to redraw the workspace when this may have changed. invalidate(); result = true; } } return result; }
From source file:com.android.launcher3.Workspace.java
@Override public boolean onEnterScrollArea(int x, int y, int direction) { // Ignore the scroll area if we are dragging over the hot seat boolean isPortrait = !LauncherAppState.isScreenLandscape(getContext()); if (mLauncher.getHotseat() != null && isPortrait) { Rect r = new Rect(); mLauncher.getHotseat().getHitRect(r); if (r.contains(x, y)) { return false; }/* w w w . jav a 2 s .c o m*/ } boolean result = false; if (!workspaceInModalState() && !mIsSwitchingState && getOpenFolder() == null) { mInScrollArea = true; final int page = getNextPage() + (direction == DragController.SCROLL_LEFT ? -1 : 1); // We always want to exit the current layout to ensure parity of enter / exit setCurrentDropLayout(null); if (0 <= page && page < getChildCount()) { // Ensure that we are not dragging over to the custom content screen if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) { return false; } CellLayout layout = (CellLayout) getChildAt(page); setCurrentDragOverlappingLayout(layout); // Workspace is responsible for drawing the edge glow on adjacent pages, // so we need to redraw the workspace when this may have changed. invalidate(); result = true; } } return result; }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
public int pointToPosition(int x, int y) { Rect frame = mTouchFrame; if (frame == null) { mTouchFrame = new Rect(); frame = mTouchFrame;/*w w w . j ava 2 s . c o m*/ } final int count = getChildCount(); for (int i = count - 1; i >= 0; i--) { final View child = getChildAt(i); if (child.getVisibility() == View.VISIBLE) { child.getHitRect(frame); if (frame.contains(x, y)) { return mFirstPosition + i; } } } return INVALID_POSITION; }