Ejemplo n.º 1
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   if (mCurrentBitmapReference != null && mCurrentBitmapReference.isValid()) {
     mCurrentBitmapReference.close();
   }
 }
Ejemplo n.º 2
0
  @Test
  public void testGet_Realloc() {
    CloseableReference<byte[]> arrayRef = mArray.get(1);
    final byte[] smallArray = arrayRef.get();
    arrayRef.close();

    arrayRef = mArray.get(7);
    assertEquals(8, arrayRef.get().length);
    assertSame(mArray.mByteArraySoftRef.get(), arrayRef.get());
    assertNotSame(smallArray, arrayRef.get());
  }
Ejemplo n.º 3
0
  public void setImageBitmap(CloseableReference<Bitmap> bitmapReference) {
    // Note: This is not a recommended way to load Bitmap.
    // This sample is intended to test the internal methods, and show how to use them.
    Bitmap bitmap = bitmapReference.get();
    mImageView.setImageBitmap(bitmap);
    mImageView.getLayoutParams().width = (int) (bitmap.getWidth() * mConversionFactor);
    mImageView.getLayoutParams().height = (int) (bitmap.getHeight() * mConversionFactor);

    if (mCurrentBitmapReference != null && mCurrentBitmapReference.isValid()) {
      mCurrentBitmapReference.close();
    }
    mCurrentBitmapReference = bitmapReference;
  }