mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Instant mix implementation
This commit is contained in:
parent
b380ae160a
commit
8f72e4234c
4 changed files with 21 additions and 15 deletions
|
|
@ -86,6 +86,16 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
List<Song> opener = new ArrayList<>();
|
||||||
|
opener.add(songs.get(getBindingAdapterPosition()));
|
||||||
|
MusicPlayerRemote.openQueue(opener, 0, true);
|
||||||
|
|
||||||
|
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||||
|
queueRepository.insertAllAndStartNew(opener);
|
||||||
|
|
||||||
|
activity.isBottomSheetInPeek(true);
|
||||||
|
activity.setBottomSheetMusicInfo(songs.get(getBindingAdapterPosition()));
|
||||||
|
|
||||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||||
songRepository.getInstantMix(songs.get(getBindingAdapterPosition()), 20, new MediaCallback() {
|
songRepository.getInstantMix(songs.get(getBindingAdapterPosition()), 20, new MediaCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -95,13 +105,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadMedia(List<?> media) {
|
public void onLoadMedia(List<?> media) {
|
||||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
MusicPlayerRemote.enqueue((List<Song>) media);
|
||||||
List<Song> mix = queueRepository.insertMix((ArrayList<Song>) media);
|
|
||||||
|
|
||||||
activity.isBottomSheetInPeek(true);
|
|
||||||
activity.setBottomSheetMusicInfo((Song) media.get(0));
|
|
||||||
|
|
||||||
MusicPlayerRemote.openQueue((List<Song>) media, 0, true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import com.cappielloantonio.play.App;
|
import com.cappielloantonio.play.App;
|
||||||
import com.cappielloantonio.play.model.Album;
|
import com.cappielloantonio.play.model.Album;
|
||||||
import com.cappielloantonio.play.subsonic.api.albumsonglist.AlbumSongListClient;
|
|
||||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||||
import com.cappielloantonio.play.util.MappingUtil;
|
import com.cappielloantonio.play.util.MappingUtil;
|
||||||
|
|
@ -22,18 +21,18 @@ import retrofit2.Response;
|
||||||
public class AlbumRepository {
|
public class AlbumRepository {
|
||||||
private static final String TAG = "AlbumRepository";
|
private static final String TAG = "AlbumRepository";
|
||||||
|
|
||||||
private AlbumSongListClient albumSongListClient;
|
private Application application;
|
||||||
|
|
||||||
private MutableLiveData<List<Album>> listLiveRecentlyAddedAlbums = new MutableLiveData<>();
|
private MutableLiveData<List<Album>> listLiveRecentlyAddedAlbums = new MutableLiveData<>();
|
||||||
private MutableLiveData<List<Album>> listLiveMostPlayedAlbums = new MutableLiveData<>();
|
private MutableLiveData<List<Album>> listLiveMostPlayedAlbums = new MutableLiveData<>();
|
||||||
private MutableLiveData<List<Album>> listLiveRecentlyPlayedAlbums = new MutableLiveData<>();
|
private MutableLiveData<List<Album>> listLiveRecentlyPlayedAlbums = new MutableLiveData<>();
|
||||||
|
|
||||||
public AlbumRepository(Application application) {
|
public AlbumRepository(Application application) {
|
||||||
albumSongListClient = App.getSubsonicClientInstance(application, false).getAlbumSongListClient();
|
this.application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Album>> getListLiveAlbums(String type, int size) {
|
public LiveData<List<Album>> getListLiveAlbums(String type, int size) {
|
||||||
albumSongListClient
|
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||||
.getAlbumList2(type, size, 0)
|
.getAlbumList2(type, size, 0)
|
||||||
.enqueue(new Callback<SubsonicResponse>() {
|
.enqueue(new Callback<SubsonicResponse>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -74,7 +73,7 @@ public class AlbumRepository {
|
||||||
public MutableLiveData<List<Album>> getStarredAlbums() {
|
public MutableLiveData<List<Album>> getStarredAlbums() {
|
||||||
MutableLiveData<List<Album>> starredAlbums = new MutableLiveData<>();
|
MutableLiveData<List<Album>> starredAlbums = new MutableLiveData<>();
|
||||||
|
|
||||||
albumSongListClient
|
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||||
.getStarred2()
|
.getStarred2()
|
||||||
.enqueue(new Callback<SubsonicResponse>() {
|
.enqueue(new Callback<SubsonicResponse>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -192,13 +192,13 @@ public class HomeFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initStarredTracksView() {
|
private void initStarredTracksView() {
|
||||||
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 5, GridLayoutManager.HORIZONTAL, false));
|
|
||||||
bind.starredTracksRecyclerView.setHasFixedSize(true);
|
bind.starredTracksRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
||||||
homeViewModel.getStarredTracks().observe(requireActivity(), songs -> {
|
homeViewModel.getStarredTracks().observe(requireActivity(), songs -> {
|
||||||
if(bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
if(bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
|
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), (songs.size() / 5) > 0 ? 5 : songs.size() % 5, GridLayoutManager.HORIZONTAL, false));
|
||||||
starredSongAdapter.setItems(songs);
|
starredSongAdapter.setItems(songs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -207,13 +207,13 @@ public class HomeFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initStarredAlbumsView() {
|
private void initStarredAlbumsView() {
|
||||||
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 5, GridLayoutManager.HORIZONTAL, false));
|
|
||||||
bind.starredAlbumsRecyclerView.setHasFixedSize(true);
|
bind.starredAlbumsRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
starredAlbumAdapter = new AlbumHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
starredAlbumAdapter = new AlbumHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter);
|
bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter);
|
||||||
homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> {
|
homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> {
|
||||||
if(bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
if(bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
|
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), (albums.size() / 5) > 0 ? 5 : albums.size() % 5, GridLayoutManager.HORIZONTAL, false));
|
||||||
starredAlbumAdapter.setItems(albums);
|
starredAlbumAdapter.setItems(albums);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -222,13 +222,13 @@ public class HomeFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initStarredArtistsView() {
|
private void initStarredArtistsView() {
|
||||||
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 5, GridLayoutManager.HORIZONTAL, false));
|
|
||||||
bind.starredArtistsRecyclerView.setHasFixedSize(true);
|
bind.starredArtistsRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
starredArtistAdapter = new ArtistHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
starredArtistAdapter = new ArtistHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
|
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
|
||||||
homeViewModel.getStarredArtists().observe(requireActivity(), artists -> {
|
homeViewModel.getStarredArtists().observe(requireActivity(), artists -> {
|
||||||
if(bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
if(bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
|
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), (artists.size() / 5) > 0 ? 5 : artists.size() % 5, GridLayoutManager.HORIZONTAL, false));
|
||||||
starredArtistAdapter.setItems(artists);
|
starredArtistAdapter.setItems(artists);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,9 @@ public class LoginFragment extends Fragment {
|
||||||
PreferenceUtil.getInstance(requireContext()).setPassword(null);
|
PreferenceUtil.getInstance(requireContext()).setPassword(null);
|
||||||
PreferenceUtil.getInstance(requireContext()).setToken(token);
|
PreferenceUtil.getInstance(requireContext()).setToken(token);
|
||||||
PreferenceUtil.getInstance(requireContext()).setSalt(salt);
|
PreferenceUtil.getInstance(requireContext()).setSalt(salt);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App.getSubsonicClientInstance(requireContext(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue