clean out the last used bitmap

Reviewed By: achen1

Differential Revision: D4828134

fbshipit-source-id: bf54f7c9f61016cc0735338f99de7b0378c1234b
This commit is contained in:
Aaron Chiu 2017-04-04 12:44:04 -07:00 committed by Facebook Github Bot
parent 40eb353487
commit f8e583b2d0
2 changed files with 11 additions and 0 deletions

View File

@ -100,6 +100,8 @@ public class ReactAppTestActivity extends FragmentActivity implements
if (mReactInstanceManager != null) {
mReactInstanceManager.destroy();
}
mScreenshotingFrameLayout.clean();
}
public void waitForDestroy(long timeoutMs) throws InterruptedException {
@ -129,6 +131,7 @@ public class ReactAppTestActivity extends FragmentActivity implements
}
mReactRootView = new ReactRootView(this);
mScreenshotingFrameLayout.removeAllViews();
mScreenshotingFrameLayout.clean();
mScreenshotingFrameLayout.addView(mReactRootView);
}

View File

@ -47,6 +47,14 @@ public class ScreenshotingFrameLayout extends FrameLayout {
canvas.drawBitmap(mBitmap, 0, 0, null);
}
public void clean() {
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
mCanvas.setBitmap(null);
}
private static Bitmap createNewBitmap(Canvas canvas) {
return Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
}