Java Code Examples for android.graphics.Point

The following examples show how to use android.graphics.Point. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private synchronized ArrayList<Point> detect(LumaData s) {
    if (mComparer == null) {
        mComparer = new Comparer(s.getWidth(), s.getHeight(), mBoxes, mLeniency);
    }

    if (mPreviousState == null) {
        mPreviousState = s;
        return null;
    }

    if (s.getWidth() != mPreviousState.getWidth() || s.getHeight() != mPreviousState.getHeight()) {
        return null;
    }

    ArrayList<Point> differing = mComparer.isDifferent(s, mPreviousState);
    mPreviousState.release();
    mPreviousState = s;

    return differing;
}
 
Example 2
Source Project: colorpicker   Source File: ColorPickerView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This will return the closes point on the circle relative to the touch event
 *
 * @param touchX
 * @param touchY
 * @return
 */
private Point getClosestPoint(float touchX, float touchY) {
    //Todo: find if there is a faster way.
    //This is for center 0,0
    double angle = Math.atan2(touchY - getCenterYInParent(), touchX - getCenterXInParent());

    double onCircleX = Math.cos(angle) * mRadius;
    double onCircleY = Math.sin(angle) * mRadius;

    //fetch the selected color from the drawable
    mLastSelectedColor = getColorFromColorRing((float) onCircleX + mCenterX, (float) onCircleY + mCenterY);
    Log.d("colorpicker", "Selected color: " + mLastSelectedColor);
    fireColorListener(getColor());

    //The circle is on an offset, not on 0,0 but centered and in a viewgroup (our parent framelayout)
    onCircleX += getCenterXInParent();
    onCircleY += getCenterYInParent();

    return new Point((int) onCircleX, (int) onCircleY);
}
 
Example 3
Source Project: Leanplum-Android-SDK   Source File: HTMLOptions.java    License: Apache License 2.0 6 votes vote down vote up
int getHtmlYOffset(Activity context) {
  int yOffset = 0;
  if (context == null) {
    return yOffset;
  }

  if (htmlYOffset != null && !TextUtils.isEmpty(htmlYOffset.type)) {
    yOffset = htmlYOffset.value;
    if ("%".equals(htmlYOffset.type)) {
      Point size = SizeUtil.getDisplaySize(context);
      yOffset = (size.y - SizeUtil.getStatusBarHeight(context)) * yOffset / 100;
    } else {
      yOffset = SizeUtil.dpToPx(context, yOffset);
    }
  }
  return yOffset;
}
 
Example 4
Source Project: LB-Launcher   Source File: WallpaperCropActivity.java    License: Apache License 2.0 6 votes vote down vote up
static public void suggestWallpaperDimension(Resources res,
        final SharedPreferences sharedPrefs,
        WindowManager windowManager,
        final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
    final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
    // If we have saved a wallpaper width/height, use that instead

    int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
    int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);

    if (savedWidth == -1 || savedHeight == -1) {
        if (!fallBackToDefaults) {
            return;
        } else {
            savedWidth = defaultWallpaperSize.x;
            savedHeight = defaultWallpaperSize.y;
        }
    }

    if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
            savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
        wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
    }
}
 
Example 5
Source Project: LB-Launcher   Source File: WallpaperPickerActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(WallpaperPickerActivity a) {
    BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
            new BitmapRegionTileSource.ResourceBitmapSource(
                    mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
    bitmapSource.loadInBackground();
    BitmapRegionTileSource source = new BitmapRegionTileSource(a, bitmapSource);
    CropView v = a.getCropView();
    v.setTileSource(source, null);
    Point wallpaperSize = WallpaperCropActivity.getDefaultWallpaperSize(
            a.getResources(), a.getWindowManager());
    RectF crop = WallpaperCropActivity.getMaxCropRect(
            source.getImageWidth(), source.getImageHeight(),
            wallpaperSize.x, wallpaperSize.y, false);
    v.setScale(wallpaperSize.x / crop.width());
    v.setTouchEnabled(false);
    a.setSystemWallpaperVisiblity(false);
}
 
Example 6
Source Project: CodeScaner   Source File: PreviewCallback.java    License: MIT License 6 votes vote down vote up
@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);
      Point screenResolution = configManager.getScreenResolution();
      Message message;
      if (screenResolution.x < screenResolution.y){
        // portrait
        message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.y,
                cameraResolution.x, data);
      } else {
        // landscape
        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");
    }
  }
 
Example 7
Source Project: firebase-android-sdk   Source File: FiamAnimator.java    License: Apache License 2.0 6 votes vote down vote up
public void slideOutOfView(
    final Application app,
    final View view,
    Position end,
    final AnimationCompleteListener completeListener) {
  Point start = Position.getPoint(end, view);

  AnimatorListenerAdapter animatorListenerAdapter =
      new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          // Remove fiam from window only after the animation is complete
          completeListener.onComplete();
        }
      };

  view.animate()
      .translationX(start.x)
      .translationY(start.y)
      .setDuration(app.getResources().getInteger(android.R.integer.config_longAnimTime))
      .setListener(animatorListenerAdapter);
}
 
Example 8
/**
 * Returns the smallest video size greater than or equal to a specified size that also satisfies
 * the {@link MediaCodec}'s width and height alignment requirements.
 * <p>
 * Must not be called if the device SDK version is less than 21.
 *
 * @param width Width in pixels.
 * @param height Height in pixels.
 * @return The smallest video size greater than or equal to the specified size that also satisfies
 *     the {@link MediaCodec}'s width and height alignment requirements, or null if not a video
 *     codec.
 */
@TargetApi(21)
public Point alignVideoSizeV21(int width, int height) {
  if (capabilities == null) {
    logNoSupport("align.caps");
    return null;
  }
  VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
  if (videoCapabilities == null) {
    logNoSupport("align.vCaps");
    return null;
  }
  int widthAlignment = videoCapabilities.getWidthAlignment();
  int heightAlignment = videoCapabilities.getHeightAlignment();
  return new Point(Util.ceilDivide(width, widthAlignment) * widthAlignment,
      Util.ceilDivide(height, heightAlignment) * heightAlignment);
}
 
Example 9
private ResourceWallpaperInfo getPreKKDefaultWallpaperInfo() {
    Resources sysRes = Resources.getSystem();
    int resId = sysRes.getIdentifier("default_wallpaper", "drawable", "android");

    File defaultThumbFile = getDefaultThumbFile();
    Bitmap thumb = null;
    boolean defaultWallpaperExists = false;
    if (defaultThumbFile.exists()) {
        thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath());
        defaultWallpaperExists = true;
    } else {
        Resources res = getResources();
        Point defaultThumbSize = getDefaultThumbnailSize(res);
        int rotation = BitmapUtils.getRotationFromExif(res, resId);
        thumb = createThumbnail(
                defaultThumbSize, getContext(), null, null, sysRes, resId, rotation, false);
        if (thumb != null) {
            defaultWallpaperExists = saveDefaultWallpaperThumb(thumb);
        }
    }
    if (defaultWallpaperExists) {
        return new ResourceWallpaperInfo(sysRes, resId, new BitmapDrawable(thumb));
    }
    return null;
}
 
Example 10
Source Project: BigApp_Discuz_Android   Source File: FloatingView.java    License: Apache License 2.0 5 votes vote down vote up
public FloatingView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.context = context;


    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingView);
    mColor = a.getColor(R.styleable.FloatingView_FloatingView_color, Color.TRANSPARENT);
    mButtonPaint.setStyle(Paint.Style.FILL);
    mButtonPaint.setColor(mColor);
    float radius, dx, dy;
    radius = a.getFloat(R.styleable.FloatingView_FloatingView_shadowRadius, 10.0f);
    dx = a.getFloat(R.styleable.FloatingView_FloatingView_shadowDx, 0.0f);
    dy = a.getFloat(R.styleable.FloatingView_FloatingView_shadowDy, 3.5f);
    int color = a.getInteger(R.styleable.FloatingView_FloatingView_shadowColor, Color.TRANSPARENT);
    mButtonPaint.setShadowLayer(radius, dx, dy, color);

    Drawable drawable = a.getDrawable(R.styleable.FloatingView_FloatingView_drawable);
    if (null != drawable) {
        mBitmap = ((BitmapDrawable) drawable).getBitmap();
    }
    setWillNotDraw(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    WindowManager mWindowManager = (WindowManager)
            context.getSystemService(Context.WINDOW_SERVICE);
    Display display = mWindowManager.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);
        mYHidden = size.y;
    } else mYHidden = display.getHeight();
}
 
Example 11
Source Project: android-gps-test-tool   Source File: DrawCircle.java    License: Apache License 2.0 5 votes vote down vote up
public void createMercatorCircle(double radius, Point center){
	double lon1 = degToRad(center.x);
	double lat1 = degToRad(center.y);
	double R_KM = 6371; //radius km
	double R_MI = 3963; //radius mi
	//double d = radius/R_KM; //angular distance on earth's surface
	double d = radius/R_MI;
	
	Polygon circle = new Polygon();
	int nodes = 100; //number of nodes in circle
	int step = Math.round(360/nodes);
	int n = 0;
	double[] pointArray;
	
	for(int x = 0; x <= 360; x++){
		int z = Math.round(n+=step);
		double bearing = degToRad(x);
		
		double lat2 = Math.asin(
				Math.sin(lat1) * Math.cos(d) +
				Math.cos(lat1) * Math.sin(d) * Math.cos(bearing)
		);
		
		double lon2 = lon1 + Math.atan2(
				Math.sin(bearing) * Math.sin(d) * Math.cos(lat1), 
				Math.cos(d) - Math.sin(lat1) * Math.sin(lat2)
		);
		
		//pointArray[x] = GeometryEngine.project(x, y, sr)
	}
}
 
Example 12
Source Project: VMLibrary   Source File: VMDimen.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取屏幕大小
 */
public static Point getScreenSize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point outSize = new Point();
    display.getSize(outSize);
    return outSize;
}
 
Example 13
Source Project: android_9.0.0_r45   Source File: ThreadedRenderer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the light center.
 */
public void setLightCenter(final Display display,
        final int windowLeft, final int windowTop) {
    // Adjust light position for window offsets.
    final Point displaySize = new Point();
    display.getRealSize(displaySize);
    final float lightX = displaySize.x / 2f - windowLeft;
    final float lightY = mLightY - windowTop;

    nSetLightCenter(mNativeProxy, lightX, lightY, mLightZ);
}
 
Example 14
Source Project: AcgClub   Source File: DimenUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Get the size of current screen.
 *
 * @param context the context
 * @return the size
 */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static Point getScreenSize(Context context) {
  WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = windowManager.getDefaultDisplay();
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
    return new Point(display.getWidth(), display.getHeight());
  } else {
    Point point = new Point();
    display.getSize(point);
    return point;
  }
}
 
Example 15
Source Project: za-Farmer   Source File: Gestures.java    License: MIT License 5 votes vote down vote up
/**
 * Returns an array of {@link PointerGesture}s representing a pinch close.
 *
 * @param bounds The area to pinch over.
 * @param percent The size of the pinch as a percentage of the total area.
 * @param speed The speed at which to move in pixels per second.
 * @return An array containing the two PointerGestures representing this pinch.
 */
public PointerGesture[] pinchClose(Rect area, float percent, int speed) {
    Point[] bottomLeft = new Point[2];
    Point[] topRight = new Point[2];
    calcPinchCoordinates(area, percent, bottomLeft, topRight);

    // A pinch close is a multi-point gesture composed of two swipes moving from the outer
    // coordinates to the inner ones.
    return new PointerGesture[] {
        swipe(bottomLeft[OUTER], bottomLeft[INNER], speed).pause(250),
        swipe(topRight[OUTER], topRight[INNER], speed).pause(250)
    };
}
 
Example 16
Source Project: Camera2Vision   Source File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
public static int getScreenHeight(Context c) {
    WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size.y;
}
 
Example 17
Source Project: AndroidHttpCapture   Source File: CameraManager.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
        }

        //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;
}
 
Example 18
Source Project: imsdk-android   Source File: BitmapSticker.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    gestureDetector.onTouchEvent(event);
    if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_POINTER_UP == event.getAction() || MotionEvent.ACTION_POINTER_1_UP == event.getAction() || MotionEvent.ACTION_POINTER_2_UP == event.getAction()) {
        setDoubleDownPoints(0, 0, 0, 0);
        lastDoubleDegress = 1000;
        lastDegree = computeDegree(new Point((int) dstPs[4], (int) dstPs[5]), new Point((int) dstPs[8], (int) dstPs[9]));
    }

    return !isOut;
}
 
Example 19
Source Project: DevUtils   Source File: CameraSizeAssist.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 根据手机支持的拍照分辨率计算, 设置预览尺寸
 * @param max        是否使用最大的尺寸
 * @param point      指定的尺寸 ( 为 null, 则使用屏幕尺寸 )
 *                   ( 从指定的宽高, 开始往下 ( 超过的不处理 ) 选择最接近尺寸 ) point.x = 宽, point.y = 高
 * @param distortion 偏差比例值
 * @return {@link Camera.Size} 拍照分辨率
 */
public Camera.Size getPictureSize(final boolean max, final Point point, final double distortion) {
    if (mCamera == null) {
        LogPrintUtils.dTag(TAG, "camera is null");
        return null;
    }
    try {
        // 计算大小并返回
        return calcPictureSize(max, point, distortion);
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getPictureSize");
    }
    return null;
}
 
Example 20
Source Project: JZAndroidChart   Source File: Chart.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Computes the current scrollable surface size, in pixels. For example, if the entire lib
 * area is visible, this is simply the current size of {@link #mContentRect}. If the lib
 * is zoomed in 200% in both directions, the returned size will be twice as large horizontally
 * and vertically.
 */
private void computeScrollSurfaceSize(Point out) {
    out.set((int) (mContentRect.width() * (Viewport.AXIS_X_MAX - Viewport.AXIS_X_MIN)
                    / mCurrentViewport.width()),
            (int) (mContentRect.height() * (Viewport.AXIS_Y_MAX - Viewport.AXIS_Y_MIN)
                    / mCurrentViewport.height()));
}
 
Example 21
Source Project: PdfViewPager   Source File: SubsamplingScaleImageView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected int[] doInBackground(Void... params) {
    try {
        String sourceUri = source.toString();
        Context context = contextRef.get();
        DecoderFactory<? extends ImageRegionDecoder> decoderFactory = decoderFactoryRef.get();
        SubsamplingScaleImageView view = viewRef.get();
        if (context != null && decoderFactory != null && view != null) {
            decoder = decoderFactory.make();
            Point dimensions = decoder.init(context, source);
            int sWidth = dimensions.x;
            int sHeight = dimensions.y;
            int exifOrientation = view.getExifOrientation(context, sourceUri);
            if (view.sRegion != null) {
                view.sRegion.left = Math.max(0, view.sRegion.left);
                view.sRegion.top = Math.max(0, view.sRegion.top);
                view.sRegion.right = Math.min(sWidth, view.sRegion.right);
                view.sRegion.bottom = Math.min(sHeight, view.sRegion.bottom);
                sWidth = view.sRegion.width();
                sHeight = view.sRegion.height();
            }
            return new int[]{sWidth, sHeight, exifOrientation};
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to initialise bitmap decoder", e);
        this.exception = e;
    }
    return null;
}
 
Example 22
Source Project: CircleFloatBar   Source File: BezierEvaluator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Point evaluate(float t, Point startValue, Point endValue) {
    int x = (int) ((1 - t) * (1 - t) * startValue.x + 2 * t * (1 - t) * controllPoint.x + t * t * endValue.x);
    int y = (int) ((1 - t) * (1 - t) * startValue.y + 2 * t * (1 - t) * controllPoint.y + t * t * endValue.y);
    curPoint.set(x, y);
    return curPoint;
}
 
Example 23
@Override
public void onConfigurationChanged (Configuration newConfig) {
	WindowManager wm = (WindowManager) this.context.getSystemService(Context.WINDOW_SERVICE);
	Display display = wm.getDefaultDisplay();
	Point dSize = new Point();
	display.getSize(dSize);
	this.sl1.displayWidth = this.sl2.displayWidth = this.sl3.displayWidth = dSize.x - iconSize - 5;
	this.invalidate();
}
 
Example 24
/**
 * 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;
    }
}
 
Example 25
Source Project: TurboLauncher   Source File: WallpaperPickerActivity.java    License: Apache License 2.0 5 votes vote down vote up
private DefaultWallpaperInfo getDefaultWallpaper() {
    File defaultThumbFile = new File(getFilesDir(), DEFAULT_WALLPAPER_THUMBNAIL_FILENAME);
    Bitmap thumb = null;
    boolean defaultWallpaperExists = false;
    if (defaultThumbFile.exists()) {
        thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath());
        defaultWallpaperExists = true;
    } else {
        // Delete old thumbnail file, since we had a bug where the thumbnail wasn't being drawn
        // before
        new File(getFilesDir(), OLD_DEFAULT_WALLPAPER_THUMBNAIL_FILENAME).delete();

        Resources res = getResources();
        Point defaultThumbSize = getDefaultThumbnailSize(res);
        Drawable wallpaperDrawable = WallpaperManager.getInstance(this).getBuiltInDrawable(
                defaultThumbSize.x, defaultThumbSize.y, true, 0.5f, 0.5f);
        if (wallpaperDrawable != null) {
            thumb = Bitmap.createBitmap(
                    defaultThumbSize.x, defaultThumbSize.y, Bitmap.Config.ARGB_8888);
            Canvas c = new Canvas(thumb);
            wallpaperDrawable.setBounds(0, 0, defaultThumbSize.x, defaultThumbSize.y);
            wallpaperDrawable.draw(c);
            c.setBitmap(null);
        }
        if (thumb != null) {
            defaultWallpaperExists = writeImageToFileAsJpeg(defaultThumbFile, thumb);
        }
    }
    if (defaultWallpaperExists) {
        return new DefaultWallpaperInfo(new BitmapDrawable(thumb));
    }
    return null;
}
 
Example 26
Source Project: ShareBox   Source File: QRCodeReaderView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Transform result to surfaceView coordinates
 * <p>
 * This method is needed because coordinates are given in landscape camera coordinates when
 * device is in portrait mode and different coordinates otherwise.
 *
 * @return a new PointF array with transformed points
 */
private PointF[] transformToViewCoordinates(QRCodeReaderView view, ResultPoint[] resultPoints) {
    int orientationDegrees = view.getCameraDisplayOrientation();
    Orientation orientation =
            orientationDegrees == 90 || orientationDegrees == 270 ? Orientation.PORTRAIT
                    : Orientation.LANDSCAPE;
    Point viewSize = new Point(view.getWidth(), view.getHeight());
    Point cameraPreviewSize = view.mCameraManager.getPreviewSize();
    boolean isMirrorCamera =
            view.mCameraManager.getPreviewCameraId() == Camera.CameraInfo.CAMERA_FACING_FRONT;

    return qrToViewPointTransformer.transform(resultPoints, isMirrorCamera, orientation, viewSize,
            cameraPreviewSize);
}
 
Example 27
Source Project: snowplow-android-tracker   Source File: Subject.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the default screen resolution
 * of the device the Tracker is running
 * on.
 *
 * @param context the android context
 */
@SuppressWarnings("deprecation")
public void setDefaultScreenResolution(Context context) {
    WindowManager windowManager =
            (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);
        this.setScreenResolution(size.x, size.y);
    } else {
        this.setScreenResolution(display.getWidth(), display.getHeight());
    }
}
 
Example 28
Source Project: FireFiles   Source File: AppsProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public AssetFileDescriptor openDocumentThumbnail(
        String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException {
    // TODO: extend ExifInterface to support fds
    final ParcelFileDescriptor pfd = openDocument(docId, "r", signal);
    return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
}
 
Example 29
Source Project: CustomViewSets   Source File: CustomBasicOpView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mWidth = w;
    mHeight = h;
    startXYPoint = new Point(mWidth/2-rectWidth/2, 3 * margin + padding + DensityUtils.sp2px(getContext(), 16));
    endXPoint = new Point(mWidth - (3 * margin + padding), 3 * margin + padding + DensityUtils.sp2px(getContext(), 16));
    endYPoint = new Point(3 * margin + padding, mHeight - (3 * margin + padding + DensityUtils.sp2px(getContext(), 16)));
}
 
Example 30
public static Point getShiftedPoint(@NonNull Point referencePoint, double distanceInPixels, double bearing) {
    double angleInRadians = Math.toRadians(bearing + 90);
    return new Point(
            (int) (referencePoint.x - (distanceInPixels * Math.cos(angleInRadians))),
            (int) (referencePoint.y - (distanceInPixels * Math.sin(angleInRadians)))
    );
}