Prevent memory leaks

This commit is contained in:
Martin Fietz 2016-01-26 11:47:56 +01:00
parent bc97221048
commit a3fcd5efe1
3 changed files with 20 additions and 0 deletions

View File

@ -110,6 +110,16 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe
saveCurrentFragment(); saveCurrentFragment();
} }
@Override
public void onDestroy() {
super.onDestroy();
// don't risk creating memory leaks
navAdapter = null;
drawerToggle = null;
mPager = null;
mPagerAdapter = null;
}
@Override @Override
protected void chooseTheme() { protected void chooseTheme() {
setTheme(UserPreferences.getNoTitleTheme()); setTheme(UserPreferences.getNoTitleTheme());

View File

@ -55,6 +55,11 @@ public class ChaptersFragment extends ListFragment implements AudioplayerContent
} }
} }
public void onDestroy() {
super.onDestroy();
adapter = null;
}
@Override @Override
public void onDataSetChanged(Playable media) { public void onDataSetChanged(Playable media) {
adapter.setMedia(media); adapter.setMedia(media);

View File

@ -98,6 +98,11 @@ public class CoverFragment extends Fragment implements
@Override @Override
public void onDataSetChanged(Playable media) { public void onDataSetChanged(Playable media) {
public void onDestroy() {
super.onDestroy();
// prevent memory leaks
root = null;
}
this.media = media; this.media = media;
loadMediaInfo(); loadMediaInfo();
} }