clean-arc

This commit is contained in:
h4h13 2019-03-04 09:25:09 +05:30
parent 1d423fc7bd
commit 5ee566c09a
62 changed files with 477 additions and 937 deletions

View file

@ -49,7 +49,6 @@ import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import java.lang.ref.WeakReference;
@ -262,7 +261,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
};
private static String getTrackUri(@NonNull Song song) {
return MusicUtil.getSongFileUri(song.id).toString();
return MusicUtil.getSongFileUri(song.getId()).toString();
}
private static Bitmap copy(Bitmap bitmap) {
@ -423,7 +422,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
playlistSongs = ((AbsCustomPlaylist) playlist).getSongs(getApplicationContext()).blockingFirst();
} else {
//noinspection unchecked
playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(getApplicationContext(), playlist.id).blockingFirst();
playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(getApplicationContext(), playlist.getId()).blockingFirst();
}
if (!playlistSongs.isEmpty()) {
if (shuffleMode == SHUFFLE_MODE_SHUFFLE) {
@ -663,7 +662,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
}
public void updateNotification() {
if (playingNotification != null && getCurrentSong().id != -1) {
if (playingNotification != null && getCurrentSong().getId() != -1) {
playingNotification.update();
}
}
@ -680,19 +679,19 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
private void updateMediaSessionMetaData() {
final Song song = getCurrentSong();
if (song.id == -1) {
if (song.getId() == -1) {
mediaSession.setMetadata(null);
return;
}
final MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder()
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.artistName)
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.artistName)
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.albumName)
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.title)
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration)
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.getArtistName())
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.getArtistName())
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.getAlbumName())
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.getTitle())
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.getDuration())
.putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getPosition() + 1)
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.year)
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.getYear())
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@ -744,7 +743,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
if (position >= 0 && position < getPlayingQueue().size()) {
return getPlayingQueue().get(position);
} else {
return Song.EMPTY_SONG;
return Song.Companion.getEmptySong();
}
}
@ -861,13 +860,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
public void removeSong(@NonNull Song song) {
for (int i = 0; i < playingQueue.size(); i++) {
if (playingQueue.get(i).id == song.id) {
if (playingQueue.get(i).getId() == song.getId()) {
playingQueue.remove(i);
rePosition(i);
}
}
for (int i = 0; i < originalPlayingQueue.size(); i++) {
if (originalPlayingQueue.get(i).id == song.id) {
if (originalPlayingQueue.get(i).getId() == song.getId()) {
originalPlayingQueue.remove(i);
}
}
@ -1033,7 +1032,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
public long getQueueDurationMillis(int position) {
long duration = 0;
for (int i = position + 1; i < playingQueue.size(); i++)
duration += playingQueue.get(i).duration;
duration += playingQueue.get(i).getDuration();
return duration;
}
@ -1087,11 +1086,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
break;
case SHUFFLE_MODE_NONE:
this.shuffleMode = shuffleMode;
int currentSongId = getCurrentSong().id;
int currentSongId = getCurrentSong().getId();
playingQueue = new ArrayList<>(originalPlayingQueue);
int newPosition = 0;
for (Song song : getPlayingQueue()) {
if (song.id == currentSongId) {
if (song.getId() == currentSongId) {
newPosition = getPlayingQueue().indexOf(song);
}
}
@ -1118,11 +1117,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
final Song song = getCurrentSong();
intent.putExtra("id", song.id);
intent.putExtra("artist", song.artistName);
intent.putExtra("album", song.albumName);
intent.putExtra("track", song.title);
intent.putExtra("duration", song.duration);
intent.putExtra("id", song.getId());
intent.putExtra("artist", song.getArtistName());
intent.putExtra("album", song.getAlbumName());
intent.putExtra("track", song.getTitle());
intent.putExtra("duration", song.getDuration());
intent.putExtra("position", (long) getSongProgressMillis());
intent.putExtra("playing", isPlaying());
intent.putExtra("scrobbling_source", RETRO_MUSIC_PACKAGE_NAME);
@ -1157,9 +1156,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
savePosition();
savePositionInTrack();
final Song currentSong = getCurrentSong();
HistoryStore.getInstance(this).addSongId(currentSong.id);
HistoryStore.getInstance(this).addSongId(currentSong.getId());
if (songPlayCountHelper.shouldBumpPlayCount()) {
SongPlayCountStore.getInstance(this).bumpPlayCount(songPlayCountHelper.getSong().id);
SongPlayCountStore.getInstance(this).bumpPlayCount(songPlayCountHelper.getSong().getId());
}
songPlayCountHelper.notifySongChanged(currentSong);
break;
@ -1389,14 +1388,14 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
public static final String TAG = SongPlayCountHelper.class.getSimpleName();
private StopWatch stopWatch = new StopWatch();
private Song song = Song.EMPTY_SONG;
private Song song = Song.getEmptySong();
public Song getSong() {
return song;
}
boolean shouldBumpPlayCount() {
return song.duration * 0.5d < stopWatch.getElapsedTime();
return song.getDuration() * 0.5d < stopWatch.getElapsedTime();
}
void notifySongChanged(Song song) {

View file

@ -241,9 +241,9 @@ public class WearBrowserService extends MediaBrowserService {
List<Song> songList = SongLoader.INSTANCE.getAllSongs(mContext).blockingFirst();
for (Song song : songList) {
fillMediaItems(mediaItems,
String.valueOf(song.id),
song.title,
song.albumName,
String.valueOf(song.getId()),
song.getTitle(),
song.getAlbumName(),
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
@ -253,9 +253,9 @@ public class WearBrowserService extends MediaBrowserService {
List<Song> albumSongList = AlbumLoader.Companion.getAlbum(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
for (Song song : albumSongList) {
fillMediaItems(mediaItems,
String.valueOf(song.id),
song.title,
song.albumName,
String.valueOf(song.getId()),
song.getTitle(),
song.getAlbumName(),
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
@ -264,9 +264,9 @@ public class WearBrowserService extends MediaBrowserService {
List<Song> artistSongs = ArtistLoader.INSTANCE.getArtist(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
for (Song song : artistSongs) {
fillMediaItems(mediaItems,
String.valueOf(song.id),
song.title,
song.albumName,
String.valueOf(song.getId()),
song.getTitle(),
song.getAlbumName(),
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
MediaBrowser.MediaItem.FLAG_PLAYABLE);
}
@ -277,8 +277,8 @@ public class WearBrowserService extends MediaBrowserService {
int size = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, playlist).blockingFirst().size();
String songCount = String.format("%d %s", size, size > 1 ? "Songs" : "Song");
fillMediaItems(mediaItems,
Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.id),
playlist.name,
Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.getId()),
playlist.getName(),
songCount,
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"),
MediaBrowser.MediaItem.FLAG_BROWSABLE);
@ -288,9 +288,9 @@ public class WearBrowserService extends MediaBrowserService {
List<Song> playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst();
for (Song song : playlistSongs) {
fillMediaItems(mediaItems,
String.valueOf(song.id),
song.title,
song.albumName,
String.valueOf(song.getId()),
song.getTitle(),
song.getAlbumName(),
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
MediaBrowser.MediaItem.FLAG_PLAYABLE);
}