Fix OOM when switching between camera and camcorder.
- Camera activities extend AbstractGalleryActivity. So
onDestroy is moved from Gallery to AbstractGalleryActivity.
- Use WeakReference for values in the WeakHashMap of
SpinnerVisibilitySetter.
bug:5954389
Change-Id: Ib15f269bd4c54a4621bdff58e7ea16b44f8fb3e3
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
index 9a1d3d3..899e9bf 100644
--- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java
+++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
@@ -181,6 +181,17 @@
}
@Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mGLRootView.lockRenderThread();
+ try {
+ getStateManager().destroy();
+ } finally {
+ mGLRootView.unlockRenderThread();
+ }
+ }
+
+ @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mGLRootView.lockRenderThread();
try {