Java Code Examples for android.graphics.Rect

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: TermViewFlipper.java

  33 
vote

private void commonConstructor(Context context){
  this.context=context;
  callbacks=new LinkedList<UpdateCallback>();
  updateVisibleRect();
  Rect visible=mVisibleRect;
  mChildParams=new LayoutParams(visible.width(),visible.height(),Gravity.TOP | Gravity.LEFT);
}
 

Example 2

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  32 
vote

@Override public void invalidateDrawable(Drawable dr){
  if (!mInDrawing) {
    if (verifyDrawable(dr)) {
      final Rect dirty=dr.getBounds();
      final int scrollX=getScrollX() + getPaddingLeft();
      final int scrollY=getScrollY() + getPaddingTop();
      invalidate(dirty.left + scrollX,dirty.top + scrollY,dirty.right + scrollX,dirty.bottom + scrollY);
    }
 else {
      super.invalidateDrawable(dr);
    }
  }
}
 

Example 3

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  32 
vote

@Override public void invalidateDrawable(Drawable dr){
  if (!mInDrawing) {
    if (verifyDrawable(dr)) {
      final Rect dirty=dr.getBounds();
      final int scrollX=getScrollX() + getPaddingLeft();
      final int scrollY=getScrollY() + getPaddingTop();
      invalidate(dirty.left + scrollX,dirty.top + scrollY,dirty.right + scrollX,dirty.bottom + scrollY);
    }
 else {
      super.invalidateDrawable(dr);
    }
  }
}
 

Example 4

From project AChartEngine, under directory /achartengine/src/org/achartengine/chart/.

Source file: AbstractChart.java

  32 
vote

/** 
 * Draw a multiple lines string.
 * @param canvas the canvas to paint to
 * @param text the text to be painted
 * @param x the x value of the area to draw to
 * @param y the y value of the area to draw to
 * @param paint the paint to be used for drawing
 */
protected void drawString(Canvas canvas,String text,float x,float y,Paint paint){
  String[] lines=text.split("\n");
  Rect rect=new Rect();
  int yOff=0;
  for (int i=0; i < lines.length; ++i) {
    canvas.drawText(lines[i],x,y + yOff,paint);
    paint.getTextBounds(lines[i],0,lines[i].length(),rect);
    yOff=yOff + rect.height() + 5;
  }
}
 

Example 5

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  32 
vote

@Override public void invalidateDrawable(Drawable dr){
  if (!mInDrawing) {
    if (verifyDrawable(dr)) {
      final Rect dirty=dr.getBounds();
      final int scrollX=getScrollX() + getPaddingLeft();
      final int scrollY=getScrollY() + getPaddingTop();
      invalidate(dirty.left + scrollX,dirty.top + scrollY,dirty.right + scrollX,dirty.bottom + scrollY);
    }
 else {
      super.invalidateDrawable(dr);
    }
  }
}
 

Example 6

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  32 
vote

@Override public void invalidateDrawable(Drawable dr){
  if (!mInDrawing) {
    if (verifyDrawable(dr)) {
      final Rect dirty=dr.getBounds();
      final int scrollX=getScrollX() + getPaddingLeft();
      final int scrollY=getScrollY() + getPaddingTop();
      invalidate(dirty.left + scrollX,dirty.top + scrollY,dirty.right + scrollX,dirty.bottom + scrollY);
    }
 else {
      super.invalidateDrawable(dr);
    }
  }
}
 

Example 7

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  32 
vote

@Override public void invalidateDrawable(Drawable dr){
  if (!mInDrawing) {
    if (verifyDrawable(dr)) {
      final Rect dirty=dr.getBounds();
      final int scrollX=getScrollX() + getPaddingLeft();
      final int scrollY=getScrollY() + getPaddingTop();
      invalidate(dirty.left + scrollX,dirty.top + scrollY,dirty.right + scrollX,dirty.bottom + scrollY);
    }
 else {
      super.invalidateDrawable(dr);
    }
  }
}
 

Example 8

From project android-cropimage, under directory /src/com/android/camera/.

Source file: CropImage.java

  32 
vote

private void ensureVisible(HighlightView hv){
  Rect r=hv.mDrawRect;
  int panDeltaX1=Math.max(0,getLeft() - r.left);
  int panDeltaX2=Math.min(0,getRight() - r.right);
  int panDeltaY1=Math.max(0,getTop() - r.top);
  int panDeltaY2=Math.min(0,getBottom() - r.bottom);
  int panDeltaX=panDeltaX1 != 0 ? panDeltaX1 : panDeltaX2;
  int panDeltaY=panDeltaY1 != 0 ? panDeltaY1 : panDeltaY2;
  if (panDeltaX != 0 || panDeltaY != 0) {
    panBy(panDeltaX,panDeltaY);
  }
}
 

Example 9

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/camera/.

Source file: CameraManager.java

  32 
vote

/** 
 * A factory method to build the appropriate LuminanceSource object based on the format of the preview buffers, as described by Camera.Parameters.
 * @param data A preview frame.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data,int width,int height){
  Rect rect=getFramingRectInPreview();
  if (rect == null) {
    return null;
  }
  return new PlanarYUVLuminanceSource(data,width,height,rect.left,rect.top,rect.width(),rect.height(),reverseImage);
}
 

Example 10

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/voice/.

Source file: SoundIndicator.java

  32 
vote

@Override public void onDraw(Canvas canvas){
  float w=getWidth();
  float h=getHeight();
  mBufferCanvas.drawRect(0,0,w,h,mClearPaint);
  Rect clip=new Rect(0,(int)((1.0 - mLevel) * (h + mEdgeBitmapOffset)) - mEdgeBitmapOffset,(int)w,(int)h);
  mBufferCanvas.save();
  mBufferCanvas.clipRect(clip);
  mFrontDrawable.setBounds(new Rect(0,0,(int)w,(int)h));
  mFrontDrawable.draw(mBufferCanvas);
  mBufferCanvas.restore();
  mBufferCanvas.drawBitmap(mEdgeBitmap,0,clip.top,mMultPaint);
  canvas.drawBitmap(mDrawingBuffer,0,0,null);
}
 

Example 11

From project android-viewflow, under directory /viewflow/src/org/taptwo/android/widget/.

Source file: TitleFlowIndicator.java

  32 
vote

/** 
 * Calculate the bounds for a view's title
 * @param index
 * @param paint
 * @return
 */
private Rect calcBounds(int index,Paint paint){
  String title=getTitle(index);
  Rect bounds=new Rect();
  bounds.right=(int)paint.measureText(title);
  bounds.bottom=(int)(paint.descent() - paint.ascent());
  return bounds;
}
 

Example 12

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/widget/.

Source file: JewelView.java

  32 
vote

private void setMeasuredDimensionByHeight(int height){
  final Rect posterPosition=mType.posterPosition;
  totalHeight=height;
  originalCoverHeight=originalHeight - ThumbSize.scale(posterPosition.top + posterPosition.bottom);
  originalCoverWidth=Math.round((float)originalCoverHeight / mPosterAR);
  scaled=(float)totalHeight / (float)originalHeight;
  coverHeight=Math.round((float)originalCoverHeight * scaled);
  coverWidth=Math.round((float)originalCoverWidth * scaled);
  totalWidth=coverWidth + Math.round((float)ThumbSize.scale(posterPosition.left + posterPosition.right) * scaled);
  setMeasuredDimension(totalWidth,totalHeight + mType.bottomPadding);
}
 

Example 13

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/drawable/.

Source file: SpotlightDrawable.java

  32 
vote

public void draw(Canvas canvas){
  if (mView.hasWindowFocus()) {
    final Rect bounds=getBounds();
    canvas.save();
    canvas.drawBitmap(mBitmap,bounds.left,bounds.top,mPaint);
  }
}
 

Example 14

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  32 
vote

@Override public void invalidateDrawable(Drawable dr){
  if (!mInDrawing) {
    if (verifyDrawable(dr)) {
      final Rect dirty=dr.getBounds();
      final int scrollX=getScrollX() + getPaddingLeft();
      final int scrollY=getScrollY() + getPaddingTop();
      invalidate(dirty.left + scrollX,dirty.top + scrollY,dirty.right + scrollX,dirty.bottom + scrollY);
    }
 else {
      super.invalidateDrawable(dr);
    }
  }
}
 

Example 15

From project Android_1, under directory /PropagatedIntents/src/com/example/android/notepad/.

Source file: NoteEditor.java

  32 
vote

@Override protected void onDraw(Canvas canvas){
  int count=getLineCount();
  Rect r=mRect;
  Paint paint=mPaint;
  for (int i=0; i < count; i++) {
    int baseline=getLineBounds(i,r);
    canvas.drawLine(r.left,baseline + 1,r.right,baseline + 1,paint);
  }
  super.onDraw(canvas);
}
 

Example 16

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: CropImage.java

  32 
vote

private void ensureVisible(HighlightView hv){
  Rect r=hv.mDrawRect;
  int panDeltaX1=Math.max(0,mLeft - r.left);
  int panDeltaX2=Math.min(0,mRight - r.right);
  int panDeltaY1=Math.max(0,mTop - r.top);
  int panDeltaY2=Math.min(0,mBottom - r.bottom);
  int panDeltaX=panDeltaX1 != 0 ? panDeltaX1 : panDeltaX2;
  int panDeltaY=panDeltaY1 != 0 ? panDeltaY1 : panDeltaY2;
  if (panDeltaX != 0 || panDeltaY != 0) {
    panBy(panDeltaX,panDeltaY);
  }
}
 

Example 17

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/app/.

Source file: AlbumPage.java

  32 
vote

@Override public Rect getPosition(int index){
  Rect rect=mSlotView.getSlotRect(index);
  Rect bounds=mSlotView.bounds();
  rect.offset(bounds.left - mSlotView.getScrollX(),bounds.top - mSlotView.getScrollY());
  return rect;
}
 

Example 18

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: CropImage.java

  32 
vote

private void ensureVisible(HighlightView hv){
  Rect r=hv.mDrawRect;
  int panDeltaX1=Math.max(0,getLeft() - r.left);
  int panDeltaX2=Math.min(0,getRight() - r.right);
  int panDeltaY1=Math.max(0,getTop() - r.top);
  int panDeltaY2=Math.min(0,getBottom() - r.bottom);
  int panDeltaX=panDeltaX1 != 0 ? panDeltaX1 : panDeltaX2;
  int panDeltaY=panDeltaY1 != 0 ? panDeltaY1 : panDeltaY2;
  if (panDeltaX != 0 || panDeltaY != 0) {
    panBy(panDeltaX,panDeltaY);
  }
}
 

Example 19

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/voice/.

Source file: SoundIndicator.java

  32 
vote

@Override public void onDraw(Canvas canvas){
  float w=getWidth();
  float h=getHeight();
  mBufferCanvas.drawRect(0,0,w,h,mClearPaint);
  Rect clip=new Rect(0,(int)((1.0 - mLevel) * (h + mEdgeBitmapOffset)) - mEdgeBitmapOffset,(int)w,(int)h);
  mBufferCanvas.save();
  mBufferCanvas.clipRect(clip);
  mFrontDrawable.setBounds(new Rect(0,0,(int)w,(int)h));
  mFrontDrawable.draw(mBufferCanvas);
  mBufferCanvas.restore();
  mBufferCanvas.drawBitmap(mEdgeBitmap,0,clip.top,mMultPaint);
  canvas.drawBitmap(mDrawingBuffer,0,0,null);
}
 

Example 20

From project Alerte-voirie-android, under directory /src/net/londatiga/android/.

Source file: CustomPopupWindow.java

  31 
vote

/** 
 * Displays like a QuickAction from the anchor view.
 * @param xOffset offset in the X direction
 * @param yOffset offset in the Y direction
 */
public void showLikeQuickAction(int xOffset,int yOffset){
  preShow();
  window.setAnimationStyle(R.style.Animations_PopUpMenu_Center);
  int[] location=new int[2];
  anchor.getLocationOnScreen(location);
  Rect anchorRect=new Rect(location[0],location[1],location[0] + anchor.getWidth(),location[1] + anchor.getHeight());
  root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  root.measure(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  int rootWidth=root.getMeasuredWidth();
  int rootHeight=root.getMeasuredHeight();
  int screenWidth=windowManager.getDefaultDisplay().getWidth();
  int xPos=((screenWidth - rootWidth) / 2) + xOffset;
  int yPos=anchorRect.top - rootHeight + yOffset;
  if (rootHeight > anchorRect.top) {
    yPos=anchorRect.bottom + yOffset;
    window.setAnimationStyle(R.style.Animations_PopDownMenu_Center);
  }
  window.showAtLocation(anchor,Gravity.NO_GRAVITY,xPos,yPos);
}
 

Example 21

From project Android, under directory /app/src/main/java/com/github/mobile/ui/issue/.

Source file: LabelDrawableSpan.java

  31 
vote

private static void setText(final TextView view,final Label[] labels){
  final Resources resources=view.getResources();
  final float paddingTop=ServiceUtils.getPixels(resources,PADDING_TOP);
  final float paddingLeft=ServiceUtils.getPixels(resources,PADDING_LEFT);
  final float paddingRight=ServiceUtils.getPixels(resources,PADDING_RIGHT);
  final float paddingBottom=ServiceUtils.getPixels(resources,PADDING_BOTTOM);
  Paint p=new Paint();
  p.setTypeface(DEFAULT_BOLD);
  p.setTextSize(view.getTextSize());
  final Rect textBounds=new Rect();
  String[] names=new String[labels.length];
  int[] nameWidths=new int[labels.length];
  int textHeight=MIN_VALUE;
  for (int i=0; i < labels.length; i++) {
    String name=labels[i].getName().toUpperCase(US);
    textBounds.setEmpty();
    p.getTextBounds(name,0,name.length(),textBounds);
    names[i]=name;
    textHeight=Math.max(textBounds.height(),textHeight);
    nameWidths[i]=textBounds.width();
  }
  final float textSize=view.getTextSize();
  final StyledText text=new StyledText();
  for (int i=0; i < labels.length; i++) {
    Rect bounds=new Rect();
    bounds.right=Math.round(nameWidths[i] + paddingLeft + paddingRight+ 0.5F);
    bounds.bottom=Math.round(textHeight + paddingTop + paddingBottom+ 0.5F);
    text.append('\uFFFC',new LabelDrawableSpan(resources,textSize,labels[i].getColor(),paddingLeft,textHeight,bounds,names[i]));
    if (i + 1 < labels.length)     text.append(' ');
  }
  view.setText(text);
}
 

Example 22

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: BetterPopupWindow.java

  31 
vote

/** 
 * Displays like a QuickAction from the anchor view.
 * @param xOffset offset in the X direction
 * @param yOffset offset in the Y direction
 */
public void showLikeQuickAction(int xOffset,int yOffset){
  this.preShow();
  this.window.setAnimationStyle(R.style.Animations_GrowFromBottom);
  int[] location=new int[2];
  this.anchor.getLocationOnScreen(location);
  Rect anchorRect=new Rect(location[0],location[1],location[0] + this.anchor.getWidth(),location[1] + this.anchor.getHeight());
  this.root.measure(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  int rootWidth=this.root.getMeasuredWidth();
  int rootHeight=this.root.getMeasuredHeight();
  int screenWidth=this.windowManager.getDefaultDisplay().getWidth();
  int screenHeight=this.windowManager.getDefaultDisplay().getHeight();
  int xPos=((screenWidth - rootWidth) / 2) + xOffset;
  int yPos=anchorRect.top - rootHeight + yOffset;
  if (rootHeight > anchorRect.top) {
    yPos=anchorRect.bottom - yOffset;
    this.window.setAnimationStyle(R.style.Animations_GrowFromTop);
    this.root.findViewById(R.id.layPopupCont).setBackgroundResource(R.drawable.popup_bg_up);
  }
  this.window.showAtLocation(this.anchor,Gravity.NO_GRAVITY,xPos,yPos);
}
 

Example 23

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: PointTextContainer.java

  31 
vote

/** 
 * Create a new point container, that holds the x-y coordinates of a point, a text variable and one paint objects.
 * @param text the text of the point.
 * @param x the x coordinate of the point.
 * @param y the y coordinate of the point.
 * @param paintFront the paintFront for the point.
 */
PointTextContainer(String text,float x,float y,Paint paintFront){
  this.text=text;
  this.x=x;
  this.y=y;
  this.paintFront=paintFront;
  this.paintBack=null;
  this.symbol=null;
  this.boundary=new Rect();
  paintFront.getTextBounds(text,0,text.length(),this.boundary);
}
 

Example 24

From project androidquery, under directory /src/com/androidquery/callback/.

Source file: BitmapAjaxCallback.java

  31 
vote

private static Bitmap getRoundedCornerBitmap(Bitmap bitmap,int pixels){
  Bitmap output=Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888);
  Canvas canvas=new Canvas(output);
  final int color=0xff424242;
  final Paint paint=new Paint();
  final Rect rect=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  final RectF rectF=new RectF(rect);
  final float roundPx=pixels;
  paint.setAntiAlias(true);
  canvas.drawARGB(0,0,0,0);
  paint.setColor(color);
  canvas.drawRoundRect(rectF,roundPx,roundPx,paint);
  paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
  canvas.drawBitmap(bitmap,rect,rect,paint);
  return output;
}
 

Example 25

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: ImmoscoutPlacesOverlay.java

  31 
vote

/** 
 * clusterize flats based on their supposed marker position
 */
public void clusterize(){
  if (mFlats == null)   return;
  final Flats flats=mFlats;
  final ArrayList<ClusterItem> items=tmpItems;
  final Projection projection=mMapView.getProjection();
  final Point screenPos=new Point();
  items.clear();
  for (int i=0; i < flats.size(); i++) {
    final Flat flat=flats.get(i);
    if (flat.lat == 0 && flat.lng == 0 || !flat.visible)     continue;
    Rect itemBounds=new Rect(markerBounds);
    GeoPoint point=new GeoPoint((int)(flat.lat * 1E6),(int)(flat.lng * 1E6));
    projection.toPixels(point,screenPos);
    itemBounds.offset(screenPos.x,screenPos.y);
    items.add(new ClusterItem(flat,point,itemBounds));
  }
  ArrayList<ClusterItem> newItems=new ArrayList<ClusterItem>();
  final Rect intersection=new Rect();
  final int size=items.size();
  for (int i=0; i < size; i++) {
    final ClusterItem item=(ClusterItem)items.get(i);
    if (item.consumed)     continue;
    for (int j=i + 1; j < size; j++) {
      final ClusterItem otherItem=(ClusterItem)items.get(j);
      if (!otherItem.consumed && intersection.setIntersect(item.screenBounds,otherItem.screenBounds) && intersection.width() * intersection.height() >= MIN_INTERSECTION_AREA)       item.add(otherItem);
    }
    newItems.add(item);
  }
  tmpItems.clear();
  tmpItems.addAll(newItems);
  setLastFocusedIndex(-1);
  populate();
}
 

Example 26

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/widgets/.

Source file: TouchInterceptor.java

  31 
vote

@Override public boolean onInterceptTouchEvent(MotionEvent ev){
  if (mDragListener != null || mDropListener != null) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
      int x=(int)ev.getX();
    int y=(int)ev.getY();
  int itemnum=pointToPosition(x,y);
if (itemnum == AdapterView.INVALID_POSITION) {
  break;
}
ViewGroup item=(ViewGroup)getChildAt(itemnum - getFirstVisiblePosition());
mDragPoint=y - item.getTop();
mCoordOffset=((int)ev.getRawY()) - y;
View dragger=item.findViewById(R.id.grabber);
Rect r=mTempRect;
dragger.getDrawingRect(r);
if (x < r.right * 2) {
item.setDrawingCacheEnabled(true);
Bitmap bitmap=Bitmap.createBitmap(item.getDrawingCache());
startDragging(bitmap,y);
mDragPos=itemnum;
mFirstDragPos=mDragPos;
mHeight=getHeight();
int touchSlop=mTouchSlop;
mUpperBound=Math.min(y - touchSlop,mHeight / 3);
mLowerBound=Math.max(y + touchSlop,mHeight * 2 / 3);
return false;
}
stopDragging();
break;
}
}
return super.onInterceptTouchEvent(ev);
}
 

Example 27

From project android_packages_apps_CMSettings, under directory /src/com/cyanogenmod/settings/widgets/.

Source file: TouchInterceptor.java

  31 
vote

@Override public boolean onInterceptTouchEvent(MotionEvent ev){
  if (mDragListener != null || mDropListener != null) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
      int x=(int)ev.getX();
    int y=(int)ev.getY();
  int itemnum=pointToPosition(x,y);
if (itemnum == AdapterView.INVALID_POSITION) {
  break;
}
ViewGroup item=(ViewGroup)getChildAt(itemnum - getFirstVisiblePosition());
mDragPoint=y - item.getTop();
mCoordOffset=((int)ev.getRawY()) - y;
View dragger=item.findViewById(R.id.grabber);
Rect r=mTempRect;
dragger.getDrawingRect(r);
if (x < r.right * 2) {
item.setDrawingCacheEnabled(true);
Bitmap bitmap=Bitmap.createBitmap(item.getDrawingCache());
startDragging(bitmap,y);
mDragPos=itemnum;
mFirstDragPos=mDragPos;
mHeight=getHeight();
int touchSlop=mTouchSlop;
mUpperBound=Math.min(y - touchSlop,mHeight / 3);
mLowerBound=Math.max(y + touchSlop,mHeight * 2 / 3);
return false;
}
stopDragging();
break;
}
}
return super.onInterceptTouchEvent(ev);
}
 

Example 28

From project android_packages_apps_SalvageParts, under directory /src/com/salvagemod/salvageparts/widgets/.

Source file: TouchInterceptor.java

  31 
vote

@Override public boolean onInterceptTouchEvent(MotionEvent ev){
  if (mDragListener != null || mDropListener != null) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
      int x=(int)ev.getX();
    int y=(int)ev.getY();
  int itemnum=pointToPosition(x,y);
if (itemnum == AdapterView.INVALID_POSITION) {
  break;
}
ViewGroup item=(ViewGroup)getChildAt(itemnum - getFirstVisiblePosition());
mDragPoint=y - item.getTop();
mCoordOffset=((int)ev.getRawY()) - y;
View dragger=item.findViewById(R.id.grabber);
Rect r=mTempRect;
dragger.getDrawingRect(r);
if (x < r.right * 2) {
item.setDrawingCacheEnabled(true);
Bitmap bitmap=Bitmap.createBitmap(item.getDrawingCache());
startDragging(bitmap,y);
mDragPos=itemnum;
mFirstDragPos=mDragPos;
mHeight=getHeight();
int touchSlop=mTouchSlop;
mUpperBound=Math.min(y - touchSlop,mHeight / 3);
mLowerBound=Math.max(y + touchSlop,mHeight * 2 / 3);
return false;
}
stopDragging();
break;
}
}
return super.onInterceptTouchEvent(ev);
}
 

Example 29

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.

Source file: BetterPopupWindow.java

  31 
vote

public void show(){
  this.preShow();
  this.window.setAnimationStyle(R.style.Animations_GrowFromTop);
  int[] location=new int[2];
  this.anchor.getLocationOnScreen(location);
  Rect anchorRect=new Rect(location[0],location[1],location[0] + this.anchor.getWidth(),location[1] + this.anchor.getHeight());
  this.root.measure(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  int rootWidth=this.root.getMeasuredWidth();
  int rootHeight=this.root.getMeasuredHeight();
  int screenWidth=this.windowManager.getDefaultDisplay().getWidth();
  int screenHeight=this.windowManager.getDefaultDisplay().getHeight();
  int xPos=anchorRect.left;
  int yPos=anchorRect.bottom;
  if (yPos + rootHeight > screenHeight) {
    this.window.setAnimationStyle(R.style.Animations_GrowFromBottom);
    yPos=anchorRect.top - rootHeight;
  }
  if (xPos + rootWidth > screenWidth) {
    xPos=anchorRect.left - ((anchorRect.left + rootWidth) - screenWidth);
  }
  this.window.showAtLocation(this.anchor,Gravity.NO_GRAVITY,xPos,yPos);
}
 

Example 30

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/nemustech/tiffany/widget/.

Source file: TFAnimateEngine.java

  31 
vote

public Rect[] getRect(Rect arect[],Rect arect1[],Rect arect2[],float f){
  Rect arect3[];
  if (arect == null || arect1 == null)   arect3=null;
 else   if (arect.length != arect1.length) {
    arect3=null;
  }
 else {
    float f1=Math.max(0.0F,Math.min(1.0F,f));
    int i=arect.length;
    Rect arect4[];
    float f2;
    if (arect2 == null || arect2.length != i)     arect4=new Rect[i];
 else     arect4=arect2;
    f2=mInterpolator.getInterpolation(f1);
    for (int j=0; j < i; j++) {
      if (arect4[j] == null)       arect4[j]=new Rect();
      arect4[j].left=arect[j].left + (int)(f2 * (float)(arect1[j].left - arect[j].left));
      arect4[j].right=arect[j].right + (int)(f2 * (float)(arect1[j].right - arect[j].right));
      arect4[j].top=arect[j].top + (int)(f2 * (float)(arect1[j].top - arect[j].top));
      arect4[j].bottom=arect[j].bottom + (int)(f2 * (float)(arect1[j].bottom - arect[j].bottom));
    }
    arect3=arect4;
  }
  return arect3;
}
 

Example 31

From project android_packages_wallpapers_MusicVisualization, under directory /src/com/android/musicvis/vis1/.

Source file: Visualization1.java

  31 
vote

void drawFrame(){
  final SurfaceHolder holder=getSurfaceHolder();
  final Rect frame=holder.getSurfaceFrame();
  final int width=frame.width();
  final int height=frame.height();
  Canvas c=null;
  try {
    c=holder.lockCanvas();
    if (c != null) {
      drawCube(c);
      drawTouchPoint(c);
    }
  }
  finally {
    if (c != null)     holder.unlockCanvasAndPost(c);
  }
  mHandler.removeCallbacks(mDrawCube);
  if (mVisible) {
    mHandler.postDelayed(mDrawCube,1000 / 25);
  }
}
 

Example 32

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/.

Source file: ViewElement.java

  31 
vote

protected void scrollIntoScreenIfNeeded(){
  Point leftTopLocation=getLocation();
  int left=leftTopLocation.x;
  int top=leftTopLocation.y;
  int right=left + getViewWidth();
  int bottom=top + getViewHeight();
  requestRectangleOnScreen(new Rect(left,top,right,bottom));
}
 

Example 33

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/widget/.

Source file: BezelImageView.java

  31 
vote

@Override protected boolean setFrame(int l,int t,int r,int b){
  final boolean changed=super.setFrame(l,t,r,b);
  mBounds=new Rect(0,0,r - l,b - t);
  mBoundsF=new RectF(mBounds);
  mBorderDrawable.setBounds(mBounds);
  mMaskDrawable.setBounds(mBounds);
  return changed;
}
 

Example 34

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardRenderer.java

  30 
vote

/** 
 * Constructor that initializes brushes and images from resources.
 * @param view parent view to render the board onto
 */
public BoardRenderer(View view){
  this.view=view;
  Resources r=view.getResources();
  blackBallPicture=r.getDrawable(R.drawable.black_ball);
  whiteBallPicture=r.getDrawable(R.drawable.white_ball);
  emptyBallPicture=r.getDrawable(R.drawable.hole);
  defaultPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  defaultPaint.setColor(r.getColor(R.color.defaultColor));
  blackP=new Paint(Paint.ANTI_ALIAS_FLAG);
  blackP.setColor(Color.BLACK);
  whiteP=new Paint(Paint.ANTI_ALIAS_FLAG);
  whiteP.setColor(Color.WHITE);
  emptyP=new Paint(Paint.ANTI_ALIAS_FLAG);
  emptyP.setColor(Color.GRAY);
  highlightedP=new Paint(Paint.ANTI_ALIAS_FLAG);
  highlightedP.setColor(Color.RED);
  highlightedP.setAlpha(100);
  selectedP=new Paint(Paint.ANTI_ALIAS_FLAG);
  selectedP.setColor(Color.GREEN);
  selectedP.setAlpha(100);
  boardP=new Paint(Paint.ANTI_ALIAS_FLAG);
  boardP.setColor(r.getColor(R.color.board));
  dst=new Rect();
}
 

Example 35

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/.

Source file: QuickActionBar.java

  29 
vote

@Override protected void onMeasureAndLayout(Rect anchorRect,View contentView){
  contentView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  contentView.measure(MeasureSpec.makeMeasureSpec(getScreenWidth(),MeasureSpec.EXACTLY),LayoutParams.WRAP_CONTENT);
  int rootHeight=contentView.getMeasuredHeight();
  int offsetY=getArrowOffsetY();
  int dyTop=anchorRect.top;
  int dyBottom=getScreenHeight() - anchorRect.bottom;
  boolean onTop=(dyTop > dyBottom);
  int popupY=(onTop) ? anchorRect.top - rootHeight + offsetY : anchorRect.bottom - offsetY;
  setWidgetSpecs(popupY,onTop);
}
 

Example 36

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: InCallMenuView.java

  29 
vote

InCallMenuView(Context context,InCallScreen inCallScreen){
  super(context);
  if (DBG)   log("InCallMenuView constructor...");
  mInCallScreen=inCallScreen;
  TypedArray a=mContext.obtainStyledAttributes(com.android.internal.R.styleable.IconMenuView);
  if (DBG)   log("- IconMenuView styled attrs: " + a);
  mRowHeight=a.getDimensionPixelSize(com.android.internal.R.styleable.IconMenuView_rowHeight,64);
  if (DBG)   log("  - mRowHeight: " + mRowHeight);
  a.recycle();
  a=mContext.obtainStyledAttributes(com.android.internal.R.styleable.MenuView);
  if (DBG)   log("- MenuView styled attrs: " + a);
  mItemBackground=a.getDrawable(com.android.internal.R.styleable.MenuView_itemBackground);
  if (DBG)   log("  - mItemBackground: " + mItemBackground);
  mHorizontalDivider=a.getDrawable(com.android.internal.R.styleable.MenuView_horizontalDivider);
  if (DBG)   log("  - mHorizontalDivider: " + mHorizontalDivider);
  mHorizontalDividerRects=new ArrayList<Rect>();
  mVerticalDivider=a.getDrawable(com.android.internal.R.styleable.MenuView_verticalDivider);
  if (DBG)   log("  - mVerticalDivider: " + mVerticalDivider);
  mVerticalDividerRects=new ArrayList<Rect>();
  a.recycle();
  if (mHorizontalDivider != null) {
    mHorizontalDividerHeight=mHorizontalDivider.getIntrinsicHeight();
    if (mHorizontalDividerHeight == -1)     mHorizontalDividerHeight=1;
  }
  if (mVerticalDivider != null) {
    mVerticalDividerWidth=mVerticalDivider.getIntrinsicWidth();
    if (mVerticalDividerWidth == -1)     mVerticalDividerWidth=1;
  }
  setWillNotDraw(false);
  setFocusableInTouchMode(true);
  setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
  ViewGroup.LayoutParams lp=new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
  setLayoutParams(lp);
}
 

Example 37

From project Barcamp-Bangalore-Android-App, under directory /slidingmenu/library/src/com/slidingmenu/lib/.

Source file: CustomViewAbove.java

  29 
vote

/** 
 * We only want the current page that is being shown to be focusable.
 */
protected boolean onRequestFocusInDescendants(int direction,Rect previouslyFocusedRect){
  int index;
  int increment;
  int end;
  int count=getChildCount();
  if ((direction & FOCUS_FORWARD) != 0) {
    index=0;
    increment=1;
    end=count;
  }
 else {
    index=count - 1;
    increment=-1;
    end=-1;
  }
  for (int i=index; i != end; i+=increment) {
    View child=getChildAt(i);
    if (child.getVisibility() == VISIBLE) {
      ItemInfo ii=infoForChild(child);
      if (ii != null && ii.position == mCurItem) {
        if (child.requestFocus(direction,previouslyFocusedRect)) {
          return true;
        }
      }
    }
  }
  return false;
}