List of usage examples for android.graphics.drawable BitmapDrawable setAlpha
@Override public void setAlpha(int alpha)
From source file:com.github.jobs.ui.fragment.JobDetailsFragment.java
private void setLogoBackground() { if (mJob.getCompanyLogo() == null) { return;/* w ww .j a va2 s . c o m*/ } CallbackBitmapObserver rawBitmapObserver = new CallbackBitmapObserver( new CallbackBitmapObserver.BitmapCallback() { @Override public boolean stillNeedsUrl(String uri) { return true; } @Override public void receiveBitmap(String uri, Bitmap bitmap) { if (bitmap == null) { return; } BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap); bitmapDrawable.setAlpha(50); bitmapDrawable.setGravity(Gravity.CENTER); mBackground.setImageDrawable(bitmapDrawable); } }, mJob.getCompanyLogo(), new Handler()); BitmapHelper.getInstance().registerBitmapObserver(getActivity(), rawBitmapObserver); }
From source file:org.mythdroid.fragments.RecDetailFragment.java
private void setImages() { final DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); final int height = dm.heightPixels; final int width = dm.widthPixels; final PreviewImageView iv = ((PreviewImageView) view.findViewById(R.id.image)); if (width > height) iv.setWidth((int) (width > height * 1.5 ? width / 3.5 : width / 3)); else/*from www .ja v a 2 s . c o m*/ iv.setHeight(height / 4); final int artWidth = (int) (width / 1.5); final ArtworkType type = (width > height) ? ArtworkType.fanart : ArtworkType.coverart; if (Globals.haveServices()) Globals.runOnThreadPool(new Runnable() { @Override public void run() { Bitmap bm = prog.getArtwork(type, artWidth, 0); if (bm == null) return; final BitmapDrawable d = new BitmapDrawable(activity.getResources(), bm); d.setAlpha(65); handler.post(new Runnable() { @Override public void run() { if (view == null) return; view.setBackgroundDrawable(d); } }); } }); Globals.runOnThreadPool(new Runnable() { @Override public void run() { final Bitmap bm = prog.previewImage(); if (bm == null) return; handler.post(new Runnable() { @Override public void run() { iv.setImageBitmap(bm); } }); } }); }