List of usage examples for android.graphics Rect height
public final int height()
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public int[] estimateItemSize(int hSpan, int vSpan, ItemInfoBean itemInfo, boolean springLoaded) { int[] size = new int[2]; if (getChildCount() > 0) { // Use the first non-custom page to estimate the child position CellLayout cl = (CellLayout) getChildAt(numCustomPages()); Rect r = estimateItemPosition(cl, itemInfo, 0, 0, hSpan, vSpan); size[0] = r.width();// www. jav a 2 s .co m size[1] = r.height(); if (springLoaded) { size[0] *= mSpringLoadedShrinkFactor; size[1] *= mSpringLoadedShrinkFactor; } return size; } else { size[0] = Integer.MAX_VALUE; size[1] = Integer.MAX_VALUE; return size; } }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
public int[] estimateItemSize(ItemInfo itemInfo, boolean springLoaded) { int[] size = new int[2]; if (getChildCount() > 0) { // Use the first non-custom page to estimate the child position CellLayout cl = (CellLayout) getChildAt(numCustomPages()); Rect r = estimateItemPosition(cl, itemInfo, 0, 0, itemInfo.spanX, itemInfo.spanY); size[0] = r.width();//from ww w .j ava 2 s.c om size[1] = r.height(); if (springLoaded) { size[0] *= mSpringLoadedShrinkFactor; size[1] *= mSpringLoadedShrinkFactor; } return size; } else { size[0] = Integer.MAX_VALUE; size[1] = Integer.MAX_VALUE; return size; } }
From source file:xyz.klinker.blur.launcher3.Workspace.java
public int[] estimateItemSize(ItemInfo itemInfo, boolean springLoaded) { int[] size = new int[2]; if (getChildCount() > 0) { // Use the first non-custom page to estimate the child position CellLayout cl = (CellLayout) getChildAt(numCustomPages()); Rect r = estimateItemPosition(cl, 0, 0, itemInfo.spanX, itemInfo.spanY); size[0] = r.width();/*from w w w .j av a 2 s . com*/ size[1] = r.height(); if (springLoaded) { size[0] *= mSpringLoadedShrinkFactor; size[1] *= mSpringLoadedShrinkFactor; } return size; } else { size[0] = Integer.MAX_VALUE; size[1] = Integer.MAX_VALUE; return size; } }
From source file:com.zyk.launcher.Workspace.java
public void onExternalDragStartedWithItem(View v) { // Compose a drag bitmap with the view scaled to the icon size LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); int iconSize = grid.iconSizePx; int bmpWidth = v.getMeasuredWidth(); int bmpHeight = v.getMeasuredHeight(); // If this is a text view, use its drawable instead if (v instanceof TextView) { TextView tv = (TextView) v;// w w w . ja v a 2 s. co m Drawable d = tv.getCompoundDrawables()[1]; Rect bounds = Utils.getDrawableBounds(d); bmpWidth = bounds.width(); bmpHeight = bounds.height(); } // Compose the bitmap to create the icon from Bitmap b = Bitmap.createBitmap(bmpWidth, bmpHeight, Bitmap.Config.ARGB_8888); mCanvas.setBitmap(b); Utils.drawDragView(v, mCanvas, 0); mCanvas.setBitmap(null); // The outline is used to visualize where the item will land if dropped mDragOutline = createDragOutline(b, DRAG_BITMAP_PADDING, iconSize, iconSize, true); }
From source file:com.klinker.android.launcher.launcher3.Workspace.java
int getOverviewModeTranslationY() { DeviceProfile grid = mLauncher.getDeviceProfile(); Rect overviewBar = grid.getOverviewModeButtonBarRect(); int availableHeight = getViewportHeight(); int scaledHeight = (int) (mOverviewModeShrinkFactor * getNormalChildHeight()); int offsetFromTopEdge = (availableHeight - scaledHeight) / 2; int offsetToCenterInOverview = (availableHeight - mInsets.top - overviewBar.height() - scaledHeight) / 2; return -offsetFromTopEdge + mInsets.top + offsetToCenterInOverview; }
From source file:cc.flydev.launcher.Workspace.java
private void getFinalPositionForDropAnimation(int[] loc, float[] scaleXY, DragView dragView, CellLayout layout, ItemInfo info, int[] targetCell, boolean external, boolean scale) { // Now we animate the dragView, (ie. the widget or shortcut preview) into its final // location and size on the home screen. int spanX = info.spanX; int spanY = info.spanY; Rect r = estimateItemPosition(layout, info, targetCell[0], targetCell[1], spanX, spanY); loc[0] = r.left;// w w w. j ava2s. co m loc[1] = r.top; setFinalTransitionTransform(layout); float cellLayoutScale = mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(layout, loc, true); resetTransitionTransform(layout); float dragViewScaleX; float dragViewScaleY; if (scale) { dragViewScaleX = (1.0f * r.width()) / dragView.getMeasuredWidth(); dragViewScaleY = (1.0f * r.height()) / dragView.getMeasuredHeight(); } else { dragViewScaleX = 1f; dragViewScaleY = 1f; } // The animation will scale the dragView about its center, so we need to center about // the final location. loc[0] -= (dragView.getMeasuredWidth() - cellLayoutScale * r.width()) / 2; loc[1] -= (dragView.getMeasuredHeight() - cellLayoutScale * r.height()) / 2; scaleXY[0] = dragViewScaleX * cellLayoutScale; scaleXY[1] = dragViewScaleY * cellLayoutScale; }
From source file:com.skytree.epubtest.BookViewActivity.java
@Override public void draw(Canvas canvas) { int lvl = getLevel(); Rect b = getBounds(); float x = (float) b.width() * (float) lvl / 10000.0f; float y = (b.height() - mPaint.getStrokeWidth()) / 2; mPaint.setStyle(Paint.Style.FILL); for (int cx = 10; cx < b.width(); cx += 30) { float cr = (float) ((float) (cx - 10) / (float) (b.width() - 10)) * 100; if (cr <= this.value) { mPaint.setColor(color);/* w w w . j a v a 2 s . c o m*/ if (color != inactiveColor) { canvas.drawCircle(cx, y, 6, mPaint); } else { canvas.drawCircle(cx, y, 4, mPaint); } } else { mPaint.setColor(inactiveColor); canvas.drawCircle(cx, y, 4, mPaint); } } }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
/** * Compute the amount to scroll in the Y direction in order to get * a rectangle completely on the screen (or, if taller than the screen, * at least the first screen size chunk of it). * * NOTE This method is borrowed from {@link ScrollView}. * * @param rect The rect.//w ww. j av a 2s.c om * @return The scroll delta. */ protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) { if (getChildCount() == 0) { return 0; } final int height = getHeight(); final int fadingEdge = getVerticalFadingEdgeLength(); int screenTop = getScrollY(); int screenBottom = screenTop + height; // leave room for top fading edge as long as rect isn't at very top if (rect.top > 0) { screenTop += fadingEdge; } // leave room for bottom fading edge as long as rect isn't at very bottom if (rect.bottom < getHeight()) { screenBottom -= fadingEdge; } int scrollYDelta = 0; if (rect.bottom > screenBottom && rect.top > screenTop) { // need to move down to get it in view: move down just enough so // that the entire rectangle is in view (or at least the first // screen size chunk). if (rect.height() > height) { // just enough to get screen size chunk on scrollYDelta = screenTop - rect.top; } else { // get entire rect at bottom of screen scrollYDelta = screenBottom - rect.bottom; } } else if (rect.top < screenTop && rect.bottom < screenBottom) { // need to move up to get it in view: move up just enough so that // entire rectangle is in view (or at least the first screen // size chunk of it). if (rect.height() > height) { // screen size chunk scrollYDelta = screenBottom - rect.bottom; } else { // entire rect at top scrollYDelta = screenTop - rect.top; } } return scrollYDelta; }
From source file:com.skytree.epubtest.BookViewActivity.java
@Override public void draw(Canvas canvas) { Rect b = getBounds(); mPaint.setColor(mColor);/* ww w .j a v a 2s . co m*/ mPaint.setStrokeWidth(mStrokeWidth); mPaint.setStyle(Paint.Style.FILL); canvas.drawLine(0, b.height() / 2 + b.height() * 0.1f, b.width(), b.height() / 2 + b.height() * .1f, mPaint); }
From source file:org.bangbang.support.v4.widget.HListView.java
@Override public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) { int rectTopWithinChild = rect.top; // offset so rect is in coordinates of the this view rect.offset(child.getLeft(), child.getTop()); rect.offset(-child.getScrollX(), -child.getScrollY()); final int height = getHeight(); int listUnfadedTop = getScrollY(); int listUnfadedBottom = listUnfadedTop + height; final int fadingEdge = getVerticalFadingEdgeLength(); if (showingTopFadingEdge()) { // leave room for top fading edge as long as rect isn't at very top if ((mSelectedPosition > 0) || (rectTopWithinChild > fadingEdge)) { listUnfadedTop += fadingEdge; }// w w w . j a v a 2 s . co m } int childCount = getChildCount(); int bottomOfBottomChild = getChildAt(childCount - 1).getBottom(); if (showingBottomFadingEdge()) { // leave room for bottom fading edge as long as rect isn't at very bottom if ((mSelectedPosition < mItemCount - 1) || (rect.bottom < (bottomOfBottomChild - fadingEdge))) { listUnfadedBottom -= fadingEdge; } } int scrollYDelta = 0; if (rect.bottom > listUnfadedBottom && rect.top > listUnfadedTop) { // need to MOVE DOWN to get it in view: move down just enough so // that the entire rectangle is in view (or at least the first // screen size chunk). if (rect.height() > height) { // just enough to get screen size chunk on scrollYDelta += (rect.top - listUnfadedTop); } else { // get entire rect at bottom of screen scrollYDelta += (rect.bottom - listUnfadedBottom); } // make sure we aren't scrolling beyond the end of our children int distanceToBottom = bottomOfBottomChild - listUnfadedBottom; scrollYDelta = Math.min(scrollYDelta, distanceToBottom); } else if (rect.top < listUnfadedTop && rect.bottom < listUnfadedBottom) { // need to MOVE UP to get it in view: move up just enough so that // entire rectangle is in view (or at least the first screen // size chunk of it). if (rect.height() > height) { // screen size chunk scrollYDelta -= (listUnfadedBottom - rect.bottom); } else { // entire rect at top scrollYDelta -= (listUnfadedTop - rect.top); } // make sure we aren't scrolling any further than the top our children int top = getChildAt(0).getTop(); int deltaToTop = top - listUnfadedTop; scrollYDelta = Math.max(scrollYDelta, deltaToTop); } final boolean scroll = scrollYDelta != 0; if (scroll) { scrollListItemsBy(-scrollYDelta); positionSelector(child); mSelectedTop = child.getTop(); invalidate(); } return scroll; }