Fix memory leaks (#6335)
This commit is contained in:
parent
9fed944392
commit
240737e3ac
|
@ -230,6 +230,14 @@ public class MainActivity extends CastEnabledActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (drawerLayout != null) {
|
||||
drawerLayout.removeDrawerListener(drawerToggle);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkFirstLaunch() {
|
||||
SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
||||
if (prefs.getBoolean(PREF_IS_FIRST_LAUNCH, true)) {
|
||||
|
|
|
@ -73,12 +73,13 @@ public class CompletedDownloadsFragment extends Fragment
|
|||
private SpeedDialView speedDialView;
|
||||
private SwipeActions swipeActions;
|
||||
private ProgressBar progressBar;
|
||||
private MaterialToolbar toolbar;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.simple_list_fragment, container, false);
|
||||
MaterialToolbar toolbar = root.findViewById(R.id.toolbar);
|
||||
toolbar = root.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(R.string.downloads_label);
|
||||
toolbar.inflateMenu(R.menu.downloads_completed);
|
||||
inflateSortMenu(toolbar);
|
||||
|
@ -168,6 +169,10 @@ public class CompletedDownloadsFragment extends Fragment
|
|||
public void onDestroyView() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
adapter.endSelectMode();
|
||||
if (toolbar != null) {
|
||||
toolbar.setOnMenuItemClickListener(null);
|
||||
toolbar.setOnLongClickListener(null);
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
|||
Log.d(TAG, "Language is " + feed.getLanguage());
|
||||
Log.d(TAG, "Author is " + feed.getAuthor());
|
||||
Log.d(TAG, "URL is " + feed.getDownload_url());
|
||||
Glide.with(getContext())
|
||||
Glide.with(this)
|
||||
.load(feed.getImageUrl())
|
||||
.apply(new RequestOptions()
|
||||
.placeholder(R.color.light_gray)
|
||||
|
@ -204,7 +204,7 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu
|
|||
.fitCenter()
|
||||
.dontAnimate())
|
||||
.into(imgvCover);
|
||||
Glide.with(getContext())
|
||||
Glide.with(this)
|
||||
.load(feed.getImageUrl())
|
||||
.apply(new RequestOptions()
|
||||
.placeholder(R.color.image_readability_tint)
|
||||
|
|
|
@ -297,9 +297,9 @@ public class ItemFragment extends Fragment {
|
|||
new RoundedCorners((int) (8 * getResources().getDisplayMetrics().density)))
|
||||
.dontAnimate();
|
||||
|
||||
Glide.with(getActivity())
|
||||
Glide.with(this)
|
||||
.load(item.getImageLocation())
|
||||
.error(Glide.with(getActivity())
|
||||
.error(Glide.with(this)
|
||||
.load(ImageResourceUtils.getFallbackImageLocation(item))
|
||||
.apply(options))
|
||||
.apply(options)
|
||||
|
|
|
@ -251,6 +251,10 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
|
|||
recyclerAdapter.endSelectMode();
|
||||
}
|
||||
recyclerAdapter = null;
|
||||
if (toolbar != null) {
|
||||
toolbar.setOnMenuItemClickListener(null);
|
||||
toolbar.setOnLongClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshToolbarState() {
|
||||
|
|
|
@ -311,6 +311,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
unregisterReceiver(audioBecomingNoisy);
|
||||
mediaPlayer.shutdown();
|
||||
taskManager.shutdown();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue