Java Code Examples for android.graphics.Point

The following are top voted examples for showing how to use android.graphics.Point. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: mupdf-android-viewer-old   File: MuPDFReflowView.java   Source Code and License 7 votes vote down vote up
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);
		}
	});
}
 
Example 2
Project: tvConnect_android   File: CameraManager.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example 3
Project: limitjson   File: LinearGraphView.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 4
Project: SmartButler   File: CameraConfigurationManager.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 5
Project: android-mrz-reader   File: CameraConfigurationManager.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 6
Project: shortrain   File: PathParser.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 7
Project: CodeScaner   File: CameraManager.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 8
Project: Bigbang   File: ViewUtil.java   Source Code and License 6 votes vote down vote up
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;
        }
    }
}
 
Example 9
Project: Android-LineChart   File: LineChartView.java   Source Code and License 6 votes vote down vote up
/**
 * 绘制曲线上的锚点
 *
 * @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);
    }
}
 
Example 10
Project: PiPle   File: Window.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 11
Project: AirPanel   File: MainActivity.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 12
Project: GitHub   File: CameraManager.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 13
Project: Rudeness   File: RudenessScreenHelper.java   Source Code and License 6 votes vote down vote up
/**
 * 重新计算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;
}
 
Example 14
Project: AndroFish   File: AndroidFishEatingFish.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 15
Project: CubeLoadingView   File: CubeLoadingView.java   Source Code and License 6 votes vote down vote up
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<>();
    }
}
 
Example 16
Project: EZFilter   File: FitViewHelper.java   Source Code and License 6 votes vote down vote up
/**
 * 计算预览区域大小
 *
 * @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;
}
 
Example 17
Project: seeta4Android   File: MyApplication.java   Source Code and License 6 votes vote down vote up
/**
 * 获取最佳预览大小
 * @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);
}
 
Example 18
Project: tvConnect_android   File: CameraConfigurationManager.java   Source Code and License 6 votes vote down vote up
/**
   * 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);
  }
 
Example 19
Project: tvConnect_android   File: PreviewCallback.java   Source Code and License 5 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);
    message.sendToTarget();
    previewHandler = null;
  } else {
    Log.d(TAG, "Got preview callback, but no handler or resolution available");
  }
}
 
Example 20
Project: Hitalk   File: CameraConfigurationManager.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 21
Project: TPlayer   File: CameraConfigurationManager.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 22
Project: mupdf-android-viewer-nui   File: DocPageView.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 23
Project: P2Video-master   File: GifSizeFilter.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 24
Project: AssistantBySDK   File: NaviConfirmPointActivity.java   Source Code and License 5 votes vote down vote up
/**
 * 设置检索结果显示索引(若有多个结果则地图缩放到保证所有结果可见)
 **/
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();
}
 
Example 25
Project: letv   File: CameraManager.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 26
Project: martian-cli   File: CommonUtils.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 27
Project: AdronEngine   File: Touch.java   Source Code and License 5 votes vote down vote up
/**
 * @param onTouchListener interface implemented in activity
 */
public Touch(IOnTouchListener onTouchListener) {
    this.mOnTouchListener = onTouchListener;
    numOfTouches = 0;
    isBeingTouch = false;
    this.mPoint = new Point();
}
 
Example 28
Project: APIJSON-Android-RxJava   File: CameraConfigurationManager.java   Source Code and License 5 votes vote down vote up
/**
	 * 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);>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	}
 
Example 29
Project: editor-sql   File: Utils.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 30
Project: https-github.com-hyb1996-NoRootScriptDroid   File: ColorFinder.java   Source Code and License 5 votes vote down vote up
@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();
    }
}
 
Example 31
Project: zxing_qrcode_demo   File: PreviewCallback.java   Source Code and License 5 votes vote down vote up
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");
    }
}
 
Example 32
Project: GravityBox   File: GravityBoxSettings.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 33
Project: SmartRefresh   File: FunGameBattleCityHeader.java   Source Code and License 5 votes vote down vote up
/**
 * 判断是否消灭敌方坦克
 * @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;
}
 
Example 34
Project: social-journal   File: SocialJournalAdapter.java   Source Code and License 5 votes vote down vote up
/**
 * 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();
}
 
Example 35
Project: BarcodeReaderView   File: CameraManager.java   Source Code and 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;
        }

        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;
}
 
Example 36
Project: APIJSON-Android-RxJava   File: PreviewCallback.java   Source Code and License 5 votes vote down vote up
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");
  }
}
 
Example 37
Project: GonioView   File: GonioView.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 38
Project: QuickActionView   File: QuickActionView.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
}
 
Example 39
Project: NoticeDog   File: DragSortController.java   Source Code and License 5 votes vote down vote up
/**
 * 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 40
Project: RLibrary   File: TurnLayoutManager.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 41
Project: android-api   File: Positioner.java   Source Code and License 5 votes vote down vote up
/**
 * @eegeo.internal
 */
@UiThread
void setProjectedState(
        Point screenPoint,
        LatLngAlt transformedPoint,
        boolean isBehindGlobeHorizon
) {
    boolean changed=false;
    boolean isScreenPointValid = (screenPoint != null);
    boolean isTransformedPointValid = (transformedPoint != null);

    if (isScreenPointValid != m_isScreenPointValid) {
        m_isScreenPointValid = isScreenPointValid;
        changed = true;
    }

    if (isScreenPointValid && !m_screenPoint.equals(screenPoint)) {
        m_screenPoint.set(screenPoint.x, screenPoint.y);
        changed = true;
    }


    if (isTransformedPointValid != m_isTransformedPointValid) {
        m_isTransformedPointValid = isTransformedPointValid;
        changed = true;
    }

    if (isTransformedPointValid && !m_transformedPoint.equals(transformedPoint)) {
        m_transformedPoint = transformedPoint;
        changed = true;
    }

    if (m_isBehindGlobeHorizon != isBehindGlobeHorizon) {
        m_isBehindGlobeHorizon = isBehindGlobeHorizon;
        changed = true;
    }
}
 
Example 42
Project: DualSeekBar   File: DualSeekBar.java   Source Code and License 5 votes vote down vote up
private void drawThumbs(Canvas canvas) {
    Point leftThumbCenter = instrumentation.getPoint(PoolKeyHolder.LEFT_THUMB_CENTER);
    Point rightThumbCenter = instrumentation.getPoint(PoolKeyHolder.RIGHT_THUMB_CENTER);

    drawBitmapAtCenter(canvas, leftThumbDrawable, leftThumbCenter);
    drawBitmapAtCenter(canvas, rightThumbDrawable, rightThumbCenter);
}
 
Example 43
Project: Android-LineChart   File: LineChartView.java   Source Code and License 5 votes vote down vote up
/**
 * 初始化曲线数据
 */
private void setupLine() {
    if (dataList.isEmpty()) return;

    int stepTemp = getTableStart();
    Point pre = new Point();
    pre.set(stepTemp, -getValueHeight(dataList.get(0).getValue()));//坐标系从0,0默认在第四象限绘制
    linePoints[0] = pre;
    linePath.moveTo(pre.x, pre.y);

    if (dataList.size() == 1) {
        isInitialized = true;
        return;
    }

    for (int i = 1; i < dataList.size(); i++) {
        Data data = dataList.get(i);
        Point next = new Point();
        next.set(stepTemp += stepSpace, -getValueHeight(data.getValue()));

        if (isBezierLine) {
            int cW = pre.x + stepSpace / 2;

            Point p1 = new Point();//控制点1
            p1.set(cW, pre.y);

            Point p2 = new Point();//控制点2
            p2.set(cW, next.y);

            linePath.cubicTo(p1.x, p1.y, p2.x, p2.y, next.x, next.y);//创建三阶贝塞尔曲线
        } else {
            linePath.lineTo(next.x, next.y);
        }

        pre = next;
        linePoints[i] = next;
    }

    isInitialized = true;
}
 
Example 44
Project: BezierView   File: GoodsView.java   Source Code and License 5 votes vote down vote up
/**
 * @param t   当前动画进度
 * @param startValue 开始值
 * @param endValue   结束值
 * @return
 */
@Override
public Object evaluate(float t, Object startValue, Object endValue) {

    Point startPoint = (Point) startValue;
    Point endPoint = (Point) endValue;

    int x = (int) (Math.pow((1-t),2)*startPoint.x+2*(1-t)*t*mCircleConPoint.x+Math.pow(t,2)*endPoint.x);
    int y = (int) (Math.pow((1-t),2)*startPoint.y+2*(1-t)*t*mCircleConPoint.y+Math.pow(t,2)*endPoint.y);

    return new Point(x,y);
}
 
Example 45
Project: FloatingNew   File: ScreenShortActivity.java   Source Code and License 5 votes vote down vote up
/****************************************** Factoring Virtual Display creation ****************/
private void createVirtualDisplay() {
    // get width and height

    final Point windowSize = new Point();
    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getRealSize(windowSize);

    mWidth = windowSize.x;
    mHeight = windowSize.y;
    // start capture reader
    mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 2);
    mVirtualDisplay = sMediaProjection.createVirtualDisplay("FloSo", mWidth, mHeight, mDensity, VIRTUAL_DISPLAY_FLAGS, mImageReader.getSurface(), null, mHandler);
    mImageReader.setOnImageAvailableListener(new ImageAvailableListener(), mHandler);
}
 
Example 46
Project: simple-share-android   File: DocumentsApplication.java   Source Code and License 5 votes vote down vote up
public static ThumbnailCache getThumbnailsCache(Context context, Point size) {
    final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext();
    final ThumbnailCache thumbnails = app.mThumbnails;
    if (!size.equals(app.mThumbnailsSize)) {
        thumbnails.evictAll();
        app.mThumbnailsSize = size;
    }
    return thumbnails;
}
 
Example 47
Project: ModPE-IDE-Source   File: LModEditor.java   Source Code and License 5 votes vote down vote up
protected void init(Context context) {
       setLayoutParams(new LinearLayout.LayoutParams(
               ViewGroup.LayoutParams.MATCH_PARENT,
               ViewGroup.LayoutParams.MATCH_PARENT));
       setLayerType(View.LAYER_TYPE_SOFTWARE, null);
       setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE
               | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
       mGestureDetector = new GestureDetector(getContext(), this);
       mGestureDetector.setIsLongpressEnabled(true);
       mScroller = new Scroller(getContext(), null, false);
       mWindowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
       mRotation = mWindowManager.getDefaultDisplay().getRotation();
       mDrawingRect = new Rect();
       mLineBounds = new Rect();
       mScrollMax = new Point();
       mPaintNumbers = new Paint();
       mPaintNumbers.setAntiAlias(true);
       mPaintNumbers.setDither(false);
       mPaintHighlight = new Paint();
mPaintHighlight.setStyle(Style.FILL);
       mPadding = (int) (6.0f * context.getResources().getDisplayMetrics().density);
       mScrollDirection = 0;
       setHorizontallyScrolling(true);
       addTextChangedListener(new EditTextChangeListener());
       mUndoRedoHelper = new UndoRedoHelper(this);
       mUndoRedoHelper.setMaxHistorySize(MAX_HISTORY_SIZE);
       setOnKeyListener(this);
       postInvalidate();
       refreshDrawableState();
       invalidateCharHeight();
   }
 
Example 48
Project: qmui   File: QMUIProgressBar.java   Source Code and License 5 votes vote down vote up
private void configShape() {
    if (mType == TYPE_RECT) {
        mBgRect = new RectF(getPaddingLeft(), getPaddingTop(), mWidth + getPaddingLeft(), mHeight + getPaddingTop());
        mProgressRect = new RectF();
    } else {
        mCircleRadius = (Math.min(mWidth, mHeight) - mStrokeWidth) / 2;
        mCenterPoint = new Point(mWidth / 2, mHeight / 2);
    }
}
 
Example 49
Project: SmartButler   File: CameraConfigurationManager.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 50
Project: easyfilemanager   File: DetailFragment.java   Source Code and License 5 votes vote down vote up
@Override
protected Void doInBackground(Void... params) {
	filePath = doc.path;

	if (!Utils.isDir(doc.mimeType)) {
              final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, doc.mimeType);
		int thumbSize = getResources().getDimensionPixelSize(R.dimen.grid_width);
		Point mThumbSize = new Point(thumbSize, thumbSize);
		final Uri uri = DocumentsContract.buildDocumentUri(doc.authority, doc.documentId);
		final Context context = getActivity();
		final ContentResolver resolver = context.getContentResolver();
		ContentProviderClient client = null;
		try {

			if (doc.mimeType.equals(Document.MIME_TYPE_APK) && !TextUtils.isEmpty(filePath)) {
				result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context, filePath, Document.MIME_TYPE_APK)).getBitmap();
			} else {
				client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, uri.getAuthority());
				result = DocumentsContract.getDocumentThumbnail(resolver, uri, mThumbSize, null);
			}
		} catch (Exception e) {
			if (!(e instanceof OperationCanceledException)) {
				Log.w(TAG_DETAIL, "Failed to load thumbnail for " + uri + ": " + e);
			}
			CrashReportingManager.logException(e);
		} finally {
			ContentProviderClientCompat.releaseQuietly(client);
		}

		sizeString = Formatter.formatFileSize(context, doc.size);
	}
	else{
		if(!TextUtils.isEmpty(filePath)){
			File dir = new File(filePath);
			sizeString = Formatter.formatFileSize(getActivity(), Utils.getDirectorySize(dir));
		}				
	}
	
	return null;
}
 
Example 51
Project: androidscan   File: PreviewCallback.java   Source Code and License 5 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);
        message.sendToTarget();
        previewHandler = null;
    } else {
        Log.d(TAG, "Got preview callback, but no handler or resolution available");
    }
}
 
Example 52
Project: ucar-weex-core   File: WXGesture.java   Source Code and License 5 votes vote down vote up
public WXGesture(WXComponent wxComponent, Context context) {
  this.component = wxComponent;
  globalRect = new Rect();
  globalOffset = new Point();
  globalEventOffset = new Point();
  locEventOffset = new PointF();
  locLeftTop = new PointF();
  mGestureDetector = new GestureDetector(context, this, new GestureHandler());
  Scrollable parentScrollable = wxComponent.getParentScroller();
  if(parentScrollable != null) {
    mParentOrientation = parentScrollable.getOrientation();
  }
}
 
Example 53
Project: Selector   File: DisplayUrils.java   Source Code and License 5 votes vote down vote up
public static float getScreenRate(Context context){
    Point P = getScreenMetrics(context);
    float H = P.y;
    float W = P.x;
    Log.i("getScreenRate", "getScreenRate"+"h="+H+"W="+W);
    return (H/W);
}
 
Example 54
Project: whiteblackgame   File: WhiteBlack.java   Source Code and License 5 votes vote down vote up
/**
 * 判断棋子是否左斜相邻五个一致
 * @param x
 * @param y
 * @param points
 * @return
 */
private boolean checkLeftDiagonal(int x,int y,List<Point> points){

    int count=1;

    //向下数
    for (int i=1;i<MAX_COUNT_IN_LINE;i++){
        if (points.contains(new Point(x-i,y+i))){
            count++;
        }else {
            break;
        }
    }

    if (count==MAX_COUNT_IN_LINE) return true;

    //向上数
    for (int i=1;i<MAX_COUNT_IN_LINE;i++){
        if (points.contains(new Point(x+i,y-i))){
            count++;
        }else {
            break;
        }
    }

    if (count==MAX_COUNT_IN_LINE) return true;

    return false;
}
 
Example 55
Project: yyox   File: ScreenUtils.java   Source Code and License 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 out = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(out);
    }else{
        int width = display.getWidth();
        int height = display.getHeight();
        out.set(width, height);
    }
    return out;
}
 
Example 56
Project: FireFiles   File: IconHelper.java   Source Code and License 5 votes vote down vote up
public LoaderTask(Uri uri, String path, String mime,
        Point thumbSize, ImageView iconThumb, ImageView iconMime, View iconMimeBackground) {
    mUri = uri;
    mIconThumb = iconThumb;
    mIconMime = iconMime;
    mThumbSize = thumbSize;
    mIconMimeBackground = iconMimeBackground;
    mimeType = mime;
    mSignal = new CancellationSignal();
    mPath = path;
}
 
Example 57
Project: PDR   File: BackgroundView.java   Source Code and License 5 votes vote down vote up
private void drawDpLine(Canvas canvas,Point[] points,Paint paint){
		//�����������ֻ��������������绪Ϊ��mate2Ϊ2,LG������nexus5Ϊ3�����Ժ�����С��λ�Ŀ��ܻ�������
//		int den = (int) density;
		int den = 3;
		//�����imageview��ԭ����ƽ��һ��(50,30)
		int len = points.length;
		for(int count=0; count < (len-1) ;count++){
			x=(points[count].x+50)*den;
			y=(points[count].y+30)*den;
			int x_next = (points[count+1].x+50)*den;
			int y_next = (points[count+1].y+30)*den;
			canvas.drawLine(x, y, x_next, y_next, paint);
		}
	}
 
Example 58
Project: easyfilemanager   File: DocumentsApplication.java   Source Code and License 5 votes vote down vote up
public static ThumbnailCache getThumbnailsCache(Context context, Point size) {
    final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext();
    final ThumbnailCache thumbnails = app.mThumbnails;
    if (!size.equals(app.mThumbnailsSize)) {
        thumbnails.evictAll();
        app.mThumbnailsSize = size;
    }
    return thumbnails;
}
 
Example 59
Project: FlickLauncher   File: GridSizeMigrationTaskTest.java   Source Code and License 5 votes vote down vote up
public MultiStepMigrationTaskVerifier(int... points) {
    super(null, null);

    mPoints = new LinkedList<>();
    for (int i = 0; i < points.length; i += 2) {
        mPoints.add(new Point(points[i], points[i + 1]));
    }
}
 
Example 60
Project: GitHub   File: GridImgAdapter.java   Source Code and License 5 votes vote down vote up
public GridImgAdapter(Context context, ArrayList<String> imagePathList, int column) {
        this.context = context;
        this.imagePathList = imagePathList;
        int width = 0;
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            Point size = new Point();
            wm.getDefaultDisplay().getSize(size);
            width = size.x;
        } else {
            width = wm.getDefaultDisplay().getWidth();
        }
        mGridWidth = width / column;
//        mImages=new HashMap<>();
    }