mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Fix a bunch of potential memory leaks
This commit is contained in:
parent
c025aee039
commit
9c661bd283
6 changed files with 34 additions and 18 deletions
|
|
@ -65,6 +65,7 @@ public class MainActivity extends BaseActivity {
|
|||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
connectivityStatusReceiverManager(false);
|
||||
bind = null;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
|
@ -186,7 +187,7 @@ public class MainActivity extends BaseActivity {
|
|||
|
||||
if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.landingFragment) {
|
||||
navController.navigate(R.id.action_landingFragment_to_loginFragment);
|
||||
} else if(Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.settingsFragment) {
|
||||
} else if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.settingsFragment) {
|
||||
navController.navigate(R.id.action_settingsFragment_to_loginFragment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
activity.removeMusicServiceEventListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
bind = null;
|
||||
}
|
||||
|
||||
private void initQueueSlideView() {
|
||||
bind.playerBodyLayout.playerSongCoverViewPager.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.ui.fragment.dialog;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -14,7 +13,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.DialogPlaylistChooserBinding;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistChooserViewModel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
@ -23,17 +21,12 @@ public class PlaylistChooserDialog extends DialogFragment {
|
|||
private static final String TAG = "ServerSignupDialog";
|
||||
|
||||
private DialogPlaylistChooserBinding bind;
|
||||
private MainActivity activity;
|
||||
private Context context;
|
||||
private PlaylistChooserViewModel playlistChooserViewModel;
|
||||
|
||||
private PlaylistHorizontalAdapter playlistHorizontalAdapter;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = (MainActivity) getActivity();
|
||||
context = requireContext();
|
||||
|
||||
bind = DialogPlaylistChooserBinding.inflate(LayoutInflater.from(requireContext()));
|
||||
playlistChooserViewModel = new ViewModelProvider(requireActivity()).get(PlaylistChooserViewModel.class);
|
||||
|
||||
|
|
@ -48,6 +41,12 @@ public class PlaylistChooserDialog extends DialogFragment {
|
|||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
bind = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
|
@ -89,12 +88,11 @@ public class PlaylistChooserDialog extends DialogFragment {
|
|||
bind.playlistDialogRecyclerView.setAdapter(playlistHorizontalAdapter);
|
||||
|
||||
playlistChooserViewModel.getPlaylistList().observe(requireActivity(), playlists -> {
|
||||
if(playlists.size() > 0) {
|
||||
if (playlists.size() > 0) {
|
||||
if (bind != null) bind.noPlaylistsCreatedTextView.setVisibility(View.GONE);
|
||||
if (bind != null) bind.playlistDialogRecyclerView.setVisibility(View.VISIBLE);
|
||||
playlistHorizontalAdapter.setItems(playlists);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (bind != null) bind.noPlaylistsCreatedTextView.setVisibility(View.VISIBLE);
|
||||
if (bind != null) bind.playlistDialogRecyclerView.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
|
||||
private DialogPlaylistEditorBinding bind;
|
||||
private MainActivity activity;
|
||||
private Context context;
|
||||
private PlaylistEditorViewModel playlistEditorViewModel;
|
||||
|
||||
private String playlistName;
|
||||
|
|
@ -38,7 +37,6 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = (MainActivity) getActivity();
|
||||
context = requireContext();
|
||||
|
||||
bind = DialogPlaylistEditorBinding.inflate(LayoutInflater.from(requireContext()));
|
||||
playlistEditorViewModel = new ViewModelProvider(requireActivity()).get(PlaylistEditorViewModel.class);
|
||||
|
|
@ -64,6 +62,12 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
initSongsView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
bind = null;
|
||||
}
|
||||
|
||||
private void setParameterInfo() {
|
||||
if (getArguments() != null) {
|
||||
if (getArguments().getParcelable("song_object") != null) {
|
||||
|
|
|
|||
|
|
@ -20,15 +20,10 @@ public class RatingDialog extends DialogFragment {
|
|||
private static final String TAG = "ServerSignupDialog";
|
||||
|
||||
private DialogRatingBinding bind;
|
||||
private MainActivity activity;
|
||||
private Context context;
|
||||
private RatingViewModel ratingViewModel;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = (MainActivity) getActivity();
|
||||
context = requireContext();
|
||||
|
||||
bind = DialogRatingBinding.inflate(LayoutInflater.from(requireContext()));
|
||||
ratingViewModel = new ViewModelProvider(requireActivity()).get(RatingViewModel.class);
|
||||
|
||||
|
|
@ -53,6 +48,12 @@ public class RatingDialog extends DialogFragment {
|
|||
setRating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
bind = null;
|
||||
}
|
||||
|
||||
private void setElementInfo() {
|
||||
if (getArguments() != null) {
|
||||
if (getArguments().getParcelable("song_object") != null) {
|
||||
|
|
|
|||
|
|
@ -72,6 +72,12 @@ public class ServerSignupDialog extends DialogFragment {
|
|||
setButtonAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
bind = null;
|
||||
}
|
||||
|
||||
private void setServerInfo() {
|
||||
if (getArguments() != null) {
|
||||
loginViewModel.setServerToEdit(getArguments().getParcelable("server_object"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue