List of usage examples for android.graphics Rect width
public final int width()
From source file:im.afterclass.android.fragment.ChatHistoryFragment.java
private void showLeftPopupWindow(View v) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View parent = getActivity().findViewById(R.id.main_button); View view = inflater.inflate(R.layout.half_popupwindow, null); String[] themes = new String[] { "?", "??", "" }; List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>(); for (int i = 0; i < themes.length; i++) { Map<String, Object> listItem = new HashMap<String, Object>(); listItem.put("theme", themes[i]); listItems.add(listItem);/* w ww. j a v a 2 s . co m*/ } SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), listItems, R.layout.theme_simple_item, new String[] { "theme" }, new int[] { R.id.theme }); ListView themelist = (ListView) view.findViewById(R.id.themeListView); themelist.setAdapter(simpleAdapter); themelist.setOnItemClickListener(new ItemClickListener()); mPopupWindow = new PopupWindow(view); view.startAnimation(animSlideLeftin); DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); int screenHeight = dm.heightPixels; int[] location = new int[2]; parent.getLocationInWindow(location); Rect frame = new Rect(); getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; int width = frame.width(); mPopupWindow.setHeight(location[1] - getActivity().getActionBar().getHeight() - statusBarHeight); mPopupWindow.setWidth(width / 2); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.showAtLocation(getActivity().findViewById(R.id.main_bottom), Gravity.BOTTOM | Gravity.LEFT, 0, screenHeight - location[1]); }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Fill the moneybox with all the movements dropping coins randomly */// w ww . j a v a 2s . c o m public void fillMoneybox() { RelativeLayout layout; int maxWidth; ArrayList<Movement> lstMoney; Random rndLeft; double total; int i; MainActivity parent; parent = (MainActivity) getActivity(); layout = findLayout(); maxWidth = layout.getWidth(); if (maxWidth == 0) { // The layout is not initialized return; } total = 0.0; i = 0; rndLeft = new Random(); lstMoney = MovementsManager.getActiveMovements(parent.getCurrentMoneybox()); for (Movement m : lstMoney) { Rect r; CurrencyValueDef curr; int left; curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount())); if (curr != null) { r = curr.getDrawable().getBounds(); left = rndLeft.nextInt(maxWidth - r.width()); total += m.getAmount(); MoneyTimerTask task; task = new MoneyTimerTask(this, m, left, r.width(), total); layout.postDelayed(task, 400 * i); } i++; } }
From source file:com.dastanapps.camera2.view.Cam2AutoFitTextureView.java
protected void pinchToZoom(MotionEvent event) { maximumZoomLevel = mCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) * 10; Rect rect = mCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); float currentFingerSpacing; if (event.getPointerCount() > 1) { // Multi touch logic currentFingerSpacing = getFingerSpacing(event); if (fingerSpacing != 0) { if (currentFingerSpacing > fingerSpacing && maximumZoomLevel > zoomLevel) { zoomLevel = zoomLevel + .4; } else if (currentFingerSpacing < fingerSpacing && zoomLevel > 1) { zoomLevel = zoomLevel - .4; }//from w w w . j av a 2 s . c o m int minW = (int) (rect.width() / maximumZoomLevel); int minH = (int) (rect.height() / maximumZoomLevel); int difW = rect.width() - minW; int difH = rect.height() - minH; int cropW = difW / 100 * (int) zoomLevel; int cropH = difH / 100 * (int) zoomLevel; cropW -= cropW & 3; cropH -= cropH & 3; Rect zoom = new Rect(cropW, cropH, rect.width() - cropW, rect.height() - cropH); mPreviewBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoom); } fingerSpacing = currentFingerSpacing; } }
From source file:com.waz.zclient.pages.main.drawing.DrawingFragment.java
private ImageAsset getFinalSketchImage() { Bitmap finalBitmap = getBitmapDrawing(); try {/*from w w w . j a va 2s .c o m*/ Rect bitmapTrim = drawingCanvasView.getImageTrimValues(); MemoryImageCache.reserveImageMemory(bitmapTrim.width(), bitmapTrim.height()); finalBitmap = Bitmap.createBitmap(finalBitmap, bitmapTrim.left, bitmapTrim.top, bitmapTrim.width(), bitmapTrim.height()); } catch (Throwable t) { // ignore } return ImageAssetFactory.getImageAsset(finalBitmap, ExifInterface.ORIENTATION_NORMAL); }
From source file:com.slushpupie.deskclock.DeskClock.java
private void resizeClock() { Log.d(LOG_TAG, "resizeClock() called"); // determine largest digit char bdigit = digitcharset[0]; Rect bb = getBoundingBox(String.valueOf(bdigit), fonts[prefsFont], 10); int w = bb.width(); for (int i = 1; i < digitcharset.length; i++) { bb = getBoundingBox(String.valueOf(digitcharset[i]), fonts[prefsFont], 10); if (bb.width() > w) { bdigit = digitcharset[i];/*from ww w . ja va 2 s . c o m*/ w = bb.width(); } } // determine largest letter char bletter = lettercharset[0]; bb = getBoundingBox(String.valueOf(bletter), fonts[prefsFont], 10); w = bb.width(); for (int i = 1; i < lettercharset.length; i++) { bb = getBoundingBox(String.valueOf(lettercharset[i]), fonts[prefsFont], 10); if (bb.width() > w) { bletter = lettercharset[i]; w = bb.width(); } } String str = String.format("%c%c:%c%c", bdigit, bdigit, bdigit, bdigit); if (prefsShowSeconds) str = String.format("%s:%c%c", str, bdigit, bdigit); if (prefsShowMeridiem) str = String.format("%s %cM", str, bletter); Rect boundingBox = new Rect(0, 0, displayWidth - 5, displayHeight - 5); float fontSize = fitTextToRect(fonts[prefsFont], str, boundingBox); if (prefsScale != 100) { fontSize = fontSize * (0.01f * ((float) prefsScale)); } if (prefsScreenSaver) { fontSize = fontSize * 0.8f; } int leftPadding = 0; Rect digitBounds = getBoundingBox("8", fonts[prefsFont], fontSize); int width = digitBounds.width(); leftPadding = width * -4; display.setWideTime(str); display.setFont(fonts[prefsFont]); display.setPadding(leftPadding, 0, 0, 0); display.setSize(fontSize); needsResizing = false; display.setTime(""); }
From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java
private void makePathBubble() { if (mPathBubble == null) { mPathBubble = new Path(); }//from ww w . j a v a 2 s . co m int width = mBubbleWidth; int height = mBubbleHeight; int arrowWidth = width / 3; //Rect r = new Rect(Math.max(getPaddingLeft()-width/2-arrowWidth/4, mProgress*mWidth/100-width/2-arrowWidth/4), mHeight/2-height + calculatedeltaY(), Math.max(getPaddingLeft()+width/2-arrowWidth/4, mProgress*mWidth/100+width/2-arrowWidth/4), mHeight/2+height-height + calculatedeltaY()); Rect r = new Rect((int) (Math.max(getPaddingLeft() - width / 2, mProgress * mWidth / 100 - width / 2)), (int) (mHeight / 2 - height + calculateDeltaY()), (int) (Math.max(getPaddingLeft() + width / 2, mProgress * mWidth / 100 + width / 2)), (int) (mHeight / 2 + height - height + calculateDeltaY())); int arrowHeight = (int) (arrowWidth / 1.5f); int radius = 8; Path path = new Path(); // Down arrow path.moveTo(r.left + r.width() / 2 - arrowWidth / 2, r.top + r.height() - arrowHeight); bubbleAnchorX = r.left + r.width() / 2; bubbleAnchorY = r.top + r.height(); path.lineTo(bubbleAnchorX, bubbleAnchorY); path.lineTo(r.left + r.width() / 2 + arrowWidth / 2, r.top + r.height() - arrowHeight); // Go to bottom-right path.lineTo(r.left + r.width() - radius, r.top + r.height() - arrowHeight); // Bottom-right arc path.arcTo(new RectF(r.left + r.width() - 2 * radius, r.top + r.height() - arrowHeight - 2 * radius, r.left + r.width(), r.top + r.height() - arrowHeight), 90, -90); // Go to upper-right path.lineTo(r.left + r.width(), r.top + arrowHeight); // Upper-right arc path.arcTo(new RectF(r.left + r.width() - 2 * radius, r.top, r.right, r.top + 2 * radius), 0, -90); // Go to upper-left path.lineTo(r.left + radius, r.top); // Upper-left arc path.arcTo(new RectF(r.left, r.top, r.left + 2 * radius, r.top + 2 * radius), 270, -90); // Go to bottom-left path.lineTo(r.left, r.top + r.height() - arrowHeight - radius); // Bottom-left arc path.arcTo(new RectF(r.left, r.top + r.height() - arrowHeight - 2 * radius, r.left + 2 * radius, r.top + r.height() - arrowHeight), 180, -90); path.close(); mPathBubble.set(path); }
From source file:vc908.stickerfactory.ui.advancedrecyclerview.swipeable.RemovingItemDecorator.java
private void fillSwipingItemBackground(Canvas c, Drawable drawable, int height) { final Rect bounds = mSwipingItemBounds; final int translationX = mInitialTranslationX; final int translationY = mTranslationY; if (height < 0) { height = bounds.height();/* w w w.j av a 2 s . c o m*/ } if ((height == 0) || (drawable == null)) { return; } final int savedCount = c.save(); c.clipRect(bounds.left + translationX, bounds.top + translationY, bounds.right + translationX, bounds.top + translationY + height); // c.drawColor(0xffff0000); // <-- debug c.translate(bounds.left + translationX, bounds.top + translationY - (bounds.height() - height) / 2); drawable.setBounds(0, 0, bounds.width(), bounds.height()); drawable.draw(c); c.restoreToCount(savedCount); }
From source file:com.android.utils.traversal.DirectionalTraversalStrategy.java
/** * Given a focus rectangle, returns another rectangle that is placed at the beginning of the * row or column of the focused object, depending on the direction in which we are navigating. * * Example://from w w w. ja v a 2 s . com * <pre> * +---------+ * | | node=# * A| # | When direction=TraversalStrategy.SEARCH_FOCUS_RIGHT, then a rectangle A with * | | same width and height as node gets returned. * | | When direction=TraversalStrategy.SEARCH_FOCUS_UP, then a rectangle B with same * +---------+ width and height as node gets returned. * B * </pre> */ private void getSearchStartRect(AccessibilityNodeInfoCompat node, int direction, Rect rect) { Rect focusedRect = new Rect(); node.getBoundsInScreen(focusedRect); Rect rootBounds = new Rect(); mRoot.getBoundsInScreen(rootBounds); switch (direction) { case TraversalStrategy.SEARCH_FOCUS_LEFT: // Start from right and move leftwards. rect.set(rootBounds.right, focusedRect.top, rootBounds.right + focusedRect.width(), focusedRect.bottom); break; case TraversalStrategy.SEARCH_FOCUS_RIGHT: // Start from left and move rightwards. rect.set(rootBounds.left - focusedRect.width(), focusedRect.top, rootBounds.left, focusedRect.bottom); break; case TraversalStrategy.SEARCH_FOCUS_UP: // Start from bottom and move upwards. rect.set(focusedRect.left, rootBounds.bottom, focusedRect.right, rootBounds.bottom + focusedRect.height()); break; case TraversalStrategy.SEARCH_FOCUS_DOWN: // Start from top and move downwards. rect.set(focusedRect.left, rootBounds.top - focusedRect.height(), focusedRect.right, rootBounds.top); break; default: throw new IllegalArgumentException("direction must be a SearchDirection"); } }
From source file:com.acious.android.paginationseekbar.PaginationSeekBar.java
private void updateProgressFromAnimation(float scale) { Rect bounds = mThumb.getBounds(); int halfThumb = bounds.width() / 2; int addedThumb = mAddedTouchBounds; int left = getPaddingLeft() + halfThumb + addedThumb; int right = getWidth() - (getPaddingRight() + halfThumb + addedThumb); int available = right - left; int progress = Math.round((scale * (mMax - mMin)) + mMin); //we don't want to just call setProgress here to avoid the animation being cancelled, //and this position is not bound to a real progress value but interpolated if (progress != getProgress()) { mValue = progress;//w w w . ja v a 2 s . c o m notifyProgress(mValue, true); updateProgressMessage(progress); } final int thumbPos = (int) (scale * available + 0.5f); updateThumbPos(thumbPos); }
From source file:com.acious.android.paginationseekbar.PaginationSeekBar.java
private void updateDragging(MotionEvent ev) { setHotspot(ev.getX(), ev.getY());//from w w w. ja va 2 s. co m int x = (int) ev.getX(); Rect oldBounds = mThumb.getBounds(); int halfThumb = oldBounds.width() / 2; int addedThumb = mAddedTouchBounds; int newX = x - mDragOffset + halfThumb; int left = getPaddingLeft() + halfThumb + addedThumb; int right = getWidth() - (getPaddingRight() + halfThumb + addedThumb); if (newX < left) { newX = left; } else if (newX > right) { newX = right; } int available = right - left; float scale = (float) (newX - left) / (float) available; if (isRtl()) { scale = 1f - scale; } int progress = Math.round((scale * (mMax - mMin)) + mMin); setProgress(progress, true); }