1package com.android.wallpaperpicker.tileinfo; 2 3import android.content.Context; 4import android.graphics.drawable.Drawable; 5import android.view.LayoutInflater; 6import android.view.View; 7import android.view.ViewGroup; 8import android.widget.ImageView; 9 10import com.android.wallpaperpicker.R; 11 12/** 13 * WallpaperTileInfo which uses drawable as the thumbnail. 14 */ 15public 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