Search in sources :

Example 1 with StatusDrawable

use of com.owncloud.android.ui.StatusDrawable in project android by nextcloud.

the class BitmapUtils method createAvatarWithStatus.

public static Bitmap createAvatarWithStatus(Bitmap avatar, StatusType statusType, String icon, Context context) {
    float avatarRadius = getResources().getDimension(R.dimen.list_item_avatar_icon_radius);
    int width = DisplayUtils.convertDpToPixel(2 * avatarRadius, context);
    Bitmap output = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    // avatar
    Bitmap croppedBitmap = getCroppedBitmap(avatar, width);
    canvas.drawBitmap(croppedBitmap, 0f, 0f, null);
    // status
    int statusSize = width / 4;
    Status status = new Status(statusType, "", icon, -1);
    StatusDrawable statusDrawable = new StatusDrawable(status, statusSize, context);
    canvas.translate(width / 2f, width / 2f);
    statusDrawable.draw(canvas);
    return output;
}
Also used : Status(com.owncloud.android.lib.resources.users.Status) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) StatusDrawable(com.owncloud.android.ui.StatusDrawable) Paint(android.graphics.Paint)

Aggregations

Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Paint (android.graphics.Paint)1 Status (com.owncloud.android.lib.resources.users.Status)1 StatusDrawable (com.owncloud.android.ui.StatusDrawable)1