use of android.graphics.Point in project UltimateAndroid by cymcsg.
the class ZoomPanLayout method slideToAndCenter.
/**
* Scrolls and centers the ZoomPanLayout to the x and y values specified by {@param point} Point using scrolling animation
* @param point (Point) Point instance containing the destination x and y values
*/
public void slideToAndCenter(Point point) {
// TODO:
int x = (int) -(getWidth() * 0.5);
int y = (int) -(getHeight() * 0.5);
point.offset(x, y);
slideToPoint(point);
}
use of android.graphics.Point in project barcodescanner by dm77.
the class DisplayUtils method getScreenResolution.
public static Point getScreenResolution(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point screenResolution = new Point();
if (android.os.Build.VERSION.SDK_INT >= 13) {
display.getSize(screenResolution);
} else {
screenResolution.set(display.getWidth(), display.getHeight());
}
return screenResolution;
}
use of android.graphics.Point in project glide by bumptech.
the class RecyclerAdapter method getScreenWidth.
// Display#getSize(Point)
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@SuppressWarnings("deprecation")
private static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
final int result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Point size = new Point();
display.getSize(size);
result = size.x;
} else {
result = display.getWidth();
}
return result;
}
use of android.graphics.Point in project Launcher3 by chislon.
the class Workspace method getDragViewVisualCenter.
// This is used to compute the visual center of the dragView. This point is then
// used to visualize drop locations and determine where to drop an item. The idea is that
// the visual center represents the user's interpretation of where the item is, and hence
// is the appropriate point to use when determining drop location.
private float[] getDragViewVisualCenter(int x, int y, int xOffset, int yOffset, DragView dragView, float[] recycle) {
float[] res;
if (recycle == null) {
res = new float[2];
} else {
res = recycle;
}
// First off, the drag view has been shifted in a way that is not represented in the
// x and y values or the x/yOffsets. Here we account for that shift.
x += getResources().getDimensionPixelSize(R.dimen.dragViewOffsetX);
y += getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
// These represent the visual top and left of drag view if a dragRect was provided.
// If a dragRect was not provided, then they correspond to the actual view left and
// top, as the dragRect is in that case taken to be the entire dragView.
// R.dimen.dragViewOffsetY.
int left = x - xOffset;
int top = y - yOffset;
// In order to find the visual center, we shift by half the dragRect
res[0] = left + dragView.getDragRegion().width() / 2;
res[1] = top + dragView.getDragRegion().height() / 2;
return res;
}
use of android.graphics.Point in project Launcher3 by chislon.
the class Workspace method acceptDrop.
/**
* {@inheritDoc}
*/
public boolean acceptDrop(DragObject d) {
// If it's an external drop (e.g. from All Apps), check if it should be accepted
CellLayout dropTargetLayout = mDropToLayout;
if (d.dragSource != this) {
// Don't accept the drop if we're not over a screen at time of drop
if (dropTargetLayout == null) {
return false;
}
if (!transitionStateShouldAllowDrop())
return false;
mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView, mDragViewVisualCenter);
// We want the point to be mapped to the dragTarget.
if (mLauncher.isHotseatLayout(dropTargetLayout)) {
mapPointFromSelfToHotseatLayout(mLauncher.getHotseat(), mDragViewVisualCenter);
} else {
mapPointFromSelfToChild(dropTargetLayout, mDragViewVisualCenter, null);
}
int spanX = 1;
int spanY = 1;
if (mDragInfo != null) {
final CellLayout.CellInfo dragCellInfo = mDragInfo;
spanX = dragCellInfo.spanX;
spanY = dragCellInfo.spanY;
} else {
final ItemInfo dragInfo = (ItemInfo) d.dragInfo;
spanX = dragInfo.spanX;
spanY = dragInfo.spanY;
}
int minSpanX = spanX;
int minSpanY = spanY;
if (d.dragInfo instanceof PendingAddWidgetInfo) {
minSpanX = ((PendingAddWidgetInfo) d.dragInfo).minSpanX;
minSpanY = ((PendingAddWidgetInfo) d.dragInfo).minSpanY;
}
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], minSpanX, minSpanY, dropTargetLayout, mTargetCell);
float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
if (willCreateUserFolder((ItemInfo) d.dragInfo, dropTargetLayout, mTargetCell, distance, true)) {
return true;
}
if (willAddToExistingUserFolder((ItemInfo) d.dragInfo, dropTargetLayout, mTargetCell, distance)) {
return true;
}
int[] resultSpan = new int[2];
mTargetCell = dropTargetLayout.createArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY, null, mTargetCell, resultSpan, CellLayout.MODE_ACCEPT_DROP);
boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0;
// Don't accept the drop if there's no room for the item
if (!foundCell) {
// Don't show the message if we are dropping on the AllApps button and the hotseat
// is full
boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
if (mTargetCell != null && isHotseat) {
Hotseat hotseat = mLauncher.getHotseat();
if (hotseat.isAllAppsButtonRank(hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
return false;
}
}
mLauncher.showOutOfSpaceMessage(isHotseat);
return false;
}
}
long screenId = getIdForScreen(dropTargetLayout);
if (screenId == EXTRA_EMPTY_SCREEN_ID) {
commitExtraEmptyScreen();
}
return true;
}
Aggregations