mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
WIP Added possibility to switch default image when absent the original one
This commit is contained in:
parent
a21a0132bd
commit
2b5a686fe4
23 changed files with 125 additions and 124 deletions
|
|
@ -45,7 +45,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
holder.textArtistName.setText(album.getArtistName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ALBUM_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class AlbumArtistPageAdapter extends RecyclerView.Adapter<AlbumArtistPage
|
|||
holder.textAlbumName.setText(album.getTitle());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.LOW_QUALITY)
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.LOW_QUALITY, CustomGlideRequest.ALBUM_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class AlbumCatalogueAdapter extends RecyclerView.Adapter<AlbumCatalogueAd
|
|||
holder.textArtistName.setText(album.getArtistName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.LOW_QUALITY)
|
||||
.from(context, album.getPrimary(), album.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.LOW_QUALITY, CustomGlideRequest.ALBUM_PIC)
|
||||
.build()
|
||||
.override(300)
|
||||
.into(holder.cover);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
|||
holder.textArtistName.setText(artist.getName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, artist.getPrimary(), artist.getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, artist.getPrimary(), artist.getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ARTIST_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogue
|
|||
holder.textArtistName.setText(artist.getName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, artist.getPrimary(), artist.getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, artist.getPrimary(), artist.getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ARTIST_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
|||
holder.textAlbum.setText(song.getAlbumName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
@ -71,8 +72,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
songRepository.increasePlayCount(songs.get(getBindingAdapterPosition()));
|
||||
Toast.makeText(context, "Ongoing development", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class PlayerNowPlayingSongAdapter extends RecyclerView.Adapter<PlayerNowP
|
|||
Song song = songs.get(position);
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, song.getPrimary(), song.getPrimary(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
@ -68,15 +68,10 @@ public class PlayerNowPlayingSongAdapter extends RecyclerView.Adapter<PlayerNowP
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
songRepository.increasePlayCount(songs.get(getBindingAdapterPosition()));
|
||||
|
||||
if (MusicPlayerRemote.isPlaying()) {
|
||||
MusicPlayerRemote.pauseSong();
|
||||
// Toast.makeText(context, "PAUSING", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
MusicPlayerRemote.resumePlaying();
|
||||
// Toast.makeText(context, "PLAYING", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
holder.songArtist.setText(song.getArtistName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
@ -79,9 +79,6 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
songRepository.increasePlayCount(songs.get(getBindingAdapterPosition()));
|
||||
|
||||
playerBottomSheetFragment.scrollPager(songs.get(getBindingAdapterPosition()), getBindingAdapterPosition(), false);
|
||||
MusicPlayerRemote.openQueue(songs, getBindingAdapterPosition(), true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
|||
holder.textAlbum.setText(song.getAlbumName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
@ -88,10 +88,7 @@ public class RecentMusicAdapter extends RecyclerView.Adapter<RecentMusicAdapter.
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
|
||||
songRepository.increasePlayCount(songs.get(getBindingAdapterPosition()));
|
||||
queueRepository.insertAllAndStartNew(songs.subList(getBindingAdapterPosition(), songs.size()));
|
||||
|
||||
mainActivity.isBottomSheetInPeek(true);
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@ import com.cappielloantonio.play.glide.CustomGlideRequest;
|
|||
import com.cappielloantonio.play.helper.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
import com.cappielloantonio.play.util.Util;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -59,10 +58,10 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
|
|||
|
||||
holder.songTitle.setText(song.getTitle());
|
||||
holder.songArtist.setText(song.getArtistName());
|
||||
holder.songDuration.setText(Util.getReadableDurationString(song.getDuration()));
|
||||
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration()));
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(holder.cover);
|
||||
}
|
||||
|
|
@ -92,10 +91,7 @@ public class SongResultSearchAdapter extends RecyclerView.Adapter<SongResultSear
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
|
||||
songRepository.increasePlayCount(songs.get(getBindingAdapterPosition()));
|
||||
queueRepository.insertAllAndStartNew(songs.subList(getBindingAdapterPosition(), songs.size()));
|
||||
|
||||
mainActivity.isBottomSheetInPeek(true);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||
import com.bumptech.glide.signature.ObjectKey;
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.wolt.blurhashkt.BlurHashDecoder;
|
||||
|
||||
import org.jellyfin.apiclient.model.dto.ImageOptions;
|
||||
|
|
@ -28,17 +29,22 @@ public class CustomGlideRequest {
|
|||
public static final String MEDIUM_QUALITY = "MEDIUM";
|
||||
public static final String LOW_QUALITY = "LOW";
|
||||
|
||||
public static final String SONG_PIC = "SONG";
|
||||
public static final String ALBUM_PIC = "ALBUM";
|
||||
public static final String ARTIST_PIC = "ARTIST";
|
||||
public static final String PLAYLIST_PIC = "PLAYLIST";
|
||||
|
||||
public static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.ALL;
|
||||
public static final int DEFAULT_IMAGE = R.drawable.ic_launcher_background;
|
||||
public static final int DEFAULT_IMAGE = R.drawable.default_album_art;
|
||||
|
||||
public static class Builder {
|
||||
private final RequestManager requestManager;
|
||||
private final Object item;
|
||||
private final Context context;
|
||||
|
||||
private Builder(Context context, String item, String placeholder, String itemType, String quality) {
|
||||
private Builder(Context context, String item, String placeholder, String itemType, String quality, String category) {
|
||||
this.requestManager = Glide.with(context);
|
||||
this.item = item != null ? createUrl(item, itemType, quality) : DEFAULT_IMAGE;
|
||||
this.item = item != null ? createUrl(item, itemType, quality) : MusicUtil.getDefaultPicPerCategory(category);
|
||||
this.context = context;
|
||||
|
||||
if (placeholder != null) {
|
||||
|
|
@ -46,13 +52,13 @@ public class CustomGlideRequest {
|
|||
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
|
||||
requestManager.applyDefaultRequestOptions(createRequestOptions(item, drawable));
|
||||
} else {
|
||||
Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), DEFAULT_IMAGE, null);
|
||||
Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), MusicUtil.getDefaultPicPerCategory(category), null);
|
||||
requestManager.applyDefaultRequestOptions(createRequestOptions(item, drawable));
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder from(Context context, String item, String placeholder, String itemType, String quality) {
|
||||
return new Builder(context, item, placeholder, itemType, quality);
|
||||
public static Builder from(Context context, String item, String placeholder, String itemType, String quality, String category) {
|
||||
return new Builder(context, item, placeholder, itemType, quality, category);
|
||||
}
|
||||
|
||||
public BitmapBuilder bitmap() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.cappielloantonio.play.model;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
|
|
@ -19,6 +20,8 @@ import java.util.UUID;
|
|||
|
||||
@Entity(tableName = "song")
|
||||
public class Song implements Parcelable {
|
||||
private static final String TAG = "SongClass";
|
||||
|
||||
@Ignore
|
||||
public static final String RECENTLY_PLAYED = "RECENTLY_PLAYED";
|
||||
|
||||
|
|
@ -400,9 +403,24 @@ public class Song implements Parcelable {
|
|||
this.playCount = playCount;
|
||||
}
|
||||
|
||||
public void nowPlaying() {
|
||||
this.playCount++;
|
||||
this.lastPlay = Instant.now().toEpochMilli();
|
||||
/*
|
||||
Log.i(TAG, "increasePlayCount: " + isIncreased);
|
||||
* Incremento il numero di ascolti solo se ho ascoltato la canzone da più tempo di:
|
||||
* tempo dell'ultimo ascolto - (durata_canzone / 2)
|
||||
* Ritorno un booleano
|
||||
* Se vero, allora SongRepository scriverà nd DB l'incremento dell'ascolto
|
||||
* Se falso, SongRepository non scriverà nulla nel db
|
||||
*/
|
||||
public boolean nowPlaying() {
|
||||
long startPlayTime = Instant.now().toEpochMilli();
|
||||
|
||||
if(startPlayTime - (getDuration()/2) > getLastPlay()) {
|
||||
this.playCount++;
|
||||
this.lastPlay = startPlayTime;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class PlayingNotification {
|
|||
|
||||
final int bigNotificationImageSize = service.getResources().getDimensionPixelSize(R.dimen.notification_big_image_size);
|
||||
service.runOnUiThread(() -> CustomGlideRequest.Builder
|
||||
.from(service, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(service, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.bitmap()
|
||||
.build()
|
||||
.into(new CustomTarget<Bitmap>(bigNotificationImageSize, bigNotificationImageSize) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class AlbumPageFragment extends Fragment {
|
|||
|
||||
private void initBackCover() {
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), albumPageViewModel.getAlbum().getPrimary(), albumPageViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(requireContext(), albumPageViewModel.getAlbum().getPrimary(), albumPageViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ALBUM_PIC)
|
||||
.build()
|
||||
.into(bind.albumBackCoverImageView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class ArtistPageFragment extends Fragment {
|
|||
|
||||
private void initBackdrop() {
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), artistPageViewModel.getArtist().getBackdrop(), artistPageViewModel.getArtist().getBackdropBlurHash(), CustomGlideRequest.BACKDROP, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(requireContext(), artistPageViewModel.getArtist().getBackdrop(), artistPageViewModel.getArtist().getBackdropBlurHash(), CustomGlideRequest.BACKDROP, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ARTIST_PIC)
|
||||
.build()
|
||||
.into(bind.artistBackdropImageView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
bind.playerHeaderLayout.playerHeaderSongArtistLabel.setText(song.getArtistName());
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(requireContext(), song.getPrimary(), song.getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(bind.playerHeaderLayout.playerHeaderSongCoverImage);
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,6 @@ public class SearchFragment extends Fragment {
|
|||
searchViewModel.searchAlbum(query).observe(requireActivity(), albums -> albumResultSearchAdapter.setItems(albums));
|
||||
searchViewModel.searchArtist(query).observe(requireActivity(), artists -> artistResultSearchAdapter.setItems(artists));
|
||||
|
||||
bind.searchResultNestedScrollView.setVisibility(View.VISIBLE);
|
||||
bind.searchResultLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
private void init(View view) {
|
||||
coverAlbum = view.findViewById(R.id.album_cover_image_view);
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), albumBottomSheetViewModel.getAlbum().getPrimary(), albumBottomSheetViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(requireContext(), albumBottomSheetViewModel.getAlbum().getPrimary(), albumBottomSheetViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ALBUM_PIC)
|
||||
.build()
|
||||
.into(coverAlbum);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement
|
|||
private void init(View view) {
|
||||
coverArtist = view.findViewById(R.id.artist_cover_image_view);
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), artistBottomSheetViewModel.getArtist().getPrimary(), artistBottomSheetViewModel.getArtist().getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(requireContext(), artistBottomSheetViewModel.getArtist().getPrimary(), artistBottomSheetViewModel.getArtist().getPrimaryBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ARTIST_PIC)
|
||||
.build()
|
||||
.into(coverArtist);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
private void init(View view) {
|
||||
coverSong = view.findViewById(R.id.song_cover_image_view);
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), songBottomSheetViewModel.getSong().getPrimary(), songBottomSheetViewModel.getSong().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.from(requireContext(), songBottomSheetViewModel.getSong().getPrimary(), songBottomSheetViewModel.getSong().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.SONG_PIC)
|
||||
.build()
|
||||
.into(coverSong);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.cappielloantonio.play.util;
|
|||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.DirectPlayCodec;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
|
||||
|
|
@ -66,4 +68,22 @@ public class MusicUtil {
|
|||
return String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getDefaultPicPerCategory(String category) {
|
||||
if(category.equals(CustomGlideRequest.SONG_PIC)) {
|
||||
return R.drawable.default_album_art;
|
||||
}
|
||||
else if(category.equals(CustomGlideRequest.ALBUM_PIC)) {
|
||||
return R.drawable.default_album_art;
|
||||
}
|
||||
else if(category.equals(CustomGlideRequest.ARTIST_PIC)) {
|
||||
return R.drawable.default_album_art;
|
||||
}
|
||||
else if(category.equals(CustomGlideRequest.PLAYLIST_PIC)) {
|
||||
return R.drawable.default_album_art;
|
||||
}
|
||||
else {
|
||||
return R.drawable.default_album_art;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
package com.cappielloantonio.play.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Util {
|
||||
public static String getReadableDurationString(long songDurationMillis) {
|
||||
long minutes = (songDurationMillis / 1000) / 60;
|
||||
long seconds = (songDurationMillis / 1000) % 60;
|
||||
|
||||
if (minutes < 60) {
|
||||
return String.format(Locale.getDefault(), "%01d:%02d", minutes, seconds);
|
||||
} else {
|
||||
long hours = minutes / 60;
|
||||
minutes = minutes % 60;
|
||||
return String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds);
|
||||
}
|
||||
}
|
||||
|
||||
public static float dpFromPx(final Context context, final float px) {
|
||||
return px / context.getResources().getDisplayMetrics().density;
|
||||
}
|
||||
|
||||
public static float pxFromDp(final Context context, final float dp) {
|
||||
return dp * context.getResources().getDisplayMetrics().density;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,78 +36,78 @@
|
|||
app:suggestionTextColor="@color/suggestionTextColor"
|
||||
app:suggestionSelectedTextColor="@color/suggestionSelectedTextColor" />
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/search_result_nested_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/persistentSearchView"
|
||||
android:orientation="vertical">
|
||||
android:layout_below="@id/persistentSearchView" >
|
||||
|
||||
<!-- Recent searched -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Label and button -->
|
||||
<!-- Recent searched -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="8dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
<!-- Label and button -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@font/open_sans_font_family"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="Recent Searches"
|
||||
android:textColor="@color/titleTextColor"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/clear_all_search_text_view_clickable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/open_sans_font_family"
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@font/open_sans_font_family"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="Recent Searches"
|
||||
android:textColor="@color/titleTextColor"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/clear_all_search_text_view_clickable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/open_sans_font_family"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="Clear all"
|
||||
android:textColor="@color/subtitleTextColor"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recently_searched_tracks_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="Clear all"
|
||||
android:textColor="@color/subtitleTextColor"
|
||||
android:textSize="14sp" />
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="8dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recently_searched_tracks_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="8dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/search_result_nested_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
<!-- Search result -->
|
||||
<LinearLayout
|
||||
android:id="@+id/search_result_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/global_padding_bottom">
|
||||
android:paddingBottom="@dimen/global_padding_bottom"
|
||||
android:visibility="gone">
|
||||
|
||||
<!-- Label -->
|
||||
<TextView
|
||||
|
|
@ -192,6 +192,6 @@
|
|||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="56dp" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</RelativeLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue