Skip to content
Snippets Groups Projects
Commit 3c22ef36 authored by Xavier Gibert's avatar Xavier Gibert
Browse files

BugFix: memory leak of theme splash screen background drawable

parent 06583d91
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,8 @@ import android.app.FragmentManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.v4.widget.DrawerLayout;
import android.os.Bundle;
import android.preference.PreferenceManager;
......@@ -515,6 +517,15 @@ public class MainActivity extends ActionBarActivity implements
((StavorApplication)getApplication()).db,
hud_panel_open
);
BitmapDrawable bd = (BitmapDrawable)getWindow().getDecorView().getBackground();
Bitmap mBitmap = bd.getBitmap();
if (mBitmap != null && !mBitmap.isRecycled()) {
getWindow().getDecorView().setBackgroundResource(0);
bd.setCallback(null);
mBitmap.recycle();
mBitmap = null;
}
}
}
......
......@@ -322,7 +322,21 @@ public final class HudFragment extends Fragment {
//System.gc();
browserLayout.removeView(mXwalkView);
}
//unbindDrawables(getView());
//System.gc();
super.onDetach();
}
private void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment