Home | History | Annotate | Download | only in tileinfo
      1 package com.android.wallpaperpicker.tileinfo;
      2 
      3 import android.content.Context;
      4 import android.graphics.drawable.Drawable;
      5 import android.view.LayoutInflater;
      6 import android.view.View;
      7 import android.view.ViewGroup;
      8 import android.widget.ImageView;
      9 
     10 import com.android.wallpaperpicker.R;
     11 
     12 /**
     13  * WallpaperTileInfo which uses drawable as the thumbnail.
     14  */
     15 public abstract class DrawableThumbWallpaperInfo extends WallpaperTileInfo {
     16 
     17     private final Drawable mThumb;
     18 
     19     DrawableThumbWallpaperInfo(Drawable thumb) {
     20         mThumb = thumb;
     21     }
     22 
     23     @Override
     24     public View createView(Context context, LayoutInflater inflator, ViewGroup parent) {
     25         mView = inflator.inflate(R.layout.wallpaper_picker_item, parent, false);
     26         setThumb(mThumb);
     27         return mView;
     28     }
     29 
     30     public void setThumb(Drawable thumb) {
     31         if (mView != null && thumb != null) {
     32             thumb.setDither(true);
     33             ImageView image = (ImageView) mView.findViewById(R.id.wallpaper_image);
     34             image.setImageDrawable(thumb);
     35         }
     36     }
     37 }
     38