mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Fixed a lot of possible issues raised by a code inspection
This commit is contained in:
parent
39ff821aee
commit
042bf3077f
76 changed files with 148 additions and 225 deletions
|
|
@ -2,9 +2,7 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.RoundedCorner;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -95,10 +95,7 @@ public class ArtistHorizontalAdapter extends RecyclerView.Adapter<ArtistHorizont
|
|||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
||||
more.setOnClickListener(v -> {
|
||||
openMore(v);
|
||||
});
|
||||
|
||||
more.setOnClickListener(this::openMore);
|
||||
artistName.setSelected(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -13,7 +12,6 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -16,13 +15,10 @@ import androidx.annotation.NonNull;
|
|||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.fragment.dialog.PlaylistChooserDialog;
|
||||
import com.cappielloantonio.play.ui.fragment.dialog.PlaylistEditorDialog;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -9,20 +8,12 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -32,8 +23,8 @@ public class PlaylistDialogSongHorizontalAdapter extends RecyclerView.Adapter<Pl
|
|||
private static final String TAG = "PlaylistDialogSongHorizontalAdapter";
|
||||
|
||||
private List<Song> songs;
|
||||
private LayoutInflater mInflater;
|
||||
private Context context;
|
||||
private final LayoutInflater mInflater;
|
||||
private final Context context;
|
||||
|
||||
public PlaylistDialogSongHorizontalAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -81,7 +72,7 @@ public class PlaylistDialogSongHorizontalAdapter extends RecyclerView.Adapter<Pl
|
|||
return songs.get(id);
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView songTitle;
|
||||
TextView songArtist;
|
||||
TextView songDuration;
|
||||
|
|
|
|||
|
|
@ -9,15 +9,12 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.interfaces.SystemCallback;
|
||||
import com.cappielloantonio.play.model.Server;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.SystemRepository;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.ui.fragment.dialog.ServerSignupDialog;
|
||||
|
|
@ -25,7 +22,6 @@ import com.cappielloantonio.play.util.PreferenceUtil;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.ViewHolder> {
|
||||
private static final String TAG = "ServerAdapter";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.cappielloantonio.play.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -10,7 +9,6 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
|
@ -68,15 +66,15 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
holder.downloadIndicator.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(isCoverVisible) CustomGlideRequest.Builder
|
||||
if (isCoverVisible) CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), CustomGlideRequest.SONG_PIC, null)
|
||||
.build()
|
||||
.transform(new RoundedCorners(CustomGlideRequest.CORNER_RADIUS))
|
||||
.into(holder.cover);
|
||||
|
||||
if(isCoverVisible) holder.trackNumber.setVisibility(View.INVISIBLE);
|
||||
if (isCoverVisible) holder.trackNumber.setVisibility(View.INVISIBLE);
|
||||
|
||||
if(!isCoverVisible) holder.cover.setVisibility(View.INVISIBLE);
|
||||
if (!isCoverVisible) holder.cover.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
|
|||
|
||||
@SuppressLint("HandlerLeak")
|
||||
private static final Handler mHandler = new Handler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(final Message msg) {
|
||||
switch (msg.what) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.cappielloantonio.play.database;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.room.AutoMigration;
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import androidx.room.Insert;
|
|||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.Server;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.cappielloantonio.play.helper.recyclerview;
|
|||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class GridItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
|
@ -17,7 +18,7 @@ public class GridItemDecoration extends RecyclerView.ItemDecoration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view); // item position
|
||||
int column = position % spanCount; // item column
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ public class Artist implements Parcelable {
|
|||
public static final String DOWNLOADED = "DOWNLOADED";
|
||||
public static final String STARRED = "STARRED";
|
||||
|
||||
private List<Genre> genres;
|
||||
private List<Album> albums;
|
||||
private List<Song> songs;
|
||||
private List<Artist> similarArtists;
|
||||
|
||||
private String id;
|
||||
|
|
@ -222,9 +220,7 @@ public class Artist implements Parcelable {
|
|||
}
|
||||
|
||||
protected Artist(Parcel in) {
|
||||
this.genres = new ArrayList<>();
|
||||
this.albums = new ArrayList<>();
|
||||
this.songs = new ArrayList<>();
|
||||
this.id = in.readString();
|
||||
this.name = in.readString();
|
||||
this.primary = in.readString();
|
||||
|
|
|
|||
|
|
@ -22,14 +22,34 @@ public class Genre implements Parcelable {
|
|||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getSongCount() {
|
||||
return songCount;
|
||||
}
|
||||
|
||||
public void setSongCount(int songCount) {
|
||||
this.songCount = songCount;
|
||||
}
|
||||
|
||||
public int getAlbumCount() {
|
||||
return albumCount;
|
||||
}
|
||||
|
||||
public void setAlbumCount(int albumCount) {
|
||||
this.albumCount = albumCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
package com.cappielloantonio.play.model;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "queue")
|
||||
public class Queue {
|
||||
@NonNull
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "track_order")
|
||||
private int trackOrder;
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ public class Server implements Parcelable {
|
|||
return serverId.hashCode();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return serverId;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.cappielloantonio.play.model;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
|
||||
import java.time.Instant;
|
||||
|
|
@ -296,6 +298,7 @@ public class Song implements Parcelable {
|
|||
return id.hashCode();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.cappielloantonio.play.service;
|
||||
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
|
|
@ -7,7 +9,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -29,8 +30,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||
|
||||
public class DownloadTracker {
|
||||
|
||||
private static final String TAG = "DownloadTracker";
|
||||
|
|
@ -74,7 +73,7 @@ public class DownloadTracker {
|
|||
MediaItem mediaItem = MusicUtil.getMediaItemFromSong(song);
|
||||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.playbackProperties).uri);
|
||||
|
||||
if(download != null && download.state != Download.STATE_FAILED) {
|
||||
if (download != null && download.state != Download.STATE_FAILED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -91,7 +90,7 @@ public class DownloadTracker {
|
|||
DownloadRepository downloadRepository = new DownloadRepository(App.getInstance());
|
||||
|
||||
for (Song song : songs) {
|
||||
if(isDownloaded(song)) {
|
||||
if (isDownloaded(song)) {
|
||||
downloadRepository.insert(MappingUtil.mapToDownload(song, playlistId, playlistName));
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,8 @@ import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
|
|
@ -32,7 +28,6 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.broadcast.receiver.MediaButtonIntentReceiver;
|
||||
import com.cappielloantonio.play.interfaces.Playback;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ public class Subsonic {
|
|||
|
||||
private final Context context;
|
||||
|
||||
private Version apiVersion = API_MAX_VERSION;
|
||||
private SubsonicPreferences preferences;
|
||||
private final Version apiVersion = API_MAX_VERSION;
|
||||
private final SubsonicPreferences preferences;
|
||||
|
||||
private SystemClient systemClient;
|
||||
private BrowsingClient browsingClient;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.cappielloantonio.play.subsonic.base;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class Version implements Comparable<Version> {
|
||||
|
||||
private static final String VERSION_PATTERN = "[0-9]+(\\.[0-9]+)*";
|
||||
|
|
@ -49,6 +51,7 @@ public class Version implements Comparable<Version> {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return versionString;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class AlbumList {
|
|||
*/
|
||||
public List<Child> getAlbums() {
|
||||
if (albums == null) {
|
||||
albums = new ArrayList<Child>();
|
||||
albums = new ArrayList<>();
|
||||
}
|
||||
return this.albums;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ArtistInfo extends ArtistInfoBase {
|
|||
*/
|
||||
public List<Artist> getSimilarArtists() {
|
||||
if (similarArtists == null) {
|
||||
similarArtists = new ArrayList<Artist>();
|
||||
similarArtists = new ArrayList<>();
|
||||
}
|
||||
return this.similarArtists;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.subsonic.models;
|
||||
|
||||
import com.tickaroo.tikxml.annotation.Element;
|
||||
import com.tickaroo.tikxml.annotation.ElementNameMatcher;
|
||||
import com.tickaroo.tikxml.annotation.Xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Bookmarks {
|
|||
*/
|
||||
public List<Bookmark> getBookmarks() {
|
||||
if (bookmarks == null) {
|
||||
bookmarks = new ArrayList<Bookmark>();
|
||||
bookmarks = new ArrayList<>();
|
||||
}
|
||||
return this.bookmarks;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ChatMessages {
|
|||
*/
|
||||
public List<ChatMessage> getChatMessages() {
|
||||
if (chatMessages == null) {
|
||||
chatMessages = new ArrayList<ChatMessage>();
|
||||
chatMessages = new ArrayList<>();
|
||||
}
|
||||
return this.chatMessages;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class Directory {
|
|||
*/
|
||||
public List<Child> getchildren() {
|
||||
if (children == null) {
|
||||
children = new ArrayList<Child>();
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
return this.children;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class ErrorCode {
|
|||
public static int TRIAL_PERIOD_OVER = 60;
|
||||
public static int DATA_NOT_FOUND = 70;
|
||||
|
||||
private int value;
|
||||
private final int value;
|
||||
|
||||
public ErrorCode(int value) {
|
||||
this.value = value;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class Index {
|
|||
*/
|
||||
public List<Artist> getArtists() {
|
||||
if (artists == null) {
|
||||
artists = new ArrayList<Artist>();
|
||||
artists = new ArrayList<>();
|
||||
}
|
||||
return this.artists;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class Indexes {
|
|||
*/
|
||||
public List<Artist> getShortcuts() {
|
||||
if (shortcuts == null) {
|
||||
shortcuts = new ArrayList<Artist>();
|
||||
shortcuts = new ArrayList<>();
|
||||
}
|
||||
return this.shortcuts;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public class Indexes {
|
|||
*/
|
||||
public List<Index> getIndices() {
|
||||
if (indices == null) {
|
||||
indices = new ArrayList<Index>();
|
||||
indices = new ArrayList<>();
|
||||
}
|
||||
return this.indices;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public class Indexes {
|
|||
*/
|
||||
public List<Child> getchildren() {
|
||||
if (children == null) {
|
||||
children = new ArrayList<Child>();
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
return this.children;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class InternetRadioStations {
|
|||
*/
|
||||
public List<InternetRadioStation> getInternetRadioStations() {
|
||||
if (internetRadioStations == null) {
|
||||
internetRadioStations = new ArrayList<InternetRadioStation>();
|
||||
internetRadioStations = new ArrayList<>();
|
||||
}
|
||||
return this.internetRadioStations;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class JukeboxPlaylist extends JukeboxStatus {
|
|||
*/
|
||||
public List<Child> getEntries() {
|
||||
if (entries == null) {
|
||||
entries = new ArrayList<Child>();
|
||||
entries = new ArrayList<>();
|
||||
}
|
||||
return this.entries;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class NewestPodcasts {
|
|||
*/
|
||||
public List<PodcastEpisode> getEpisodes() {
|
||||
if (episodes == null) {
|
||||
episodes = new ArrayList<PodcastEpisode>();
|
||||
episodes = new ArrayList<>();
|
||||
}
|
||||
return this.episodes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class NowPlaying {
|
|||
*/
|
||||
public List<NowPlayingEntry> getEntries() {
|
||||
if (entries == null) {
|
||||
entries = new ArrayList<NowPlayingEntry>();
|
||||
entries = new ArrayList<>();
|
||||
}
|
||||
return this.entries;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class PlayQueue {
|
|||
*/
|
||||
public List<Child> getEntries() {
|
||||
if (entries == null) {
|
||||
entries = new ArrayList<Child>();
|
||||
entries = new ArrayList<>();
|
||||
}
|
||||
return this.entries;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class PodcastChannel {
|
|||
*/
|
||||
public List<PodcastEpisode> getEpisodes() {
|
||||
if (episodes == null) {
|
||||
episodes = new ArrayList<PodcastEpisode>();
|
||||
episodes = new ArrayList<>();
|
||||
}
|
||||
return this.episodes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Podcasts {
|
|||
*/
|
||||
public List<PodcastChannel> getChannels() {
|
||||
if (channels == null) {
|
||||
channels = new ArrayList<PodcastChannel>();
|
||||
channels = new ArrayList<>();
|
||||
}
|
||||
return this.channels;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public class ResponseStatus {
|
|||
public static String OK = "ok";
|
||||
public static String FAILED = "failed";
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
public ResponseStatus(@Attribute String value) {
|
||||
this.value = value;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class SearchResult {
|
|||
*/
|
||||
public List<Child> getMatches() {
|
||||
if (matches == null) {
|
||||
matches = new ArrayList<Child>();
|
||||
matches = new ArrayList<>();
|
||||
}
|
||||
return this.matches;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class Share {
|
|||
*/
|
||||
public List<Child> getEntries() {
|
||||
if (entries == null) {
|
||||
entries = new ArrayList<Child>();
|
||||
entries = new ArrayList<>();
|
||||
}
|
||||
return this.entries;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Shares {
|
|||
*/
|
||||
public List<Share> getShares() {
|
||||
if (shares == null) {
|
||||
shares = new ArrayList<Share>();
|
||||
shares = new ArrayList<>();
|
||||
}
|
||||
return this.shares;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ package com.cappielloantonio.play.subsonic.models;
|
|||
|
||||
import com.tickaroo.tikxml.annotation.Attribute;
|
||||
import com.tickaroo.tikxml.annotation.Xml;
|
||||
import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Xml(name = "similarArtist")
|
||||
public class SimilarArtistID3 {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class SimilarSongs {
|
|||
*/
|
||||
public List<Child> getSongs() {
|
||||
if (songs == null) {
|
||||
songs = new ArrayList<Child>();
|
||||
songs = new ArrayList<>();
|
||||
}
|
||||
return this.songs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class Starred {
|
|||
*/
|
||||
public List<Artist> getArtists() {
|
||||
if (artists == null) {
|
||||
artists = new ArrayList<Artist>();
|
||||
artists = new ArrayList<>();
|
||||
}
|
||||
return this.artists;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class Starred {
|
|||
*/
|
||||
public List<Child> getAlbums() {
|
||||
if (albums == null) {
|
||||
albums = new ArrayList<Child>();
|
||||
albums = new ArrayList<>();
|
||||
}
|
||||
return this.albums;
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ public class Starred {
|
|||
*/
|
||||
public List<Child> getSongs() {
|
||||
if (songs == null) {
|
||||
songs = new ArrayList<Child>();
|
||||
songs = new ArrayList<>();
|
||||
}
|
||||
return this.songs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class User {
|
|||
*/
|
||||
public List<Integer> getFolders() {
|
||||
if (folders == null) {
|
||||
folders = new ArrayList<Integer>();
|
||||
folders = new ArrayList<>();
|
||||
}
|
||||
return this.folders;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Users {
|
|||
*/
|
||||
public List<User> getUsers() {
|
||||
if (users == null) {
|
||||
users = new ArrayList<User>();
|
||||
users = new ArrayList<>();
|
||||
}
|
||||
return this.users;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class VideoInfo {
|
|||
*/
|
||||
public List<Captions> getCaptions() {
|
||||
if (captions == null) {
|
||||
captions = new ArrayList<Captions>();
|
||||
captions = new ArrayList<>();
|
||||
}
|
||||
return this.captions;
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ public class VideoInfo {
|
|||
*/
|
||||
public List<AudioTrack> getAudioTracks() {
|
||||
if (audioTracks == null) {
|
||||
audioTracks = new ArrayList<AudioTrack>();
|
||||
audioTracks = new ArrayList<>();
|
||||
}
|
||||
return this.audioTracks;
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ public class VideoInfo {
|
|||
*/
|
||||
public List<VideoConversion> getConversions() {
|
||||
if (conversions == null) {
|
||||
conversions = new ArrayList<VideoConversion>();
|
||||
conversions = new ArrayList<>();
|
||||
}
|
||||
return this.conversions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Videos {
|
|||
*/
|
||||
public List<Child> getVideos() {
|
||||
if (videos == null) {
|
||||
videos = new ArrayList<Child>();
|
||||
videos = new ArrayList<>();
|
||||
}
|
||||
return this.videos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ public class StringUtil {
|
|||
try {
|
||||
MessageDigest digest = java.security.MessageDigest.getInstance(MD5);
|
||||
digest.update(s.getBytes());
|
||||
byte messageDigest[] = digest.digest();
|
||||
byte[] messageDigest = digest.digest();
|
||||
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aMessageDigest : messageDigest) {
|
||||
String h = Integer.toHexString(0xFF & aMessageDigest);
|
||||
StringBuilder h = new StringBuilder(Integer.toHexString(0xFF & aMessageDigest));
|
||||
while (h.length() < 2) {
|
||||
h = "0" + h;
|
||||
h.insert(0, "0");
|
||||
}
|
||||
hexString.append(h);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.tickaroo.tikxml.TypeConverter;
|
|||
public class ErrorCodeConverter implements TypeConverter<ErrorCode> {
|
||||
@Override
|
||||
public ErrorCode read(String value) throws Exception {
|
||||
return new ErrorCode(Integer.valueOf(value));
|
||||
return new ErrorCode(Integer.parseInt(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -107,9 +107,7 @@ public class AlbumCatalogueFragment extends Fragment {
|
|||
albumAdapter = new AlbumCatalogueAdapter(activity, requireContext());
|
||||
albumAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
|
||||
bind.albumCatalogueRecyclerView.setAdapter(albumAdapter);
|
||||
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> {
|
||||
albumAdapter.setItems(albums);
|
||||
});
|
||||
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> albumAdapter.setItems(albums));
|
||||
|
||||
bind.albumCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ public class AlbumListPageFragment extends Fragment {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.toolbar.setNavigationOnClickListener(v -> {
|
||||
activity.navController.navigateUp();
|
||||
});
|
||||
bind.toolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if ((bind.albumInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.toolbar))) {
|
||||
|
|
|
|||
|
|
@ -121,16 +121,14 @@ public class AlbumPageFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void initAlbumInfoTextButton() {
|
||||
bind.albumArtistLabel.setOnClickListener(v -> {
|
||||
albumPageViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
activity.navController.navigate(R.id.action_albumPageFragment_to_artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
});
|
||||
bind.albumArtistLabel.setOnClickListener(v -> albumPageViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
activity.navController.navigate(R.id.action_albumPageFragment_to_artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
}));
|
||||
}
|
||||
|
||||
private void initMusicButton() {
|
||||
|
|
@ -181,8 +179,6 @@ public class AlbumPageFragment extends Fragment {
|
|||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), false);
|
||||
bind.songRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
albumPageViewModel.getAlbumSongLiveList(requireActivity()).observe(requireActivity(), songs -> {
|
||||
songHorizontalAdapter.setItems(songs);
|
||||
});
|
||||
albumPageViewModel.getAlbumSongLiveList(requireActivity()).observe(requireActivity(), songs -> songHorizontalAdapter.setItems(songs));
|
||||
}
|
||||
}
|
||||
|
|
@ -107,9 +107,7 @@ public class ArtistCatalogueFragment extends Fragment {
|
|||
artistAdapter = new ArtistCatalogueAdapter(activity, requireContext());
|
||||
artistAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
|
||||
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
|
||||
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artistList -> {
|
||||
artistAdapter.setItems(artistList);
|
||||
});
|
||||
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artistList -> artistAdapter.setItems(artistList));
|
||||
|
||||
bind.artistCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ public class ArtistListPageFragment extends Fragment {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.toolbar.setNavigationOnClickListener(v -> {
|
||||
activity.navController.navigateUp();
|
||||
});
|
||||
bind.toolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if ((bind.artistInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.toolbar))) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -77,9 +76,7 @@ public class FilterFragment extends Fragment {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.toolbar.setNavigationOnClickListener(v -> {
|
||||
activity.navController.navigateUp();
|
||||
});
|
||||
bind.toolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
|
|
|
|||
|
|
@ -114,9 +114,7 @@ public class GenreCatalogueFragment extends Fragment {
|
|||
activity.navController.navigate(R.id.action_genreCatalogueFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
||||
genreCatalogueViewModel.getGenreList().observe(requireActivity(), genres -> {
|
||||
genreCatalogueAdapter.setItems(genres);
|
||||
});
|
||||
genreCatalogueViewModel.getGenreList().observe(requireActivity(), genres -> genreCatalogueAdapter.setItems(genres));
|
||||
|
||||
bind.genreCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
|
@ -11,7 +10,6 @@ import android.view.ViewGroup;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
|
@ -27,8 +25,8 @@ import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
|
|||
import com.cappielloantonio.play.adapter.ArtistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
|
||||
import com.cappielloantonio.play.adapter.SimilarTrackAdapter;
|
||||
import com.cappielloantonio.play.adapter.TrackAdapter;
|
||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.TrackAdapter;
|
||||
import com.cappielloantonio.play.adapter.YearAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
||||
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
||||
|
|
@ -37,9 +35,6 @@ import com.cappielloantonio.play.model.Album;
|
|||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
||||
|
|
@ -345,7 +340,8 @@ public class HomeFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.homeStarredTracksPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
if (bind != null)
|
||||
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
starredSongAdapter.setItems(songs);
|
||||
}
|
||||
|
|
@ -376,7 +372,8 @@ public class HomeFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.homeStarredAlbumsPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
if (bind != null)
|
||||
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
starredAlbumAdapter.setItems(albums);
|
||||
}
|
||||
|
|
@ -407,7 +404,8 @@ public class HomeFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.homeStarredArtistsPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
if (bind != null)
|
||||
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
starredArtistAdapter.setItems(artists);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
|
@ -14,9 +13,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.ServerAdapter;
|
||||
|
|
@ -25,8 +22,6 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
|
|||
import com.cappielloantonio.play.ui.fragment.dialog.ServerSignupDialog;
|
||||
import com.cappielloantonio.play.viewmodel.LoginViewModel;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class LoginFragment extends Fragment {
|
||||
private static final String TAG = "LoginFragment";
|
||||
|
||||
|
|
@ -88,12 +83,11 @@ public class LoginFragment extends Fragment {
|
|||
serverAdapter = new ServerAdapter(activity, requireContext());
|
||||
bind.serverListRecyclerView.setAdapter(serverAdapter);
|
||||
loginViewModel.getServerList().observe(requireActivity(), servers -> {
|
||||
if(servers.size() > 0) {
|
||||
if (servers.size() > 0) {
|
||||
if (bind != null) bind.noServerAddedTextView.setVisibility(View.GONE);
|
||||
if (bind != null) bind.serverListRecyclerView.setVisibility(View.VISIBLE);
|
||||
serverAdapter.setItems(servers);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (bind != null) bind.noServerAddedTextView.setVisibility(View.VISIBLE);
|
||||
if (bind != null) bind.serverListRecyclerView.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -102,13 +96,10 @@ public class LoginFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add:
|
||||
ServerSignupDialog dialog = new ServerSignupDialog();
|
||||
dialog.show(activity.getSupportFragmentManager(), null);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
if (item.getItemId() == R.id.action_add) {
|
||||
ServerSignupDialog dialog = new ServerSignupDialog();
|
||||
dialog.show(activity.getSupportFragmentManager(), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.cappielloantonio.play.util.PreferenceUtil;
|
|||
import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerBottomSheetFragment extends Fragment implements MusicServiceEventListener, MusicProgressViewUpdateHelper.Callback {
|
||||
private static final String TAG = "PlayerBottomSheetFragment";
|
||||
|
|
@ -166,7 +167,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
int toPosition = -1;
|
||||
|
||||
@Override
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||
if (originalPosition == -1)
|
||||
originalPosition = viewHolder.getBindingAdapterPosition();
|
||||
|
||||
|
|
@ -185,7 +186,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
*/
|
||||
|
||||
Collections.swap(playerSongQueueAdapter.getItems(), fromPosition, toPosition);
|
||||
recyclerView.getAdapter().notifyItemMoved(fromPosition, toPosition);
|
||||
Objects.requireNonNull(recyclerView.getAdapter()).notifyItemMoved(fromPosition, toPosition);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -212,7 +213,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
if (!(viewHolder.getBindingAdapterPosition() == MusicPlayerRemote.getPosition()) && !(MusicPlayerRemote.getPlayingQueue().size() <= 1)) {
|
||||
MusicPlayerRemote.removeFromQueue(viewHolder.getBindingAdapterPosition());
|
||||
playerBottomSheetViewModel.removeSong(viewHolder.getBindingAdapterPosition());
|
||||
bodyBind.playerQueueRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
Objects.requireNonNull(bodyBind.playerQueueRecyclerView.getAdapter()).notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
bodyBind.playerSongCoverViewPager.setCurrentItem(MusicPlayerRemote.getPosition(), false);
|
||||
} else {
|
||||
bodyBind.playerQueueRecyclerView.getAdapter().notifyDataSetChanged();
|
||||
|
|
@ -271,11 +272,6 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
}
|
||||
|
||||
private void setViewPageDelayed(int position) {
|
||||
/*bodyBind.playerSongCoverViewPager.post(() -> {
|
||||
int restoredPosition = PreferenceManager.getDefaultSharedPreferences(requireContext()).getInt(PreferenceUtil.POSITION, -1);
|
||||
bodyBind.playerSongCoverViewPager.setCurrentItem(restoredPosition, true);
|
||||
});*/
|
||||
|
||||
final Handler handler = new Handler();
|
||||
final Runnable r = () -> {
|
||||
if (bind != null) bodyBind.playerSongCoverViewPager.setCurrentItem(position, false);
|
||||
|
|
@ -308,7 +304,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
}
|
||||
|
||||
public View getPlayerHeader() {
|
||||
return getView().findViewById(R.id.player_header_layout);
|
||||
return requireView().findViewById(R.id.player_header_layout);
|
||||
}
|
||||
|
||||
public void scrollOnTop() {
|
||||
|
|
@ -322,7 +318,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
setSongInfo(MusicPlayerRemote.getCurrentSong());
|
||||
setSongInfo(Objects.requireNonNull(MusicPlayerRemote.getCurrentSong()));
|
||||
updatePlayPauseState();
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +335,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
@Override
|
||||
public void onPlayMetadataChanged() {
|
||||
setViewPageDelayed(MusicPlayerRemote.getPosition());
|
||||
setSongInfo(MusicPlayerRemote.getCurrentSong());
|
||||
setSongInfo(Objects.requireNonNull(MusicPlayerRemote.getCurrentSong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -107,9 +107,7 @@ public class PlaylistCatalogueFragment extends Fragment {
|
|||
|
||||
playlistCatalogueAdapter = new PlaylistCatalogueAdapter(activity, requireContext(), playlistCatalogueViewModel.getType().equals(Playlist.DOWNLOADED));
|
||||
bind.playlistCatalogueRecyclerView.setAdapter(playlistCatalogueAdapter);
|
||||
playlistCatalogueViewModel.getPlaylistList(requireActivity()).observe(requireActivity(), playlist -> {
|
||||
playlistCatalogueAdapter.setItems(playlist);
|
||||
});
|
||||
playlistCatalogueViewModel.getPlaylistList(requireActivity()).observe(requireActivity(), playlist -> playlistCatalogueAdapter.setItems(playlist));
|
||||
|
||||
bind.playlistCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SongBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
||||
|
|
@ -146,13 +147,13 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
|
||||
TextView download = view.findViewById(R.id.download_text_view);
|
||||
download.setOnClickListener(v -> {
|
||||
DownloadUtil.getDownloadTracker(requireContext()).download(Arrays.asList(song), null, null);
|
||||
DownloadUtil.getDownloadTracker(requireContext()).download(Collections.singletonList(song), null, null);
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
TextView remove = view.findViewById(R.id.remove_text_view);
|
||||
remove.setOnClickListener(v -> {
|
||||
DownloadUtil.getDownloadTracker(requireContext()).remove(Arrays.asList(song));
|
||||
DownloadUtil.getDownloadTracker(requireContext()).remove(Collections.singletonList(song));
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
|
|
@ -171,32 +172,28 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
});
|
||||
|
||||
TextView goToAlbum = view.findViewById(R.id.go_to_album_text_view);
|
||||
goToAlbum.setOnClickListener(v -> {
|
||||
songBottomSheetViewModel.getAlbum().observe(requireActivity(), album -> {
|
||||
if (album != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", album);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.albumPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving album", Toast.LENGTH_SHORT).show();
|
||||
goToAlbum.setOnClickListener(v -> songBottomSheetViewModel.getAlbum().observe(requireActivity(), album -> {
|
||||
if (album != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", album);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.albumPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving album", Toast.LENGTH_SHORT).show();
|
||||
|
||||
dismissBottomSheet();
|
||||
});
|
||||
});
|
||||
dismissBottomSheet();
|
||||
}));
|
||||
|
||||
TextView goToArtist = view.findViewById(R.id.go_to_artist_text_view);
|
||||
goToArtist.setOnClickListener(v -> {
|
||||
songBottomSheetViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
goToArtist.setOnClickListener(v -> songBottomSheetViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
|
||||
dismissBottomSheet();
|
||||
});
|
||||
});
|
||||
dismissBottomSheet();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -108,9 +108,7 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
playlistDialogSongHorizontalAdapter = new PlaylistDialogSongHorizontalAdapter(requireContext());
|
||||
bind.playlistSongRecyclerView.setAdapter(playlistDialogSongHorizontalAdapter);
|
||||
|
||||
playlistEditorViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> {
|
||||
playlistDialogSongHorizontalAdapter.setItems(songs);
|
||||
});
|
||||
playlistEditorViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> playlistDialogSongHorizontalAdapter.setItems(songs));
|
||||
|
||||
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT) {
|
||||
int originalPosition = -1;
|
||||
|
|
@ -118,7 +116,7 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
int toPosition = -1;
|
||||
|
||||
@Override
|
||||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||
if (originalPosition == -1)
|
||||
originalPosition = viewHolder.getBindingAdapterPosition();
|
||||
|
||||
|
|
@ -147,16 +145,16 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
playlistEditorViewModel.removeFromPlaylistSongLiveList(viewHolder.getBindingAdapterPosition());
|
||||
bind.playlistSongRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
Objects.requireNonNull(bind.playlistSongRecyclerView.getAdapter()).notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
}
|
||||
}
|
||||
).attachToRecyclerView(bind.playlistSongRecyclerView);
|
||||
}
|
||||
|
||||
private boolean validateInput() {
|
||||
playlistName = bind.playlistNameTextView.getText().toString().trim();
|
||||
playlistName = Objects.requireNonNull(bind.playlistNameTextView.getText()).toString().trim();
|
||||
|
||||
if (TextUtils.isEmpty(playlistName)) {
|
||||
bind.playlistNameTextView.setError("Required");
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ public class RatingDialog extends DialogFragment {
|
|||
builder.setView(bind.getRoot())
|
||||
.setTitle("Rate")
|
||||
.setNegativeButton("Cancel", (dialog, id) -> dialog.cancel())
|
||||
.setPositiveButton("Save", (dialog, id) -> {
|
||||
ratingViewModel.rate((int) bind.ratingBar.getRating());
|
||||
});
|
||||
.setPositiveButton("Save", (dialog, id) -> ratingViewModel.rate((int) bind.ratingBar.getRating()));
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ import com.cappielloantonio.play.subsonic.models.Genre;
|
|||
import com.cappielloantonio.play.subsonic.models.SimilarArtistID3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MappingUtil {
|
||||
public static ArrayList<Song> mapSong(List<Child> children) {
|
||||
|
|
@ -111,7 +109,7 @@ public class MappingUtil {
|
|||
|
||||
for (Download download : downloads) {
|
||||
Song song = new Song(download);
|
||||
if(!songs.contains(song)) {
|
||||
if (!songs.contains(song)) {
|
||||
songs.add(song);
|
||||
}
|
||||
}
|
||||
|
|
@ -124,7 +122,7 @@ public class MappingUtil {
|
|||
|
||||
for (Download download : downloads) {
|
||||
Album album = new Album(download);
|
||||
if(!albums.contains(album)) {
|
||||
if (!albums.contains(album)) {
|
||||
albums.add(album);
|
||||
}
|
||||
}
|
||||
|
|
@ -137,7 +135,7 @@ public class MappingUtil {
|
|||
|
||||
for (Download download : downloads) {
|
||||
Artist artist = new Artist(download);
|
||||
if(!artists.contains(artist)) {
|
||||
if (!artists.contains(artist)) {
|
||||
artists.add(artist);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,9 @@ import com.cappielloantonio.play.model.Song;
|
|||
import com.google.android.exoplayer2.MediaItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MusicUtil {
|
||||
|
|
@ -76,8 +74,8 @@ public class MusicUtil {
|
|||
|
||||
public static String normalizedArtistName(String string) {
|
||||
if (string != null) {
|
||||
if(string.toLowerCase().contains(" feat.")) return Pattern.compile(" feat.", Pattern.CASE_INSENSITIVE).split(string)[0].trim();
|
||||
else if(string.toLowerCase().contains(" featuring")) return Pattern.compile(" featuring", Pattern.CASE_INSENSITIVE).split(string)[0].trim();
|
||||
if (string.toLowerCase().contains(" feat.")) return Pattern.compile(" feat.", Pattern.CASE_INSENSITIVE).split(string)[0].trim();
|
||||
else if (string.toLowerCase().contains(" featuring")) return Pattern.compile(" featuring", Pattern.CASE_INSENSITIVE).split(string)[0].trim();
|
||||
else return string;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import androidx.lifecycle.AndroidViewModel;
|
|||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import androidx.lifecycle.AndroidViewModel;
|
|||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
|
|
@ -36,8 +35,7 @@ public class PlaylistPageViewModel extends AndroidViewModel {
|
|||
public LiveData<List<Song>> getPlaylistSongLiveList(FragmentActivity activity) {
|
||||
if (isOffline) {
|
||||
downloadRepository.getLiveDownloadFromPlaylist(playlist.getId()).observe(activity, downloads -> playlistSongLiveList.postValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
playlistSongLiveList = playlistRepository.getPlaylistSongs(playlist.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,14 +75,10 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
songList = songRepository.getStarredSongs(false, -1);
|
||||
break;
|
||||
case Song.DOWNLOADED:
|
||||
downloadRepository.getLiveDownload().observe(activity, downloads -> {
|
||||
songList.setValue(MappingUtil.mapDownloadToSong(downloads));
|
||||
});
|
||||
downloadRepository.getLiveDownload().observe(activity, downloads -> songList.setValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
break;
|
||||
case Song.FROM_ALBUM:
|
||||
downloadRepository.getLiveDownloadFromAlbum(album.getId()).observe(activity, downloads -> {
|
||||
songList.setValue(MappingUtil.mapDownloadToSong(downloads));
|
||||
});
|
||||
downloadRepository.getLiveDownloadFromAlbum(album.getId()).observe(activity, downloads -> songList.setValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue