/** * Allows third party apps to specify the scanning rectangle dimensions, rather than determine * them automatically based on screen resolution. * * @param width The width in pixels to scan. * @param height The height in pixels to scan. */ public synchronized void setManualFramingRect(int width, int height) { if (initialized) { Point screenResolution = configManager.getScreenResolution(); if (width > screenResolution.x) { width = screenResolution.x; } if (height > screenResolution.y) { height = screenResolution.y; } int leftOffset = (screenResolution.x - width) / 2; int topOffset = (screenResolution.y - height) / 2; framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); Log.d(TAG, "Calculated manual framing rect: " + framingRect); framingRectInPreview = null; } else { requestedFramingRectWidth = width; requestedFramingRectHeight = height; } }
private void drawScrollLine(Canvas canvas) { Point startp; Point endp; for (int i = 0; i < mPoints.length - 1; i++) { startp = mPoints[i]; endp = mPoints[i + 1]; int wt = (startp.x + endp.x) / 2; Point p3 = new Point(); Point p4 = new Point(); p3.y = startp.y; p3.x = wt; p4.y = endp.y; p4.x = wt; Path path = new Path(); path.moveTo(startp.x, startp.y); path.cubicTo(p3.x, p3.y, p4.x, p4.y, endp.x, endp.y); canvas.drawPath(path, mPaint); } }
public void initFromCameraParameters(Camera camera) { Camera.Parameters parameters = camera.getParameters(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point theScreenResolution = new Point(); theScreenResolution = getDisplaySize(display); screenResolution = theScreenResolution; Log.i(TAG, "Screen resolution: " + screenResolution); /** 因为换成了竖屏显示,所以不替换屏幕宽高得出的预览图是变形的 */ Point screenResolutionForCamera = new Point(); screenResolutionForCamera.x = screenResolution.x; screenResolutionForCamera.y = screenResolution.y; if (screenResolution.x < screenResolution.y) { screenResolutionForCamera.x = screenResolution.y; screenResolutionForCamera.y = screenResolution.x; } cameraResolution = findBestPreviewSizeValue(parameters, screenResolutionForCamera); Log.i(TAG, "Camera resolution x: " + cameraResolution.x); Log.i(TAG, "Camera resolution y: " + cameraResolution.y); }
/** * Reads, one time, values from the camera that are needed by the app. */ void initFromCameraParameters(Camera camera) { Camera.Parameters parameters = camera.getParameters(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); // We're landscape-only, and have apparently seen issues with display thinking it's portrait // when waking from sleep. If it's not landscape, assume it's mistaken and reverse them: if (width < height) { Log.i(TAG, "Display reports portrait orientation; assuming this is incorrect"); int temp = width; width = height; height = temp; } screenResolution = new Point(width, height); Log.i(TAG, "Screen resolution: " + screenResolution); cameraResolution = findBestPreviewSizeValue(parameters, screenResolution); Log.i(TAG, "Camera resolution: " + cameraResolution); }
private Point getNextTilePoint(int row, int col, int direction) { switch (direction) { case TrainDirection.LEFT: col--; break; case TrainDirection.RIGHT: col++; break; case TrainDirection.UP: row--; break; case TrainDirection.DOWN: row++; break; } return new Point(row, col); }
public static boolean isNavigationBarShow(Activity activity){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); Point realSize = new Point(); display.getSize(size); display.getRealSize(realSize); return realSize.y!=size.y; }else { boolean menu = ViewConfiguration.get(activity).hasPermanentMenuKey(); boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if(menu || back) { return false; }else { return true; } } }
/** * 绘制曲线上的锚点 * * @param canvas */ private void drawLinePoints(Canvas canvas) { if (linePoints == null) return; float pointWidth = dip2px(pointWidthDP) / 2; int pointCount = linePoints.length; if (isPlayAnim) { pointCount = Math.round(currentValue * linePoints.length); } for (int i = 0; i < pointCount; i++) { Point point = linePoints[i]; if (point == null) break; if (isCubePoint) { canvas.drawPoint(point.x, point.y, pointPaint); } else { canvas.drawCircle(point.x, point.y, pointWidth, pointPaint); } //绘制点的文本 drawLinePointText(canvas, String.valueOf(dataList.get(i).getValue()), point.x, point.y); } }
/** * checks if pt is on root and calls itself recursivly to check root's children * @param pt the point we want to check the location of * @param root the message we want to check if the point is on * @return root if pt is on it, null otherwise * @author Paul Best */ public Message clickedOn(Point pt, Message root){ Message answer; for(int i = 0; i<root.getChildren().size();i++){ answer = clickedOn(pt,root.getChildren().get(i)); if(answer!=null){ return answer; } } if(Math.pow(Math.pow(pt.x/mScaleFactor-(root.getGoval().getX()+mPosX/mScaleFactor),2)+Math.pow(pt.y/mScaleFactor-(root.getGoval().getY()+mPosY/mScaleFactor),2),0.5)<root.getGoval().getRay()){ return root; } else{ return null; } }
public static Point getRealScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(size); } else { try { size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display); size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display); } catch (Exception e) { e.printStackTrace(); } } return size; }
/** * Like {@link #getFramingRect} but coordinates are in terms of the preview frame, * not UI / screen. */ public Rect getFramingRectInPreview() { if (framingRectInPreview == null) { Rect rect = new Rect(getFramingRect()); Point cameraResolution = configManager.getCameraResolution(); Point screenResolution = configManager.getScreenResolution(); //modify here // rect.left = rect.left * cameraResolution.x / screenResolution.x; // rect.right = rect.right * cameraResolution.x / screenResolution.x; // rect.top = rect.top * cameraResolution.y / screenResolution.y; // rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y; rect.left = rect.left * cameraResolution.y / screenResolution.x; rect.right = rect.right * cameraResolution.y / screenResolution.x; rect.top = rect.top * cameraResolution.x / screenResolution.y; rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y; framingRectInPreview = rect; } return framingRectInPreview; }
/** * 重新计算displayMetrics.xhdpi, 使单位pt重定义为设计稿的相对长度 * @see #activate() * * @param context * @param designWidth 设计稿的宽度 */ public static void resetDensity(Context context, float designWidth){ if(context == null) return; Point size = new Point(); ((WindowManager)context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getSize(size); Resources resources = context.getResources(); resources.getDisplayMetrics().xdpi = size.x/designWidth*72f; DisplayMetrics metrics = getMetricsOnMiui(context.getResources()); if(metrics != null) metrics.xdpi = size.x/designWidth*72f; }
private void drawWaypoints(Canvas canvas, Paint paint, List<Point> waypoints) { if ((waypoints == null) || (waypoints.size()==0)) { return; } Paint p = new Paint(paint); p.setStyle(Style.STROKE); p.setColor(Color.RED); p.setStrokeWidth(2.0f); Path path = new Path(); Point startPoint = waypoints.get(0); path.moveTo(startPoint.x, startPoint.y); for (int i=1; i<waypoints.size()-1; i++) { Point point = waypoints.get(i); path.lineTo(point.x, point.y); } Point endPoint = waypoints.get(waypoints.size()-1); path.setLastPoint(endPoint.x, endPoint.y); canvas.drawPath(path, p); }
public CubeLoadingView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CubeLoadingView); mShadowEnable = a.getBoolean(R.styleable.CubeLoadingView_shadowEnable, true); MAIN_COLOR = a.getColor(R.styleable.CubeLoadingView_mainColor, MAIN_COLOR); CEIL_COLOR = a.getColor(R.styleable.CubeLoadingView_ceilColor, CEIL_COLOR); SHADOW_COLOR = a.getColor(R.styleable.CubeLoadingView_shadowColor, SHADOW_COLOR); T = a.getInteger(R.styleable.CubeLoadingView_duration, T); a.recycle(); mPaint = new Paint(); mPaint.setStyle(Paint.Style.FILL); mOrigin = new Point(); mCubes = new ArrayList<>(); if (SDK_INT >= Build.VERSION_CODES.KITKAT) { mCubePathCollection = new Path(); mShadowPathCollection = new Path(); mCeilPathCollection = new Path(); } else { mCubePaths = new ArrayList<>(); mShadowPaths = new ArrayList<>(); mCeilPaths = new ArrayList<>(); } }
public MuPDFReflowView(Context c, MuPDFCore core, Point parentSize) { super(c); mHandler = new Handler(); mCore = core; mParentSize = parentSize; mScale = 1.0f; mContentHeight = parentSize.y; getSettings().setJavaScriptEnabled(true); addJavascriptInterface(new Object(){ public void reportContentHeight(String value) { mContentHeight = (int)Float.parseFloat(value); mHandler.post(new Runnable() { public void run() { requestLayout(); } }); } }, "HTMLOUT"); setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { setScale(mScale); } }); }
/** * 计算预览区域大小 * * @param measureWidth * @param measureHeight * @return 是否应该调用requestLayout刷新视图 */ protected boolean calculatePreviewSize(int measureWidth, int measureHeight) { Point size; if (mScaleType == ScaleType.FIT_CENTER) { size = fitCenter(measureWidth, measureHeight); } else if (mScaleType == ScaleType.FIT_WIDTH) { size = fitWidth(measureWidth, measureHeight); } else if (mScaleType == ScaleType.FIT_HEIGHT) { size = fitHeight(measureWidth, measureHeight); } else { size = centerCrop(measureWidth, measureHeight); } boolean change = size.x != mPreviewWidth || size.y != mPreviewHeight; mPreviewWidth = size.x; mPreviewHeight = size.y; return change; }
/** * 获取最佳预览大小 * @param parameters 相机参数 * @param screenResolution 屏幕宽高 * @return */ public static Point getBestCameraResolution(Camera.Parameters parameters, Point screenResolution) { float tmp = 0f; float mindiff = 100f; float x_d_y = (float) screenResolution.x / (float) screenResolution.y; Camera.Size best = null; List<Camera.Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes(); for (Camera.Size s : supportedPreviewSizes) { tmp = Math.abs(((float) s.width / (float) s.height) - x_d_y); if (tmp < mindiff) { mindiff = tmp; best = s; } } return new Point(best.width, best.height); }
/** * Reads, one time, values from the camera that are needed by the app. */ void initFromCameraParameters(Camera camera) { Camera.Parameters parameters = camera.getParameters(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point theScreenResolution = new Point(); display.getSize(theScreenResolution); screenResolution = theScreenResolution; Log.i(TAG, "Screen resolution: " + screenResolution); //解决竖屏后图像拉伸问题 Point screenResolutionForCamera = new Point(); screenResolutionForCamera.x = screenResolution.x; screenResolutionForCamera.y = screenResolution.y; // preview size is always something like 480*320, other 320*480 if (screenResolution.x < screenResolution.y) { screenResolutionForCamera.x = screenResolution.y; screenResolutionForCamera.y = screenResolution.x; } //TODO check // cameraResolution = getCameraResolution(parameters, screenResolutionForCamera); cameraResolution = CameraConfigurationUtils.findBestPreviewSizeValue(parameters, screenResolutionForCamera); Log.i(TAG, "Camera resolution: " + cameraResolution); }
@Override public void onPreviewFrame(byte[] data, Camera camera) { Point cameraResolution = configManager.getCameraResolution(); Handler thePreviewHandler = previewHandler; if (cameraResolution != null && thePreviewHandler != null) { Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data); message.sendToTarget(); previewHandler = null; } else { Log.d(TAG, "Got preview callback, but no handler or resolution available"); } }
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) { int bestX = 0; int bestY = 0; int diff = Integer.MAX_VALUE; for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) { previewSize = previewSize.trim(); int dimPosition = previewSize.indexOf('x'); if (dimPosition < 0) { continue; } int newX; int newY; try { newX = Integer.parseInt(previewSize.substring(0, dimPosition)); newY = Integer.parseInt(previewSize.substring(dimPosition + 1)); } catch (NumberFormatException nfe) { continue; } int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y); if (newDiff == 0) { bestX = newX; bestY = newY; break; } else if (newDiff < diff) { bestX = newX; bestY = newY; diff = newDiff; } } if (bestX > 0 && bestY > 0) { return new Point(bestX, bestY); } return null; }
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private Point getDisplaySize(final Display display) { final Point point = new Point(); try { display.getSize(point); } catch (NoSuchMethodError ignore) { point.x = display.getWidth(); point.y = display.getHeight(); } return point; }
public boolean hitTest(Point pt) { PointF ul = new PointF(mPoint.x, mPoint.y-50); PointF dr = new PointF(mPoint.x+50, mPoint.y); Rect rect = new Rect((int)ul.x, (int)ul.y, (int)dr.x, (int)dr.y); if (rect.contains(pt.x, pt.y)) return true; return false; }
@Override public UncapableCause filter(Context context, Item item) { if (!needFiltering(context, item)) return null; Point size = PhotoMetadataUtils.getBitmapBound(context.getContentResolver(), item.getContentUri()); if (size.x < mMinWidth || size.y < mMinHeight || item.size > mMaxSize) { return new UncapableCause(UncapableCause.DIALOG, context.getString(R.string.error_gif, mMinWidth, String.valueOf(PhotoMetadataUtils.getSizeInMB(mMaxSize)))); } return null; }
/** * 设置检索结果显示索引(若有多个结果则地图缩放到保证所有结果可见) **/ private void setPoiPosition() { if (aList.size() == 0 || poiOverlay == null) return; if (aList.size() == 1) { MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(aList.get(0).getLatitude(), aList.get(0).getLongitude())) .targetScreen(new Point(baiduMap.getMapStatus().targetScreen.x, baiduMap.getMapStatus().targetScreen.y / 4)) .zoom(17F); baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); } else poiOverlay.zoomToSpan(); }
public Rect getFramingRectInPreview() { if (this.framingRectInPreview == null) { Rect rect = new Rect(getFramingRect()); Point cameraResolution = this.configManager.getCameraResolution(); Point screenResolution = this.configManager.getScreenResolution(); rect.left = (rect.left * cameraResolution.y) / screenResolution.x; rect.right = (rect.right * cameraResolution.y) / screenResolution.x; rect.top = (rect.top * cameraResolution.x) / screenResolution.y; rect.bottom = (rect.bottom * cameraResolution.x) / screenResolution.y; this.framingRectInPreview = rect; } return this.framingRectInPreview; }
public static int getDisplayWidth(Activity activity){ int width=0; if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) { Point point=new Point(); activity.getWindowManager().getDefaultDisplay().getSize(point); width = point.x; } return width; }
/** * @param onTouchListener interface implemented in activity */ public Touch(IOnTouchListener onTouchListener) { this.mOnTouchListener = onTouchListener; numOfTouches = 0; isBeingTouch = false; this.mPoint = new Point(); }
/** * Reads, one time, values from the camera that are needed by the app. */ void initFromCameraParameters(Camera camera) { Camera.Parameters parameters = camera.getParameters(); previewFormat = parameters.getPreviewFormat(); previewFormatString = parameters.get("preview-format"); Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); screenResolution = new Point(display.getWidth(), display.getHeight()); Log.d(TAG, "Screen resolution: " + screenResolution); // //Lemon add 扫描框修改,解决拉伸但导致成像模糊识别率很低。<<<<<<<<<<<<<<<<<<<<<<<<<<<< // Point screenResolutionForCamera = new Point(); // screenResolutionForCamera.x = screenResolution.x; // screenResolutionForCamera.y = screenResolution.y; // // preview size is always something like 480*320, other 320*480 // if (screenResolution.x < screenResolution.y) { // screenResolutionForCamera.x = screenResolution.y; // screenResolutionForCamera.y = screenResolution.x; // } //Lemon add 扫描框修改,解决拉伸>>>>>>>>>>>>>>>>>>>>>>>>>>>> //Lemon 扫描框修改,解决拉伸但导致成像模糊识别率很低 screenResolution改为screenResolutionForCamera);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< cameraResolution = getCameraResolution(parameters, screenResolution); Log.d(TAG, "Camera resolution: " + screenResolution); //Lemon 扫描框修改,解决拉伸但导致成像模糊识别率很低 screenResolution改为screenResolutionForCamera);>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> }
public static Point MeasureString(Context context, String text, float fontSize, int widthMeasureSpec, int heightMeasureSpec) { int width = 0; int height = 0; if (null == context || null == text || text.isEmpty() || 0 == fontSize) { return null; } TextView tv = new TextView(context); tv.setText(text);// 待测文本 tv.setTextSize(fontSize);// 字体 if (ViewGroup.LayoutParams.WRAP_CONTENT != widthMeasureSpec && ViewGroup.LayoutParams.MATCH_PARENT != widthMeasureSpec) { tv.setWidth(widthMeasureSpec);// 如果设置了宽度,字符串的宽度则为所设置的宽度 } if (ViewGroup.LayoutParams.WRAP_CONTENT != heightMeasureSpec && ViewGroup.LayoutParams.MATCH_PARENT != heightMeasureSpec) { tv.setHeight(heightMeasureSpec); } tv.setSingleLine(false);// 多行 tv.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); width = tv.getMeasuredWidth(); height = tv.getMeasuredHeight(); Point point = new Point(); point.x = width; point.y = height; return point; }
@Override public void run() { Thread thread = Thread.currentThread(); ColorIterator.Pixel pixel = new ColorIterator.Pixel(); while (mColorIterator.hasNext() && !thread.isInterrupted()) { mColorIterator.nextColor(pixel); if (mColorDetector.detectsColor(pixel.red, pixel.green, pixel.blue)) { mResult.add(new Point(mColorIterator.getX(), mColorIterator.getY())); } } if (thread.isInterrupted()) { throw new ScriptInterruptedException(); } }
public void onPreviewFrame(byte[] data, Camera camera) { Point cameraResolution = configManager.getCameraResolution(); if (!useOneShotPreviewCallback) { camera.setPreviewCallback(null); } if (previewHandler != null) { Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data); message.sendToTarget(); previewHandler = null; } else { Log.d(TAG, "Got preview callback, but no handler for it"); } }
private void setCustomLockscreenImage() { Intent intent = new Intent(getActivity(), PickImageActivity.class); intent.putExtra(PickImageActivity.EXTRA_CROP, true); intent.putExtra(PickImageActivity.EXTRA_SCALE, true); Display display = getActivity().getWindowManager().getDefaultDisplay(); Point displaySize = new Point(); display.getRealSize(displaySize); // Lock screen for tablets visible section are different in landscape/portrait, // image need to be cropped correctly, like wallpaper setup for scrolling in background in home screen // other wise it does not scale correctly if (Utils.isTabletUI(getActivity())) { WallpaperManager wpManager = WallpaperManager.getInstance(getActivity()); int wpWidth = wpManager.getDesiredMinimumWidth(); int wpHeight = wpManager.getDesiredMinimumHeight(); float spotlightX = (float) displaySize.x / wpWidth; float spotlightY = (float) displaySize.y / wpHeight; intent.putExtra(PickImageActivity.EXTRA_ASPECT_X, wpWidth); intent.putExtra(PickImageActivity.EXTRA_ASPECT_Y, wpHeight); intent.putExtra(PickImageActivity.EXTRA_OUTPUT_X, wpWidth); intent.putExtra(PickImageActivity.EXTRA_OUTPUT_Y, wpHeight); intent.putExtra(PickImageActivity.EXTRA_SPOTLIGHT_X, spotlightX); intent.putExtra(PickImageActivity.EXTRA_SPOTLIGHT_Y, spotlightY); } else { boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; intent.putExtra(PickImageActivity.EXTRA_ASPECT_X, isPortrait ? displaySize.x : displaySize.y); intent.putExtra(PickImageActivity.EXTRA_ASPECT_Y, isPortrait ? displaySize.y : displaySize.x); } getActivity().startActivityFromFragment(this, intent, REQ_LOCKSCREEN_BACKGROUND); }
/** * 判断是否消灭敌方坦克 * @param point 单签子弹坐标点 * @return 消灭:true, 反之:false */ private boolean checkWipeOutETank(Point point) { boolean beHit = false; int trackIndex = getTrackIndex(point.y); RectF rectF = eTankSparseArray.get(trackIndex).peek(); if (rectF != null && rectF.contains(point.x, point.y)) { // 击中 if (++wipeOutNum == levelNum) { upLevel(); } eTankSparseArray.get(trackIndex).poll(); beHit = true; } return beHit; }
/** * Used to set the scale for Facebook WebPosts. * * @return the integer scale value. * @deprecated Facebook WebPosts are deprecated. This isn't needed for Facebook Posts. */ private int getScale() { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; Double val = (double) width / 484d; val = val * 100d; return val.intValue(); }
/** * Like {@link #getFramingRect} but coordinates are in terms of the preview frame, * not UI / screen. * * @return {@link Rect} expressing barcode scan area in terms of the preview size */ public synchronized Rect getFramingRectInPreview() { if (framingRectInPreview == null) { Rect framingRect = getFramingRect(); if (framingRect == null) { return null; } Rect rect = new Rect(framingRect); Point cameraResolution = configManager.getCameraResolution(); Point screenResolution = configManager.getScreenResolution(); if (cameraResolution == null || screenResolution == null) { // Called early, before init even finished return null; } if (view.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { rect.left = rect.left * cameraResolution.y / screenResolution.x; rect.right = rect.right * cameraResolution.y / screenResolution.x; rect.top = rect.top * cameraResolution.x / screenResolution.y; rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y; } else { rect.left = rect.left * cameraResolution.x / screenResolution.x; rect.right = rect.right * cameraResolution.x / screenResolution.x; rect.top = rect.top * cameraResolution.y / screenResolution.y; rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y; } framingRectInPreview = rect; } return framingRectInPreview; }
private void drawHandles(Canvas canvas) { int handleColor = Color.argb(75, Color.red(mHandleColor), Color.green(mHandleColor), Color.blue(mHandleColor)); mHandlePaint.setColor(handleColor); for (Point handle : mHandles) { canvas.drawCircle(handle.x, handle.y, mHandleSize, mHandlePaint); } }
/** * Get the center point of the {@link QuickActionView} aka the point at which the actions will eminate from * * @return the center point, or null if the view has not yet been created */ @Nullable public Point getCenterPoint() { if (mQuickActionViewLayout != null) { return mQuickActionViewLayout.mCenterPoint; } return null; }
/** * Overrides to provide fading when slide removal is enabled. */ @Override public void onDragFloatView(View floatView, Point position, Point touch) { if (mRemoveEnabled && mIsRemoving) { mPositionX = position.x; } }
/** * Traffic method to divert calls based on {@link Orientation}. * * @see #setChildOffsetsVertical(int, int, Point, int) * @see #setChildOffsetsHorizontal(int, int, Point, int) */ private void setChildOffsets(@Gravity int gravity, int orientation, @Dimension int radius, Point center, int peekDistance) { if (orientation == VERTICAL) { setChildOffsetsVertical(gravity, radius, center, peekDistance); } else if (orientation == HORIZONTAL) { setChildOffsetsHorizontal(gravity, radius, center, peekDistance); } }