Home | History | Annotate | Download | only in launcher2
      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 
     17 package com.android.launcher2;
     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;
     24 import android.graphics.Bitmap;
     25 
     26 import com.android.launcher.R;
     27 
     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();
     44         Bitmap b = folderInfo.icon;
     45         if (b == null) {
     46             b = Utilities.createIconBitmap(resources.getDrawable(R.drawable.ic_launcher_folder),
     47                     launcher);
     48         }
     49         icon.setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(b), null, null);
     50         icon.setText(folderInfo.title);
     51         icon.setTag(folderInfo);
     52         icon.setOnClickListener(launcher);
     53 
     54         return icon;
     55     }
     56 
     57     @Override
     58     public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
     59             DragView dragView, Object dragInfo) {
     60         return false;
     61     }
     62 
     63     @Override
     64     public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
     65             DragView dragView, Object dragInfo) {
     66     }
     67 
     68     @Override
     69     public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
     70             DragView dragView, Object dragInfo) {
     71     }
     72 
     73     @Override
     74     public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
     75             DragView dragView, Object dragInfo) {
     76     }
     77 
     78     @Override
     79     public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
     80             DragView dragView, Object dragInfo) {
     81     }
     82 }
     83