Add "Add to playlist" menu button to Album pages

This commit is contained in:
Matthew Simpson 2025-03-09 15:16:04 +00:00
parent 8ac059bb17
commit d66f96432d
No known key found for this signature in database
GPG key ID: 9291883D725C52C9
10 changed files with 27 additions and 1 deletions

View file

@ -31,6 +31,7 @@ import com.cappielloantonio.tempo.service.MediaManager;
import com.cappielloantonio.tempo.service.MediaService;
import com.cappielloantonio.tempo.ui.activity.MainActivity;
import com.cappielloantonio.tempo.ui.adapter.SongHorizontalAdapter;
import com.cappielloantonio.tempo.ui.dialog.PlaylistChooserDialog;
import com.cappielloantonio.tempo.util.Constants;
import com.cappielloantonio.tempo.util.DownloadUtil;
import com.cappielloantonio.tempo.util.MappingUtil;
@ -38,6 +39,7 @@ import com.cappielloantonio.tempo.util.MusicUtil;
import com.cappielloantonio.tempo.viewmodel.AlbumPageViewModel;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.stream.Collectors;
@ -108,6 +110,17 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
});
return true;
}
if (item.getItemId() == R.id.action_add_to_playlist) {
albumPageViewModel.getAlbumSongLiveList().observe(getViewLifecycleOwner(), songs -> {
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(Constants.TRACKS_OBJECT, new ArrayList<>(songs));
PlaylistChooserDialog dialog = new PlaylistChooserDialog();
dialog.setArguments(bundle);
dialog.show(requireActivity().getSupportFragmentManager(), null);
});
return true;
}
return false;
}