PagedViewIcon.java revision 82369a16126a1030c1c9203dc62b33c2598add89
1/*
2 * Copyright (C) 2010 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 */
16
17package com.android.launcher2;
18
19import android.animation.ObjectAnimator;
20import android.content.Context;
21import android.content.res.Resources;
22import android.graphics.Bitmap;
23import android.graphics.Canvas;
24import android.graphics.Paint;
25import android.util.AttributeSet;
26import android.widget.TextView;
27
28import com.android.launcher.R;
29
30/**
31 * An icon on a PagedView, specifically for items in the launcher's paged view (with compound
32 * drawables on the top).
33 */
34public class PagedViewIcon extends TextView {
35    private static final String TAG = "PagedViewIcon";
36
37    private Bitmap mIcon;
38
39    public PagedViewIcon(Context context) {
40        this(context, null);
41    }
42
43    public PagedViewIcon(Context context, AttributeSet attrs) {
44        this(context, attrs, 0);
45    }
46
47    public PagedViewIcon(Context context, AttributeSet attrs, int defStyle) {
48        super(context, attrs, defStyle);
49    }
50
51    public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp) {
52        mIcon = info.iconBitmap;
53        setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
54        setText(info.title);
55        setTag(info);
56    }
57}
58