Methods Summary |
---|
private void | findWallpapers()
mThumbs = new ArrayList<Integer>(THUMB_IDS.length + 4);
Collections.addAll(mThumbs, THUMB_IDS);
mImages = new ArrayList<Integer>(IMAGE_IDS.length + 4);
Collections.addAll(mImages, IMAGE_IDS);
final Resources resources = getResources();
final String[] extras = resources.getStringArray(R.array.extra_wallpapers);
final String packageName = getApplication().getPackageName();
for (String extra : extras) {
int res = resources.getIdentifier(extra, "drawable", packageName);
if (res != 0) {
final int thumbRes = resources.getIdentifier(extra + "_small",
"drawable", packageName);
if (thumbRes != 0) {
mThumbs.add(thumbRes);
mImages.add(res);
}
}
}
|
public void | onClick(android.view.View v)
selectWallpaper(mGallery.getSelectedItemPosition());
|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
findWallpapers();
setContentView(R.layout.wallpaper_chooser);
mOptions = new BitmapFactory.Options();
mOptions.inDither = false;
mOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
mGallery = (Gallery) findViewById(R.id.gallery);
mGallery.setAdapter(new ImageAdapter(this));
mGallery.setOnItemSelectedListener(this);
mGallery.setCallbackDuringFling(false);
Button b = (Button) findViewById(R.id.set);
b.setOnClickListener(this);
mImageView = (ImageView) findViewById(R.id.wallpaper);
|
public void | onItemSelected(android.widget.AdapterView parent, android.view.View v, int position, long id)
final ImageView view = mImageView;
Bitmap b = BitmapFactory.decodeResource(getResources(), mImages.get(position), mOptions);
view.setImageBitmap(b);
// Help the GC
if (mBitmap != null) {
mBitmap.recycle();
}
mBitmap = b;
final Drawable drawable = view.getDrawable();
drawable.setFilterBitmap(true);
drawable.setDither(true);
|
public void | onNothingSelected(android.widget.AdapterView parent)
|
protected void | onResume()
super.onResume();
mIsWallpaperSet = false;
|
private void | selectWallpaper(int position)
if (mIsWallpaperSet) {
return;
}
mIsWallpaperSet = true;
try {
InputStream stream = getResources().openRawResource(mImages.get(position));
setWallpaper(stream);
setResult(RESULT_OK);
finish();
} catch (IOException e) {
Log.e(Launcher.LOG_TAG, "Failed to set wallpaper: " + e);
}
|