blob: 5b73a59a76365892b3df8e7dc6d8af0745e5667f [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
Romain Guyedcce092010-03-04 13:03:17 -080026import com.android.launcher.R;
27
The Android Open Source Project31dd5032009-03-03 19:32:27 -080028public class LiveFolderIcon extends FolderIcon {
29 public LiveFolderIcon(Context context, AttributeSet attrs) {
30 super(context, attrs);
31 }
32
33 public LiveFolderIcon(Context context) {
34 super(context);
35 }
36
37 static LiveFolderIcon fromXml(int resId, Launcher launcher, ViewGroup group,
38 LiveFolderInfo folderInfo) {
39
40 LiveFolderIcon icon = (LiveFolderIcon)
41 LayoutInflater.from(launcher).inflate(resId, group, false);
42
43 final Resources resources = launcher.getResources();
Joe Onorato0589f0f2010-02-08 13:44:00 -080044 Bitmap b = folderInfo.icon;
45 if (b == null) {
46 b = Utilities.createIconBitmap(resources.getDrawable(R.drawable.ic_launcher_folder),
Joe Onorato6665c0f2009-09-02 15:27:24 -070047 launcher);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080048 }
Joe Onorato0589f0f2010-02-08 13:44:00 -080049 icon.setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(b), null, null);
The Android Open Source Project31dd5032009-03-03 19:32:27 -080050 icon.setText(folderInfo.title);
51 icon.setTag(folderInfo);
52 icon.setOnClickListener(launcher);
53
54 return icon;
55 }
56
57 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040058 public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
59 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080060 return false;
61 }
62
63 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040064 public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
65 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080066 }
67
68 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040069 public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
70 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080071 }
72
73 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040074 public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
75 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080076 }
77
78 @Override
Joe Onorato00acb122009-08-04 16:04:30 -040079 public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
80 DragView dragView, Object dragInfo) {
The Android Open Source Project31dd5032009-03-03 19:32:27 -080081 }
82}