1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.mail.bitmap;
17
18import android.content.res.Resources;
19import android.graphics.Bitmap;
20import android.graphics.BitmapFactory;
21import android.graphics.Canvas;
22
23import com.android.bitmap.BitmapCache;
24import com.android.mail.R;
25
26/**
27 * A contact drawable with a set default avatar.
28 */
29public class AccountAvatarDrawable extends AbstractAvatarDrawable {
30    private static Bitmap DEFAULT_AVATAR = null;
31
32    public AccountAvatarDrawable(final Resources res, final BitmapCache cache,
33            final ContactResolver contactResolver) {
34        super(res);
35        setBitmapCache(cache);
36        setContactResolver(contactResolver);
37
38        if (DEFAULT_AVATAR == null) {
39            DEFAULT_AVATAR = BitmapFactory.decodeResource(res, R.drawable.avatar_placeholder_gray);
40        }
41    }
42
43    @Override
44    protected void drawDefaultAvatar(Canvas canvas) {
45        drawBitmap(DEFAULT_AVATAR, DEFAULT_AVATAR.getWidth(), DEFAULT_AVATAR.getHeight(),
46                canvas);
47    }
48}
49
50