/**
* @Overrided method that handles the core portion, <br>
* @warning Dont change the implementation
* This method get called when ever a invalidate is invoked
*/
@Override
protected void onDraw(Canvas canvas) {
// Gets the whole available width to work on
width = canvas.getWidth();
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.reload);
// Create a mutable bitmap to work on. @warning dont load large images
Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
// Set the radius based on image width
RADIUS = bitmap.getWidth() / 2;
calculatePoints();
// release unused bitmap memory
bitmap.recycle();
Path _path = new Path();
if(distance < REFRESH_POSITION && distance >= 0)
{
// Rough Y point which bend to pass through
BEND_POINT_Y = distance/2;
// Rough X point which bend to pass through
BEND_POINT_X = distance/5;
_path.moveTo(top_X1, CENTER_POINT_Y);
_path.quadTo(top_X1 + BEND_POINT_X, CENTER_POINT_Y + BEND_POINT_Y, bottom_X1, CENTER_POINT_Y + distance);
/* Calculate the radius of the bottom arc */
int bottomRadius = (bottom_X2 - bottom_X1)/2;
_path.quadTo(bottom_X1 + bottomRadius, CENTER_POINT_Y + distance + bottomRadius, bottom_X2, CENTER_POINT_Y + distance);
_path.quadTo(top_X2 - BEND_POINT_X, CENTER_POINT_Y + BEND_POINT_Y, top_X2, CENTER_POINT_Y );
_path.lineTo(top_X1, CENTER_POINT_Y);
_path.setFillType(FillType.WINDING);
}
_path.close();
// Draw on canvas
canvas.drawPath(_path, paint);
canvas.drawBitmap(mutableBitmap, (width/2) - RADIUS, CENTER_POINT_Y - RADIUS, paint);
refreshList();
mutableBitmap.recycle();
}
Droplet.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:PullToRefresh-Dropper
作者:
评论列表
文章目录