List of usage examples for android.graphics Bitmap isRecycled
public final boolean isRecycled()
From source file:github.daneren2005.dsub.util.ImageLoader.java
public SilentBackgroundTask<Void> loadAvatar(Context context, ImageView view, String username) { if (username == null) { view.setImageResource(R.drawable.ic_social_person); return null; }/*from www. j ava 2 s . c o m*/ Bitmap bitmap = cache.get(username); if (bitmap != null && !bitmap.isRecycled()) { Drawable drawable = Util.createDrawableFromBitmap(this.context, bitmap); view.setImageDrawable(drawable); return null; } view.setImageDrawable(null); SilentBackgroundTask<Void> task = new AvatarTask(context, view, username); task.execute(); return task; }
From source file:github.madmarty.madsonic.util.ImageLoader.java
public Bitmap getImageBitmap(String username, int size) { Bitmap bitmap = cache.get(getKey(username, size)); if (bitmap != null && !bitmap.isRecycled()) { Bitmap.Config config = bitmap.getConfig(); return bitmap.copy(config, false); }//ww w . j a v a 2 s. c o m return null; }
From source file:github.madmarty.madsonic.util.ImageLoader.java
public Bitmap getImageBitmap(MusicDirectory.Entry entry, boolean large, int size) { if (entry == null) { return null; }//from w ww . jav a 2 s. c o m String coverArt = entry.getCoverArt(); if (coverArt == null) { return null; } if (size <= 0) { size = large ? imageSizeLarge : imageSizeDefault; } Bitmap bitmap = cache.get(getKey(coverArt, size)); if (bitmap != null && !bitmap.isRecycled()) { Bitmap.Config config = bitmap.getConfig(); return bitmap.copy(config, false); } return null; }
From source file:github.daneren2005.dsub.util.ImageLoader.java
public Bitmap getCachedImage(Context context, MusicDirectory.Entry entry, boolean large) { int size = large ? imageSizeLarge : imageSizeDefault; if (entry == null || entry.getCoverArt() == null) { return getUnknownImage(entry, size); }/*from w ww.j a v a2 s.com*/ Bitmap bitmap = cache.get(getKey(entry.getCoverArt(), size)); if (bitmap == null || bitmap.isRecycled()) { bitmap = FileUtil.getAlbumArtBitmap(context, entry, size); String key = getKey(entry.getCoverArt(), size); cache.put(key, bitmap); cache.get(key); } return bitmap; }
From source file:github.madmarty.madsonic.util.ImageLoader.java
public void loadImage(Context context, RemoteControlClient remoteControl, MusicDirectory.Entry entry) { if (entry == null || entry.getCoverArt() == null) { setUnknownImage(remoteControl);/* w ww . ja va2 s . co m*/ return; } Bitmap bitmap = cache.get(getKey(entry.getCoverArt(), imageSizeLarge)); if (bitmap != null && !bitmap.isRecycled()) { Drawable drawable = Util.createDrawableFromBitmap(this.context, bitmap); setImage(remoteControl, drawable); return; } setUnknownImage(remoteControl); queue.offer(new Task(context, entry, imageSizeLarge, imageSizeLarge, false, new RemoteControlClientTaskHandler(remoteControl))); }
From source file:com.torrenttunes.android.MediaNotificationManager.java
private void fetchBitmapFromURLAsync(final String bitmapUrl, final NotificationCompat.Builder builder) { AlbumArtCache.getInstance().fetch(bitmapUrl, new AlbumArtCache.FetchListener() { @Override/*w w w . ja va2 s . c o m*/ public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) { if (mMetadata != null && mMetadata.getDescription() != null && artUrl.equals(mMetadata.getDescription().getIconUri().toString())) { // If the media is still the same, update the notification: LogHelper.d(TAG, "fetchBitmapFromURLAsync: set bitmap to ", artUrl); if (!bitmap.isRecycled()) { builder.setLargeIcon(bitmap); } mNotificationManager.notify(NOTIFICATION_ID, builder.build()); } } }); }
From source file:freed.viewer.screenslide.ImageFragment.java
private void createHistogramm(Bitmap bitmap) { /*histogramData = new int [ 256*4]; RenderScript mRS = RenderScript.create(getContext()); ScriptIntrinsicHistogram histogram = ScriptIntrinsicHistogram.create(mRS,Element.U8_4(mRS)); Allocation mHistogramAllocation = Allocation.createSized(mRS, Element.I32_3(mRS), 256); Allocation in = Allocation.createFromBitmap(mRS, bitmap); histogram.setOutput(mHistogramAllocation); histogram.forEach(in);//from ww w . j ava 2 s . c o m mHistogramAllocation.copyTo(histogramData);*/ Log.d(TAG, "Histodata"); if (bitmap == null || bitmap.isRecycled()) return; int[] histo = new int[256 * 3]; int w = bitmap.getWidth(); int h = bitmap.getHeight(); int[] pixels = new int[w * h]; bitmap.getPixels(pixels, 0, w, 0, 0, w, h); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { int index = j * w + i; int r = Color.red(pixels[index]); int g = Color.green(pixels[index]); int b = Color.blue(pixels[index]); histo[r]++; histo[256 + g]++; histo[512 + b]++; } } pixels = null; histogramData = histo; }
From source file:github.popeen.dsub.util.ImageLoader.java
public Bitmap getCachedImage(Context context, MusicDirectory.Entry entry, boolean large) { int size = large ? imageSizeLarge : imageSizeDefault; if (entry == null || entry.getCoverArt() == null) { return getUnknownImage(entry, size); }/* w w w. j a va 2 s .c o m*/ Bitmap bitmap = cache.get(getKey(entry.getCoverArt(), size)); if (bitmap == null || bitmap.isRecycled()) { bitmap = FileUtil.getAlbumArtBitmap(context, entry, size); String key = getKey(entry.getCoverArt(), size); cache.put(key, bitmap); cache.get(key); } if (bitmap != null && bitmap.isRecycled()) { bitmap = null; } return bitmap; }
From source file:github.popeen.dsub.util.ImageLoader.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setImage(MusicDirectory.Entry entry, RemoteControlClientBase remoteControl, Drawable drawable) { if (remoteControl != null && drawable != null) { Bitmap origBitmap = ((BitmapDrawable) drawable).getBitmap(); if (origBitmap != null && !origBitmap.isRecycled()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && origBitmap != null) { origBitmap = origBitmap.copy(origBitmap.getConfig(), false); }/*www .ja v a2 s . com*/ remoteControl.updateAlbumArt(entry, origBitmap); } else { if (origBitmap != null) { Log.e(TAG, "Tried to load a recycled bitmap."); } remoteControl.updateAlbumArt(entry, null); } } }
From source file:com.codeskraps.sbrowser.home.SBrowserActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.itemQuit) { try {//w w w .j av a2s .co m dataBaseData.deleteTable(DataBaseData.DB_TABLE_TABS); } catch (Exception e) { Log.e(TAG, "deleteTable: " + e.getMessage()); } this.finish(); overridePendingTransition(R.anim.fadein, R.anim.fadeout); } else if (item.getItemId() == R.id.itemFeedback) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { "codeskraps@gmail.com" }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "sBrowser - Feedback"); emailIntent.setType("plain/text"); startActivity(Intent.createChooser(emailIntent, "Send your feedback in:")); /*- } else if (item.getItemId() == R.id.itemBuyMeAPint) { try { Intent marketIntent = new Intent(Intent.ACTION_VIEW); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(marketIntent.setData(Uri.parse("market://developer?id=Codeskraps"))); } catch (Exception e) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/developer?id=Codeskraps")); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(browserIntent); Log.e(TAG, e.getMessage()); } */ } else { try { Picture picture = webView.capturePicture(); PictureDrawable pictureDrawable = new PictureDrawable(picture); Bitmap bitmap = Bitmap.createBitmap(300, 300, Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawPicture(pictureDrawable.getPicture()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, (OutputStream) bos); bitmap.isRecycled(); BookmarkItem bookmarkItem = new BookmarkItem(webView.getTitle(), webView.getUrl()); bookmarkItem.setImage(bos.toByteArray()); sBrowserData.setBookmarkItem(bookmarkItem); bos.close(); } catch (Exception e) { Log.e(TAG, "Picture:" + e.getMessage()); BookmarkItem bookmarkItem = new BookmarkItem("Set title", "Set url"); bookmarkItem.setImage(null); sBrowserData.setBookmarkItem(bookmarkItem); } SBrowserApplication sBrwoserApp = (SBrowserApplication) getApplication(); SBrowserActivity.this.startActivity(sBrwoserApp.getMenuIntent(item, SBrowserActivity.this)); overridePendingTransition(R.anim.fadein, R.anim.fadeout); } return super.onOptionsItemSelected(item); }