android.graphics.Bitmap.isRecycled()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中android.graphics.Bitmap.isRecycled()方法的一些代码示例,展示了Bitmap.isRecycled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.isRecycled()方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:isRecycled

Bitmap.isRecycled介绍

暂无

代码示例

代码示例来源:origin: CarGuo/GSYVideoPlayer

@Override
protected void releasePauseCover() {
  try {
    if (mCurrentState != CURRENT_STATE_PAUSE && mFullPauseBitmap != null
        && !mFullPauseBitmap.isRecycled() && mShowPauseCover) {
      mFullPauseBitmap.recycle();
      mFullPauseBitmap = null;
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: CarGuo/GSYVideoPlayer

protected void updatePauseCover() {
  if ((mFullPauseBitmap == null || mFullPauseBitmap.isRecycled()) && mShowPauseCover) {
    try {
      initCover();
    } catch (Exception e) {
      e.printStackTrace();
      mFullPauseBitmap = null;
    }
  }
}

代码示例来源:origin: airbnb/lottie-android

@Override public void drawLayer(@NonNull Canvas canvas, Matrix parentMatrix, int parentAlpha) {
 Bitmap bitmap = getBitmap();
 if (bitmap == null || bitmap.isRecycled()) {
  return;
 }
 float density = Utils.dpScale();
 paint.setAlpha(parentAlpha);
 if (colorFilterAnimation != null) {
  paint.setColorFilter(colorFilterAnimation.getValue());
 }
 canvas.save();
 canvas.concat(parentMatrix);
 src.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
 dst.set(0, 0, (int) (bitmap.getWidth() * density), (int) (bitmap.getHeight() * density));
 canvas.drawBitmap(bitmap, src, dst , paint);
 canvas.restore();
}

代码示例来源:origin: square/picasso

@Override void complete(RequestHandler.Result result) {
 if (result == null) {
  throw new AssertionError(
    String.format("Attempted to complete action with no result!\n%s", this));
 }
 Bitmap bitmap = result.getBitmap();
 if (bitmap != null) {
  target.onBitmapLoaded(bitmap, result.getLoadedFrom());
  if (bitmap.isRecycled()) {
   throw new IllegalStateException("Target callback must not recycle bitmap!");
  }
 }
}

代码示例来源:origin: CarGuo/GSYVideoPlayer

@Override
public void releaseAll() {
  super.releaseAll();
  Bitmap bitmap = mBitmapEffect.getBitmap();
  if (bitmap != null && !bitmap.isRecycled()) {
    bitmap.recycle();
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldRecycleBitmap() throws Exception {
 Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
 bitmap.recycle();
 assertThat(bitmap.isRecycled()).isTrue();
}

代码示例来源:origin: bumptech/glide

public void isNotRecycled() {
 if (actual().isRecycled()) {
  fail("is not recycled");
 }
}

代码示例来源:origin: bumptech/glide

@Test
public void recycle_doesNotRecycleWrappedBitmap() {
 resource.recycle();
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void transform_withBitmapDrawable_andUnitBitmapTransformation_doesNotRecycle() {
 when(
   bitmapTransformation
     .transform(
       any(Context.class), anyBitmapResource(), anyInt(), anyInt()))
   .thenAnswer(new ReturnGivenResource());
 Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
 BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
 @SuppressWarnings("unchecked")
 Resource<Drawable> input =
   (Resource<Drawable>) (Resource<?>) new BitmapDrawableResource(drawable, bitmapPool);
 transformation.transform(context, input, /*outWidth=*/ 100, /*outHeight=*/ 200);
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void testEvictedBitmapsAreRecycled() {
 fillPool(pool, MAX_SIZE);
 List<Bitmap> bitmaps = new ArrayList<>(MAX_SIZE);
 bitmaps.addAll(strategy.bitmaps);
 pool.clearMemory();
 for (Bitmap b : bitmaps) {
  assertTrue(b.isRecycled());
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldCreateActiveBitmap() throws Exception {
 Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
 assertThat(bitmap.isRecycled()).isFalse();
 assertThat(bitmap.getPixel(0, 0)).isEqualTo(0);
 assertThat(bitmap.getWidth()).isEqualTo(100);
 assertThat(bitmap.getHeight()).isEqualTo(200);
 assertThat(bitmap.getConfig()).isEqualTo(Bitmap.Config.ARGB_8888);
}

代码示例来源:origin: square/picasso

@Test public void reusedBitmapIsNotRecycled() {
 Request data = new Request.Builder(URI_1).build();
 Bitmap source = Bitmap.createBitmap(10, 10, ARGB_8888);
 Bitmap result = transformResult(data, source, 0);
 assertThat(result).isSameAs(source);
 assertThat(result.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void transform_withLoadedBitmapDrawable_doesNotRecycleBitmap() {
 Glide.init(
   context,
   glideBuilder
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
 concurrency.wait(
   GlideApp.with(context)
     .load(drawable)
     .centerCrop()
     .submit(100, 100));
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void clear_withLoadedBitmapDrawable_doesNotRecycleBitmap() {
 Glide.init(
   context,
   glideBuilder
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
 Target<Drawable> target =
   concurrency.wait(
     GlideApp.with(context)
       .load(drawable)
       .submit(100, 100));
 Glide.with(context).clear(target);
 // Allow Glide's resource recycler to run on the main thread.
 concurrency.pokeMainThread();
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void transformFromRequestManager_withLoadedBitmap_doesNotRecycleBitmap() {
 Glide.init(
   context,
   new GlideBuilder()
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 concurrency.wait(
   GlideApp.with(context)
     .load(bitmap)
     .centerCrop()
     .submit(100, 100));
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void clearFromRequestManager_withLoadedBitmap_doesNotRecycleBitmap() {
 Glide.init(
   context,
   new GlideBuilder()
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 Target<Drawable> target =
   concurrency.wait(
     GlideApp.with(context)
       .load(bitmap)
       .submit(100, 100));
 Glide.with(context).clear(target);
 // Allow Glide's resource recycler to run on the main thread.
 concurrency.pokeMainThread();
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void clearFromRequestBuilder_withLoadedBitmap_asBitmap_doesNotRecycleBitmap() {
 Glide.init(
   context,
   new GlideBuilder()
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 Target<Bitmap> target =
   concurrency.wait(
     GlideApp.with(context)
       .asBitmap()
       .load(bitmap)
       .submit(100, 100));
 Glide.with(context).clear(target);
 // Allow Glide's resource recycler to run on the main thread.
 concurrency.pokeMainThread();
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void clearFromRequestBuilder_asDrawable_withLoadedBitmap_doesNotRecycleBitmap() {
 Glide.init(
   context,
   new GlideBuilder()
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 Target<Drawable> target =
   concurrency.wait(
     GlideApp.with(context)
       .asDrawable()
       .load(bitmap)
       .submit(100, 100));
 Glide.with(context).clear(target);
 // Allow Glide's resource recycler to run on the main thread.
 concurrency.pokeMainThread();
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void transformFromRequestBuilder_asDrawable_withLoadedBitmap_doesNotRecycleBitmap() {
 Glide.init(
   context,
   new GlideBuilder()
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(bitmap)
     .centerCrop()
     .submit(100, 100));
 assertThat(bitmap.isRecycled()).isFalse();
}

代码示例来源:origin: bumptech/glide

@Test
public void transformFromRequestBuilder_withLoadedBitmap_asBitmap_doesNotRecycleBitmap() {
 Glide.init(
   context,
   new GlideBuilder()
     .setMemoryCache(new MemoryCacheAdapter())
     .setBitmapPool(new BitmapPoolAdapter()));
 Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
 concurrency.wait(
   GlideApp.with(context)
     .asBitmap()
     .load(bitmap)
     .centerCrop()
     .submit(100, 100));
 assertThat(bitmap.isRecycled()).isFalse();
}

相关文章