blob: f80928bd474fd61ab2943b9c3b64b412884f4891 [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
2 * Copyright (C) 2008 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
Joe Onoratoa5902522009-07-30 13:37:37 -070017package com.android.launcher2;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
19import android.content.Context;
20import android.content.res.Resources;
21import android.util.AttributeSet;
22import android.view.ViewGroup;
23import android.view.LayoutInflater;
Joe Onorato0589f0f2010-02-08 13:44:00 -080024import android.graphics.Bitmap;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080025
26public class LiveFolderIcon extends FolderIcon {
27 public LiveFolderIcon(Context context, AttributeSet attrs) {
28 super(context, attrs);
29 }
30
31 public LiveFolderIcon(Context context) {
32 super(context);
33 }
34
35 static LiveFolderIcon fromXml(int resId, Launcher launcher, ViewGroup group,
36 LiveFolderInfo folderInfo) {
37
38 LiveFolderIcon icon = (LiveFolderIcon)
39 LayoutInflater.from(launcher).inflate(resId, group, false);
40
41 final Resources resources = launcher.getResources();
Joe Onorato0589f0f2010-02-08 13:44:00 -080042 Bitmap b = folderInfo.icon;
43 if (b == null) {
44 b = Utilities.createIconBitmap(resources.getDrawable(R.drawable.ic_launcher_folder),
Joe Onorato6665c0f2009-09-02 15:27:24 -070045 launcher);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080046 }
Joe Onorato0589f0f2010-02-08 13:44:00 -080047 icon.setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(b), null, null);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080048 icon.setText(folderInfo.title);
49 icon.setTag(folderInfo);
50 icon.setOnClickListener(launcher);
51
52 return icon;
53 }
54
55 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040056 public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
57 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080058 return false;
59 }
60
61 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040062 public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
63 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080064 }
65
66 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040067 public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
68 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080069 }
70
71 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040072 public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
73 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080074 }
75
76 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040077 public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
78 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080079 }
80}