The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 1 | /* |
| 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 Onorato | a590252 | 2009-07-30 13:37:37 -0700 | [diff] [blame] | 17 | package com.android.launcher2; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
| 19 | import android.content.Context; |
| 20 | import android.content.res.Resources; |
| 21 | import android.util.AttributeSet; |
| 22 | import android.view.ViewGroup; |
| 23 | import android.view.LayoutInflater; |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 24 | import android.graphics.Bitmap; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 25 | |
Romain Guy | edcce09 | 2010-03-04 13:03:17 -0800 | [diff] [blame] | 26 | import com.android.launcher.R; |
| 27 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 28 | public 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 Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 44 | Bitmap b = folderInfo.icon; |
| 45 | if (b == null) { |
| 46 | b = Utilities.createIconBitmap(resources.getDrawable(R.drawable.ic_launcher_folder), |
Joe Onorato | 6665c0f | 2009-09-02 15:27:24 -0700 | [diff] [blame] | 47 | launcher); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 48 | } |
Joe Onorato | 0589f0f | 2010-02-08 13:44:00 -0800 | [diff] [blame] | 49 | icon.setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(b), null, null); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 50 | icon.setText(folderInfo.title); |
| 51 | icon.setTag(folderInfo); |
| 52 | icon.setOnClickListener(launcher); |
| 53 | |
| 54 | return icon; |
| 55 | } |
| 56 | |
| 57 | @Override |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 58 | public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
| 59 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 60 | return false; |
| 61 | } |
| 62 | |
| 63 | @Override |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 64 | public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
| 65 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | @Override |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 69 | public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, |
| 70 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | @Override |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 74 | public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset, |
| 75 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @Override |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 79 | public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, |
| 80 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 81 | } |
| 82 | } |