Merge pull request #485 from tzugen/context-free-2

Removing remaining context from MusicService signatures.
This commit is contained in:
Nite 2021-05-11 15:32:18 +02:00 committed by GitHub
commit 14941486a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 219 additions and 262 deletions

View File

@ -117,8 +117,8 @@
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$// TODO Test if this works with external Intents // android.intent.action.SEARCH and android.media.action.MEDIA_PLAY_FROM_SEARCH calls here override fun onNewIntent(intent: Intent?)</ID>
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$override fun onCreate(savedInstanceState: Bundle?)</ID>
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$private fun showNowPlaying()</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( context: Context, username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( context: Context, entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(IOException::class) private fun savePlaylist( name: String?, playlist: MusicDirectory )</ID>
<ID>LongMethod:RestErrorMapper.kt$ fun SubsonicRESTException.getLocalizedErrorMessage(context: Context): String</ID>
<ID>LongMethod:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
@ -200,8 +200,8 @@
<ID>ReturnCount:CommunicationErrorHandler.kt$CommunicationErrorHandler.Companion$fun getErrorMessage(error: Throwable, context: Context): String</ID>
<ID>ReturnCount:FileLoggerTree.kt$FileLoggerTree$ private fun getNextLogFile()</ID>
<ID>ReturnCount:MediaPlayerService.kt$MediaPlayerService$private fun generateAction(context: Context, requestCode: Int): NotificationCompat.Action?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( context: Context, username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( context: Context, entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
<ID>ReturnCount:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
<ID>ReturnCount:ServerRowAdapter.kt$ServerRowAdapter$ private fun popupMenuItemClick(menuItem: MenuItem, position: Int): Boolean</ID>

View File

@ -117,8 +117,8 @@
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$// TODO Test if this works with external Intents // android.intent.action.SEARCH and android.media.action.MEDIA_PLAY_FROM_SEARCH calls here override fun onNewIntent(intent: Intent?)</ID>
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$override fun onCreate(savedInstanceState: Bundle?)</ID>
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$private fun showNowPlaying()</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( context: Context, username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( context: Context, entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(IOException::class) private fun savePlaylist( name: String?, playlist: MusicDirectory )</ID>
<ID>LongMethod:RestErrorMapper.kt$ fun SubsonicRESTException.getLocalizedErrorMessage(context: Context): String</ID>
<ID>LongMethod:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
@ -200,8 +200,8 @@
<ID>ReturnCount:CommunicationErrorHandler.kt$CommunicationErrorHandler.Companion$fun getErrorMessage(error: Throwable, context: Context): String</ID>
<ID>ReturnCount:FileLoggerTree.kt$FileLoggerTree$ private fun getNextLogFile()</ID>
<ID>ReturnCount:MediaPlayerService.kt$MediaPlayerService$private fun generateAction(context: Context, requestCode: Int): NotificationCompat.Action?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( context: Context, username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( context: Context, entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
<ID>ReturnCount:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
<ID>ReturnCount:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
<ID>ReturnCount:ServerRowAdapter.kt$ServerRowAdapter$ private fun popupMenuItemClick(menuItem: MenuItem, position: Int): Boolean</ID>

View File

@ -205,7 +205,7 @@ public class BookmarksFragment extends Fragment {
@Override
protected MusicDirectory load(MusicService service) throws Exception
{
return Util.getSongsFromBookmarks(service.getBookmarks(getContext()));
return Util.getSongsFromBookmarks(service.getBookmarks());
}
}.execute();
}

View File

@ -250,7 +250,7 @@ public class ChatFragment extends Fragment {
protected Void doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
musicService.addChatMessage(message, getContext());
musicService.addChatMessage(message);
return null;
}
@ -274,7 +274,7 @@ public class ChatFragment extends Fragment {
protected List<ChatMessage> doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
return musicService.getChatMessages(lastChatMessageTime, getContext());
return musicService.getChatMessages(lastChatMessageTime);
}
@Override

View File

@ -79,7 +79,7 @@ public class LyricsFragment extends Fragment {
String artist = arguments.getString(Constants.INTENT_EXTRA_NAME_ARTIST);
String title = arguments.getString(Constants.INTENT_EXTRA_NAME_TITLE);
MusicService musicService = MusicServiceFactory.getMusicService();
return musicService.getLyrics(artist, title, getContext());
return musicService.getLyrics(artist, title);
}
@Override

View File

@ -1027,7 +1027,7 @@ public class PlayerFragment extends Fragment implements GestureDetector.OnGestur
final MusicService musicService = MusicServiceFactory.getMusicService();
try {
musicService.createBookmark(songId, playerPosition, getContext());
musicService.createBookmark(songId, playerPosition);
} catch (Exception e) {
Timber.e(e);
}
@ -1053,7 +1053,7 @@ public class PlayerFragment extends Fragment implements GestureDetector.OnGestur
final MusicService musicService = MusicServiceFactory.getMusicService();
try {
musicService.deleteBookmark(bookmarkSongId, getContext());
musicService.deleteBookmark(bookmarkSongId);
} catch (Exception e) {
Timber.e(e);
}
@ -1128,7 +1128,7 @@ public class PlayerFragment extends Fragment implements GestureDetector.OnGestur
entries.add(downloadFile.getSong());
}
final MusicService musicService = MusicServiceFactory.getMusicService();
musicService.createPlaylist(null, playlistName, entries, getContext());
musicService.createPlaylist(null, playlistName, entries);
return null;
}

View File

@ -128,7 +128,7 @@ public class PlaylistsFragment extends Fragment {
protected List<Playlist> doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
List<Playlist> playlists = musicService.getPlaylists(refresh, getContext());
List<Playlist> playlists = musicService.getPlaylists(refresh);
if (!ActiveServerProvider.Companion.isOffline())
new CacheCleaner(getContext()).cleanPlaylists(playlists);
@ -223,7 +223,7 @@ public class PlaylistsFragment extends Fragment {
protected Void doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
musicService.deletePlaylist(playlist.getId(), getContext());
musicService.deletePlaylist(playlist.getId());
return null;
}
@ -313,7 +313,7 @@ public class PlaylistsFragment extends Fragment {
String comment = commentBoxText != null ? commentBoxText.toString() : null;
MusicService musicService = MusicServiceFactory.getMusicService();
musicService.updatePlaylist(playlist.getId(), name, comment, publicBox.isChecked(), getContext());
musicService.updatePlaylist(playlist.getId(), name, comment, publicBox.isChecked());
return null;
}

View File

@ -97,7 +97,7 @@ public class PodcastFragment extends Fragment {
protected List<PodcastsChannel> doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
return musicService.getPodcastsChannels(refresh, context);
return musicService.getPodcastsChannels(refresh);
}
@Override

View File

@ -421,7 +421,7 @@ public class SearchFragment extends Fragment {
{
SearchCriteria criteria = new SearchCriteria(query, maxArtists, maxAlbums, maxSongs);
MusicService service = MusicServiceFactory.getMusicService();
return service.search(criteria, getContext());
return service.search(criteria);
}
@Override

View File

@ -129,7 +129,7 @@ public class SharesFragment extends Fragment {
protected List<Share> doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
return musicService.getShares(refresh, getContext());
return musicService.getShares(refresh);
}
@Override
@ -196,7 +196,7 @@ public class SharesFragment extends Fragment {
protected Void doInBackground() throws Throwable
{
MusicService musicService = MusicServiceFactory.getMusicService();
musicService.deleteShare(share.getId(), getContext());
musicService.deleteShare(share.getId());
return null;
}
@ -302,7 +302,7 @@ public class SharesFragment extends Fragment {
String description = shareDescriptionText != null ? shareDescriptionText.toString() : null;
MusicService musicService = MusicServiceFactory.getMusicService();
musicService.updateShare(share.getId(), description, millis, getContext());
musicService.updateShare(share.getId(), description, millis);
return null;
}

View File

@ -159,7 +159,7 @@ public class UltrasonicAppWidgetProvider extends AppWidgetProvider
// Set the cover art
try
{
Bitmap bitmap = currentSong == null ? null : FileUtil.getAlbumArtBitmap(context, currentSong, 240, true);
Bitmap bitmap = currentSong == null ? null : FileUtil.getAlbumArtBitmap(currentSong, 240, true);
if (bitmap == null)
{

View File

@ -18,7 +18,6 @@
*/
package org.moire.ultrasonic.service;
import android.content.Context;
import android.graphics.Bitmap;
import org.moire.ultrasonic.data.ActiveServerProvider;
@ -210,77 +209,77 @@ public class CachedMusicService implements MusicService
}
@Override
public SearchResult search(SearchCriteria criteria, Context context) throws Exception
public SearchResult search(SearchCriteria criteria) throws Exception
{
return musicService.search(criteria, context);
return musicService.search(criteria);
}
@Override
public MusicDirectory getPlaylist(String id, String name, Context context) throws Exception
public MusicDirectory getPlaylist(String id, String name) throws Exception
{
return musicService.getPlaylist(id, name, context);
return musicService.getPlaylist(id, name);
}
@Override
public List<PodcastsChannel> getPodcastsChannels(boolean refresh, Context context) throws Exception {
public List<PodcastsChannel> getPodcastsChannels(boolean refresh) throws Exception {
checkSettingsChanged();
List<PodcastsChannel> result = refresh ? null : cachedPodcastsChannels.get();
if (result == null)
{
result = musicService.getPodcastsChannels(refresh, context);
result = musicService.getPodcastsChannels(refresh);
cachedPodcastsChannels.set(result);
}
return result;
}
@Override
public MusicDirectory getPodcastEpisodes(String podcastChannelId, Context context) throws Exception {
return musicService.getPodcastEpisodes(podcastChannelId,context);
public MusicDirectory getPodcastEpisodes(String podcastChannelId) throws Exception {
return musicService.getPodcastEpisodes(podcastChannelId);
}
@Override
public List<Playlist> getPlaylists(boolean refresh, Context context) throws Exception
public List<Playlist> getPlaylists(boolean refresh) throws Exception
{
checkSettingsChanged();
List<Playlist> result = refresh ? null : cachedPlaylists.get();
if (result == null)
{
result = musicService.getPlaylists(refresh, context);
result = musicService.getPlaylists(refresh);
cachedPlaylists.set(result);
}
return result;
}
@Override
public void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries, Context context) throws Exception
public void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries) throws Exception
{
cachedPlaylists.clear();
musicService.createPlaylist(id, name, entries, context);
musicService.createPlaylist(id, name, entries);
}
@Override
public void deletePlaylist(String id, Context context) throws Exception
public void deletePlaylist(String id) throws Exception
{
musicService.deletePlaylist(id, context);
musicService.deletePlaylist(id);
}
@Override
public void updatePlaylist(String id, String name, String comment, boolean pub, Context context) throws Exception
public void updatePlaylist(String id, String name, String comment, boolean pub) throws Exception
{
musicService.updatePlaylist(id, name, comment, pub, context);
musicService.updatePlaylist(id, name, comment, pub);
}
@Override
public Lyrics getLyrics(String artist, String title, Context context) throws Exception
public Lyrics getLyrics(String artist, String title) throws Exception
{
return musicService.getLyrics(artist, title, context);
return musicService.getLyrics(artist, title);
}
@Override
public void scrobble(String id, boolean submission, Context context) throws Exception
public void scrobble(String id, boolean submission) throws Exception
{
musicService.scrobble(id, submission, context);
musicService.scrobble(id, submission);
}
@Override
@ -296,9 +295,9 @@ public class CachedMusicService implements MusicService
}
@Override
public MusicDirectory getRandomSongs(int size, Context context) throws Exception
public MusicDirectory getRandomSongs(int size) throws Exception
{
return musicService.getRandomSongs(size, context);
return musicService.getRandomSongs(size);
}
@Override
@ -314,9 +313,9 @@ public class CachedMusicService implements MusicService
}
@Override
public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, boolean saveToFile, boolean highQuality) throws Exception
public Bitmap getCoverArt(MusicDirectory.Entry entry, int size, boolean saveToFile, boolean highQuality) throws Exception
{
return musicService.getCoverArt(context, entry, size, saveToFile, highQuality);
return musicService.getCoverArt(entry, size, saveToFile, highQuality);
}
@Override
@ -326,45 +325,45 @@ public class CachedMusicService implements MusicService
}
@Override
public String getVideoUrl(Context context, String id, boolean useFlash) throws Exception
public String getVideoUrl(String id, boolean useFlash) throws Exception
{
return musicService.getVideoUrl(context, id, useFlash);
return musicService.getVideoUrl(id, useFlash);
}
@Override
public JukeboxStatus updateJukeboxPlaylist(List<String> ids, Context context) throws Exception
public JukeboxStatus updateJukeboxPlaylist(List<String> ids) throws Exception
{
return musicService.updateJukeboxPlaylist(ids, context);
return musicService.updateJukeboxPlaylist(ids);
}
@Override
public JukeboxStatus skipJukebox(int index, int offsetSeconds, Context context) throws Exception
public JukeboxStatus skipJukebox(int index, int offsetSeconds) throws Exception
{
return musicService.skipJukebox(index, offsetSeconds, context);
return musicService.skipJukebox(index, offsetSeconds);
}
@Override
public JukeboxStatus stopJukebox(Context context) throws Exception
public JukeboxStatus stopJukebox() throws Exception
{
return musicService.stopJukebox(context);
return musicService.stopJukebox();
}
@Override
public JukeboxStatus startJukebox(Context context) throws Exception
public JukeboxStatus startJukebox() throws Exception
{
return musicService.startJukebox(context);
return musicService.startJukebox();
}
@Override
public JukeboxStatus getJukeboxStatus(Context context) throws Exception
public JukeboxStatus getJukeboxStatus() throws Exception
{
return musicService.getJukeboxStatus(context);
return musicService.getJukeboxStatus();
}
@Override
public JukeboxStatus setJukeboxGain(float gain, Context context) throws Exception
public JukeboxStatus setJukeboxGain(float gain) throws Exception
{
return musicService.setJukeboxGain(gain, context);
return musicService.setJukeboxGain(gain);
}
private void checkSettingsChanged()
@ -434,49 +433,49 @@ public class CachedMusicService implements MusicService
}
@Override
public MusicDirectory getSongsByGenre(String genre, int count, int offset, Context context) throws Exception
public MusicDirectory getSongsByGenre(String genre, int count, int offset) throws Exception
{
return musicService.getSongsByGenre(genre, count, offset, context);
return musicService.getSongsByGenre(genre, count, offset);
}
@Override
public List<Share> getShares(boolean refresh, Context context) throws Exception
public List<Share> getShares(boolean refresh) throws Exception
{
return musicService.getShares(refresh, context);
return musicService.getShares(refresh);
}
@Override
public List<ChatMessage> getChatMessages(Long since, Context context) throws Exception
public List<ChatMessage> getChatMessages(Long since) throws Exception
{
return musicService.getChatMessages(since, context);
return musicService.getChatMessages(since);
}
@Override
public void addChatMessage(String message, Context context) throws Exception
public void addChatMessage(String message) throws Exception
{
musicService.addChatMessage(message, context);
musicService.addChatMessage(message);
}
@Override
public List<Bookmark> getBookmarks(Context context) throws Exception
public List<Bookmark> getBookmarks() throws Exception
{
return musicService.getBookmarks(context);
return musicService.getBookmarks();
}
@Override
public void deleteBookmark(String id, Context context) throws Exception
public void deleteBookmark(String id) throws Exception
{
musicService.deleteBookmark(id, context);
musicService.deleteBookmark(id);
}
@Override
public void createBookmark(String id, int position, Context context) throws Exception
public void createBookmark(String id, int position) throws Exception
{
musicService.createBookmark(id, position, context);
musicService.createBookmark(id, position);
}
@Override
public MusicDirectory getVideos(boolean refresh, Context context) throws Exception
public MusicDirectory getVideos(boolean refresh) throws Exception
{
checkSettingsChanged();
TimeLimitedCache<MusicDirectory> cache = refresh ? null : cachedMusicDirectories.get(Constants.INTENT_EXTRA_NAME_VIDEOS);
@ -485,7 +484,7 @@ public class CachedMusicService implements MusicService
if (dir == null)
{
dir = musicService.getVideos(refresh, context);
dir = musicService.getVideos(refresh);
cache = new TimeLimitedCache<>(Util.getDirectoryCacheTime(), TimeUnit.SECONDS);
cache.set(dir);
cachedMusicDirectories.put(Constants.INTENT_EXTRA_NAME_VIDEOS, cache);
@ -495,7 +494,7 @@ public class CachedMusicService implements MusicService
}
@Override
public UserInfo getUser(String username, Context context) throws Exception
public UserInfo getUser(String username) throws Exception
{
checkSettingsChanged();
@ -505,7 +504,7 @@ public class CachedMusicService implements MusicService
if (userInfo == null)
{
userInfo = musicService.getUser(username, context);
userInfo = musicService.getUser(username);
cache = new TimeLimitedCache<>(Util.getDirectoryCacheTime(), TimeUnit.SECONDS);
cache.set(userInfo);
cachedUserInfo.put(username, cache);
@ -515,26 +514,26 @@ public class CachedMusicService implements MusicService
}
@Override
public List<Share> createShare(List<String> ids, String description, Long expires, Context context) throws Exception
public List<Share> createShare(List<String> ids, String description, Long expires) throws Exception
{
return musicService.createShare(ids, description, expires, context);
return musicService.createShare(ids, description, expires);
}
@Override
public void deleteShare(String id, Context context) throws Exception
public void deleteShare(String id) throws Exception
{
musicService.deleteShare(id, context);
musicService.deleteShare(id);
}
@Override
public void updateShare(String id, String description, Long expires, Context context) throws Exception
public void updateShare(String id, String description, Long expires) throws Exception
{
musicService.updateShare(id, description, expires, context);
musicService.updateShare(id, description, expires);
}
@Override
public Bitmap getAvatar(Context context, String username, int size, boolean saveToFile, boolean highQuality) throws Exception
public Bitmap getAvatar(String username, int size, boolean saveToFile, boolean highQuality) throws Exception
{
return musicService.getAvatar(context, username, size, saveToFile, highQuality);
return musicService.getAvatar(username, size, saveToFile, highQuality);
}
}

View File

@ -397,7 +397,7 @@ public class JukeboxMediaPlayer
@Override
JukeboxStatus execute() throws Exception
{
return getMusicService().getJukeboxStatus(context);
return getMusicService().getJukeboxStatus();
}
}
@ -413,7 +413,7 @@ public class JukeboxMediaPlayer
@Override
JukeboxStatus execute() throws Exception
{
return getMusicService().updateJukeboxPlaylist(ids, context);
return getMusicService().updateJukeboxPlaylist(ids);
}
}
@ -431,7 +431,7 @@ public class JukeboxMediaPlayer
@Override
JukeboxStatus execute() throws Exception
{
return getMusicService().skipJukebox(index, offsetSeconds, context);
return getMusicService().skipJukebox(index, offsetSeconds);
}
}
@ -440,7 +440,7 @@ public class JukeboxMediaPlayer
@Override
JukeboxStatus execute() throws Exception
{
return getMusicService().stopJukebox(context);
return getMusicService().stopJukebox();
}
}
@ -449,7 +449,7 @@ public class JukeboxMediaPlayer
@Override
JukeboxStatus execute() throws Exception
{
return getMusicService().startJukebox(context);
return getMusicService().startJukebox();
}
}
@ -466,7 +466,7 @@ public class JukeboxMediaPlayer
@Override
JukeboxStatus execute() throws Exception
{
return getMusicService().setJukeboxGain(gain, context);
return getMusicService().setJukeboxGain(gain);
}
}

View File

@ -527,7 +527,7 @@ public class MediaPlayerControllerImpl implements MediaPlayerController
try
{
String username = activeServerProvider.getValue().getActiveServer().getUserName();
UserInfo user = MusicServiceFactory.getMusicService().getUser(username, context);
UserInfo user = MusicServiceFactory.getMusicService().getUser(username);
return user.getJukeboxRole();
}
catch (Exception e)

View File

@ -18,7 +18,6 @@
*/
package org.moire.ultrasonic.service;
import android.content.Context;
import android.graphics.Bitmap;
import org.moire.ultrasonic.domain.Bookmark;
@ -71,82 +70,82 @@ public interface MusicService
MusicDirectory getAlbum(String id, String name, boolean refresh) throws Exception;
SearchResult search(SearchCriteria criteria, Context context) throws Exception;
SearchResult search(SearchCriteria criteria) throws Exception;
MusicDirectory getPlaylist(String id, String name, Context context) throws Exception;
MusicDirectory getPlaylist(String id, String name) throws Exception;
List<PodcastsChannel> getPodcastsChannels(boolean refresh, Context context) throws Exception;
List<PodcastsChannel> getPodcastsChannels(boolean refresh) throws Exception;
List<Playlist> getPlaylists(boolean refresh, Context context) throws Exception;
List<Playlist> getPlaylists(boolean refresh) throws Exception;
void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries, Context context) throws Exception;
void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries) throws Exception;
void deletePlaylist(String id, Context context) throws Exception;
void deletePlaylist(String id) throws Exception;
void updatePlaylist(String id, String name, String comment, boolean pub, Context context) throws Exception;
void updatePlaylist(String id, String name, String comment, boolean pub) throws Exception;
Lyrics getLyrics(String artist, String title, Context context) throws Exception;
Lyrics getLyrics(String artist, String title) throws Exception;
void scrobble(String id, boolean submission, Context context) throws Exception;
void scrobble(String id, boolean submission) throws Exception;
MusicDirectory getAlbumList(String type, int size, int offset, String musicFolderId) throws Exception;
MusicDirectory getAlbumList2(String type, int size, int offset, String musicFolderId) throws Exception;
MusicDirectory getRandomSongs(int size, Context context) throws Exception;
MusicDirectory getRandomSongs(int size) throws Exception;
MusicDirectory getSongsByGenre(String genre, int count, int offset, Context context) throws Exception;
MusicDirectory getSongsByGenre(String genre, int count, int offset) throws Exception;
SearchResult getStarred() throws Exception;
SearchResult getStarred2() throws Exception;
Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, boolean saveToFile, boolean highQuality) throws Exception;
Bitmap getCoverArt(MusicDirectory.Entry entry, int size, boolean saveToFile, boolean highQuality) throws Exception;
/**
Bitmap getAvatar(String username, int size, boolean saveToFile, boolean highQuality) throws Exception;
/**
* Return response {@link InputStream} and a {@link Boolean} that indicates if this response is
* partial.
*/
Pair<InputStream, Boolean> getDownloadInputStream(MusicDirectory.Entry song, long offset, int maxBitrate) throws Exception;
// TODO: Refactor and remove this call (see RestMusicService implementation)
String getVideoUrl(Context context, String id, boolean useFlash) throws Exception;
String getVideoUrl(String id, boolean useFlash) throws Exception;
JukeboxStatus updateJukeboxPlaylist(List<String> ids, Context context) throws Exception;
JukeboxStatus updateJukeboxPlaylist(List<String> ids) throws Exception;
JukeboxStatus skipJukebox(int index, int offsetSeconds, Context context) throws Exception;
JukeboxStatus skipJukebox(int index, int offsetSeconds) throws Exception;
JukeboxStatus stopJukebox(Context context) throws Exception;
JukeboxStatus stopJukebox() throws Exception;
JukeboxStatus startJukebox(Context context) throws Exception;
JukeboxStatus startJukebox() throws Exception;
JukeboxStatus getJukeboxStatus(Context context) throws Exception;
JukeboxStatus getJukeboxStatus() throws Exception;
JukeboxStatus setJukeboxGain(float gain, Context context) throws Exception;
JukeboxStatus setJukeboxGain(float gain) throws Exception;
List<Share> getShares(boolean refresh, Context context) throws Exception;
List<Share> getShares(boolean refresh) throws Exception;
List<ChatMessage> getChatMessages(Long since, Context context) throws Exception;
List<ChatMessage> getChatMessages(Long since) throws Exception;
void addChatMessage(String message, Context context) throws Exception;
void addChatMessage(String message) throws Exception;
List<Bookmark> getBookmarks(Context context) throws Exception;
List<Bookmark> getBookmarks() throws Exception;
void deleteBookmark(String id, Context context) throws Exception;
void deleteBookmark(String id) throws Exception;
void createBookmark(String id, int position, Context context) throws Exception;
void createBookmark(String id, int position) throws Exception;
MusicDirectory getVideos(boolean refresh, Context context) throws Exception;
MusicDirectory getVideos(boolean refresh) throws Exception;
UserInfo getUser(String username, Context context) throws Exception;
UserInfo getUser(String username) throws Exception;
List<Share> createShare(List<String> ids, String description, Long expires, Context context) throws Exception;
List<Share> createShare(List<String> ids, String description, Long expires) throws Exception;
void deleteShare(String id, Context context) throws Exception;
void deleteShare(String id) throws Exception;
void updateShare(String id, String description, Long expires, Context context) throws Exception;
void updateShare(String id, String description, Long expires) throws Exception;
Bitmap getAvatar(Context context, String username, int size, boolean saveToFile, boolean highQuality) throws Exception;
MusicDirectory getPodcastEpisodes(String podcastChannelId, Context context) throws Exception;
MusicDirectory getPodcastEpisodes(String podcastChannelId) throws Exception;
}

View File

@ -18,7 +18,6 @@
*/
package org.moire.ultrasonic.service;
import android.content.Context;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
@ -333,7 +332,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public Bitmap getAvatar(Context context, String username, int size, boolean saveToFile, boolean highQuality)
public Bitmap getAvatar(String username, int size, boolean saveToFile, boolean highQuality)
{
try
{
@ -347,11 +346,11 @@ public class OfflineMusicService implements MusicService
}
@Override
public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, boolean saveToFile, boolean highQuality)
public Bitmap getCoverArt(MusicDirectory.Entry entry, int size, boolean saveToFile, boolean highQuality)
{
try
{
Bitmap bitmap = FileUtil.getAlbumArtBitmap(context, entry, size, highQuality);
Bitmap bitmap = FileUtil.getAlbumArtBitmap(entry, size, highQuality);
return Util.scaleBitmap(bitmap, size);
}
catch (Exception e)
@ -361,7 +360,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public SearchResult search(SearchCriteria criteria, Context context)
public SearchResult search(SearchCriteria criteria)
{
List<Artist> artists = new ArrayList<>();
List<MusicDirectory.Entry> albums = new ArrayList<>();
@ -384,7 +383,7 @@ public class OfflineMusicService implements MusicService
artists.add(artist);
}
recursiveAlbumSearch(artistName, artistFile, criteria, context, albums, songs);
recursiveAlbumSearch(artistName, artistFile, criteria, albums, songs);
}
}
@ -431,7 +430,7 @@ public class OfflineMusicService implements MusicService
return new SearchResult(artists, albums, songs);
}
private static void recursiveAlbumSearch(String artistName, File file, SearchCriteria criteria, Context context, List<MusicDirectory.Entry> albums, List<MusicDirectory.Entry> songs)
private static void recursiveAlbumSearch(String artistName, File file, SearchCriteria criteria, List<MusicDirectory.Entry> albums, List<MusicDirectory.Entry> songs)
{
int closeness;
@ -454,7 +453,7 @@ public class OfflineMusicService implements MusicService
if (songFile.isDirectory())
{
recursiveAlbumSearch(artistName, songFile, criteria, context, albums, songs);
recursiveAlbumSearch(artistName, songFile, criteria, albums, songs);
}
else if ((closeness = matchCriteria(criteria, songName)) > 0)
{
@ -505,7 +504,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public List<Playlist> getPlaylists(boolean refresh, Context context)
public List<Playlist> getPlaylists(boolean refresh)
{
List<Playlist> playlists = new ArrayList<>();
File root = FileUtil.getPlaylistDirectory();
@ -564,7 +563,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public MusicDirectory getPlaylist(String id, String name, Context context) throws Exception
public MusicDirectory getPlaylist(String id, String name) throws Exception
{
Reader reader = null;
BufferedReader buffer = null;
@ -606,7 +605,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries, Context context) throws Exception
public void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries) throws Exception
{
File playlistFile = FileUtil.getPlaylistFile(activeServerProvider.getValue().getActiveServer().getName(), name);
FileWriter fw = new FileWriter(playlistFile);
@ -639,7 +638,7 @@ public class OfflineMusicService implements MusicService
@Override
public MusicDirectory getRandomSongs(int size, Context context)
public MusicDirectory getRandomSongs(int size)
{
File root = FileUtil.getMusicDirectory();
List<File> children = new LinkedList<>();
@ -677,25 +676,25 @@ public class OfflineMusicService implements MusicService
}
@Override
public void deletePlaylist(String id, Context context) throws Exception
public void deletePlaylist(String id) throws Exception
{
throw new OfflineException("Playlists not available in offline mode");
}
@Override
public void updatePlaylist(String id, String name, String comment, boolean pub, Context context) throws Exception
public void updatePlaylist(String id, String name, String comment, boolean pub) throws Exception
{
throw new OfflineException("Updating playlist not available in offline mode");
}
@Override
public Lyrics getLyrics(String artist, String title, Context context) throws Exception
public Lyrics getLyrics(String artist, String title) throws Exception
{
throw new OfflineException("Lyrics not available in offline mode");
}
@Override
public void scrobble(String id, boolean submission, Context context) throws Exception
public void scrobble(String id, boolean submission) throws Exception
{
throw new OfflineException("Scrobbling not available in offline mode");
}
@ -707,37 +706,37 @@ public class OfflineMusicService implements MusicService
}
@Override
public JukeboxStatus updateJukeboxPlaylist(List<String> ids, Context context) throws Exception
public JukeboxStatus updateJukeboxPlaylist(List<String> ids) throws Exception
{
throw new OfflineException("Jukebox not available in offline mode");
}
@Override
public JukeboxStatus skipJukebox(int index, int offsetSeconds, Context context) throws Exception
public JukeboxStatus skipJukebox(int index, int offsetSeconds) throws Exception
{
throw new OfflineException("Jukebox not available in offline mode");
}
@Override
public JukeboxStatus stopJukebox(Context context) throws Exception
public JukeboxStatus stopJukebox() throws Exception
{
throw new OfflineException("Jukebox not available in offline mode");
}
@Override
public JukeboxStatus startJukebox(Context context) throws Exception
public JukeboxStatus startJukebox() throws Exception
{
throw new OfflineException("Jukebox not available in offline mode");
}
@Override
public JukeboxStatus getJukeboxStatus(Context context) throws Exception
public JukeboxStatus getJukeboxStatus() throws Exception
{
throw new OfflineException("Jukebox not available in offline mode");
}
@Override
public JukeboxStatus setJukeboxGain(float gain, Context context) throws Exception
public JukeboxStatus setJukeboxGain(float gain) throws Exception
{
throw new OfflineException("Jukebox not available in offline mode");
}
@ -749,7 +748,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public MusicDirectory getSongsByGenre(String genre, int count, int offset, Context context) throws Exception
public MusicDirectory getSongsByGenre(String genre, int count, int offset) throws Exception
{
throw new OfflineException("Getting Songs By Genre not available in offline mode");
}
@ -761,31 +760,31 @@ public class OfflineMusicService implements MusicService
}
@Override
public UserInfo getUser(String username, Context context) throws Exception
public UserInfo getUser(String username) throws Exception
{
throw new OfflineException("Getting user info not available in offline mode");
}
@Override
public List<Share> createShare(List<String> ids, String description, Long expires, Context context) throws Exception
public List<Share> createShare(List<String> ids, String description, Long expires) throws Exception
{
throw new OfflineException("Creating shares not available in offline mode");
}
@Override
public List<Share> getShares(boolean refresh, Context context) throws Exception
public List<Share> getShares(boolean refresh) throws Exception
{
throw new OfflineException("Getting shares not available in offline mode");
}
@Override
public void deleteShare(String id, Context context) throws Exception
public void deleteShare(String id) throws Exception
{
throw new OfflineException("Deleting shares not available in offline mode");
}
@Override
public void updateShare(String id, String description, Long expires, Context context) throws Exception
public void updateShare(String id, String description, Long expires) throws Exception
{
throw new OfflineException("Updating shares not available in offline mode");
}
@ -814,40 +813,40 @@ public class OfflineMusicService implements MusicService
}
@Override
public String getVideoUrl(Context context, String id, boolean useFlash) {
public String getVideoUrl(String id, boolean useFlash) {
Timber.w("OfflineMusicService.getVideoUrl was called but it isn't available");
return null;
}
@Override
public List<ChatMessage> getChatMessages(Long since, Context context) {
public List<ChatMessage> getChatMessages(Long since) {
Timber.w("OfflineMusicService.getChatMessages was called but it isn't available");
return null;
}
@Override
public void addChatMessage(String message, Context context) {
public void addChatMessage(String message) {
Timber.w("OfflineMusicService.addChatMessage was called but it isn't available");
}
@Override
public List<Bookmark> getBookmarks(Context context) {
public List<Bookmark> getBookmarks() {
Timber.w("OfflineMusicService.getBookmarks was called but it isn't available");
return null;
}
@Override
public void deleteBookmark(String id, Context context) {
public void deleteBookmark(String id) {
Timber.w("OfflineMusicService.deleteBookmark was called but it isn't available");
}
@Override
public void createBookmark(String id, int position, Context context) {
public void createBookmark(String id, int position) {
Timber.w("OfflineMusicService.createBookmark was called but it isn't available");
}
@Override
public MusicDirectory getVideos(boolean refresh, Context context) {
public MusicDirectory getVideos(boolean refresh) {
Timber.w("OfflineMusicService.getVideos was called but it isn't available");
return null;
}
@ -886,7 +885,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public MusicDirectory getPodcastEpisodes(String podcastChannelId, Context context) {
public MusicDirectory getPodcastEpisodes(String podcastChannelId) {
Timber.w("OfflineMusicService.getPodcastEpisodes was called but it isn't available");
return null;
}
@ -903,7 +902,7 @@ public class OfflineMusicService implements MusicService
}
@Override
public List<PodcastsChannel> getPodcastsChannels(boolean refresh, Context context) {
public List<PodcastsChannel> getPodcastsChannels(boolean refresh) {
Timber.w("OfflineMusicService.getPodcastsChannels was called but it isn't available");
return null;
}

View File

@ -39,7 +39,7 @@ public class Scrobbler
MusicService service = MusicServiceFactory.getMusicService();
try
{
service.scrobble(id, submission, context);
service.scrobble(id, submission);
Timber.i("Scrobbled '%s' for %s", submission ? "submission" : "now playing", song);
}
catch (Exception x)

View File

@ -214,7 +214,7 @@ public class FileUtil
return null;
}
public static Bitmap getAlbumArtBitmap(Context context, MusicDirectory.Entry entry, int size, boolean highQuality)
public static Bitmap getAlbumArtBitmap(MusicDirectory.Entry entry, int size, boolean highQuality)
{
if (entry == null) return null;

View File

@ -419,8 +419,8 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
MusicService musicService = MusicServiceFactory.getMusicService();
final boolean isAvatar = this.username != null && this.entry == null;
final Bitmap bitmap = this.entry != null ?
musicService.getCoverArt(view.getContext(), entry, size, saveToFile, highQuality) :
musicService.getAvatar(view.getContext(), username, size, saveToFile, highQuality);
musicService.getCoverArt(entry, size, saveToFile, highQuality) :
musicService.getAvatar(username, size, saveToFile, highQuality);
if (bitmap == null) {
Timber.d("Found empty album art.");

View File

@ -106,7 +106,7 @@ public class ShufflePlayBuffer
{
MusicService service = MusicServiceFactory.getMusicService();
int n = CAPACITY - buffer.size();
MusicDirectory songs = service.getRandomSongs(n, context);
MusicDirectory songs = service.getRandomSongs(n);
synchronized (buffer)
{

View File

@ -137,7 +137,6 @@ public class Util
return preferences.getBoolean(Constants.PREFERENCES_KEY_ALWAYS_SHOW_NOTIFICATION, false);
}
@SuppressWarnings({"BooleanMethodIsAlwaysInverted"}) // It is inverted for readability
public static boolean isLockScreenEnabled()
{
SharedPreferences preferences = getPreferences();
@ -1061,7 +1060,7 @@ public class Util
return preferences.getBoolean(Constants.PREFERENCES_KEY_ID3_TAGS, false);
}
public static boolean getShouldShowArtistPicture(Context context)
public static boolean getShouldShowArtistPicture()
{
SharedPreferences preferences = getPreferences();
boolean isOffline = ActiveServerProvider.Companion.isOffline();
@ -1082,7 +1081,6 @@ public class Util
return Integer.parseInt(preferences.getString(Constants.PREFERENCES_KEY_DIRECTORY_CACHE_TIME, "300"));
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted") // Inverted for readability
public static boolean isNullOrWhiteSpace(String string)
{
return string == null || string.isEmpty() || string.trim().isEmpty();

View File

@ -79,7 +79,7 @@ public enum VideoPlayerType
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(installedPro ? PACKAGE_NAME_MX_PRO : PACKAGE_NAME_MX_AD);
intent.putExtra("title", entry.getTitle());
intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService().getVideoUrl(context, entry.getId(), false)), "video/*");
intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService().getVideoUrl(entry.getId(), false)), "video/*");
context.startActivity(intent);
}
}
@ -91,7 +91,7 @@ public enum VideoPlayerType
public void playVideo(Context context, MusicDirectory.Entry entry) throws Exception
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(MusicServiceFactory.getMusicService().getVideoUrl(context, entry.getId(), true)));
intent.setData(Uri.parse(MusicServiceFactory.getMusicService().getVideoUrl(entry.getId(), true)));
context.startActivity(intent);
}
},
@ -102,7 +102,7 @@ public enum VideoPlayerType
public void playVideo(Context context, MusicDirectory.Entry entry) throws Exception
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService().getVideoUrl(context, entry.getId(), false)), "video/*");
intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService().getVideoUrl(entry.getId(), false)), "video/*");
context.startActivity(intent);
}
};

View File

@ -98,7 +98,7 @@ class ArtistRowAdapter(
holder.layout.setOnLongClickListener { view -> createPopupMenu(view, listPosition) }
holder.coverArtId = artistList[listPosition].coverArt
if (Util.getShouldShowArtistPicture(holder.coverArt.context)) {
if (Util.getShouldShowArtistPicture()) {
holder.coverArt.visibility = View.VISIBLE
imageLoader.loadImage(
holder.coverArt,

View File

@ -200,7 +200,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
suspend fun getSongsForGenre(genre: String, count: Int, offset: Int) {
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()
val musicDirectory = service.getSongsByGenre(genre, count, offset, context)
val musicDirectory = service.getSongsByGenre(genre, count, offset)
songsForGenre.postValue(musicDirectory)
}
}
@ -227,7 +227,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()
currentDirectory.postValue(service.getVideos(refresh, context))
currentDirectory.postValue(service.getVideos(refresh))
}
}
@ -235,7 +235,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()
val musicDirectory = service.getRandomSongs(size, context)
val musicDirectory = service.getRandomSongs(size)
currentDirectoryIsSortable = false
currentDirectory.postValue(musicDirectory)
@ -246,7 +246,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()
val musicDirectory = service.getPlaylist(playlistId, playlistName, context)
val musicDirectory = service.getPlaylist(playlistId, playlistName)
currentDirectory.postValue(musicDirectory)
}
@ -256,7 +256,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
withContext(Dispatchers.IO) {
val service = MusicServiceFactory.getMusicService()
val musicDirectory = service.getPodcastEpisodes(podcastChannelId, context)
val musicDirectory = service.getPodcastEpisodes(podcastChannelId)
currentDirectory.postValue(musicDirectory)
}
}
@ -267,7 +267,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
val service = MusicServiceFactory.getMusicService()
val musicDirectory = MusicDirectory()
val shares = service.getShares(true, context)
val shares = service.getShares(true)
for (share in shares) {
if (share.id == shareId) {

View File

@ -330,7 +330,7 @@ class DownloadFile(
try {
if (!TextUtils.isEmpty(song.coverArt)) {
val size = Util.getMinDisplayMetric(context)
musicService.getCoverArt(context, song, size, true, true)
musicService.getCoverArt(song, size, true, true)
}
} catch (x: Exception) {
Timber.e(x, "Failed to get cover art.")

View File

@ -417,14 +417,13 @@ class MediaPlayerService : Service() {
private fun setupOnSongCompletedHandler() {
localMediaPlayer.onSongCompleted = { currentPlaying: DownloadFile? ->
val index = downloader.currentPlayingIndex
val context = this@MediaPlayerService
if (currentPlaying != null) {
val song = currentPlaying.song
if (song.bookmarkPosition > 0 && Util.getShouldClearBookmark()) {
val musicService = getMusicService()
try {
musicService.deleteBookmark(song.id, context)
musicService.deleteBookmark(song.id)
} catch (ignored: Exception) {
}
}
@ -480,8 +479,8 @@ class MediaPlayerService : Service() {
try {
val song = currentPlaying.song
val cover = FileUtil.getAlbumArtBitmap(
context, song,
Util.getMinDisplayMetric(context), true
song, Util.getMinDisplayMetric(context),
true
)
metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, -1L)
metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.artist)
@ -648,7 +647,7 @@ class MediaPlayerService : Service() {
// Set song title, artist and cover if possible
if (song != null) {
val iconSize = (256 * context.resources.displayMetrics.density).toInt()
val bitmap = FileUtil.getAlbumArtBitmap(context, song, iconSize, true)
val bitmap = FileUtil.getAlbumArtBitmap(song, iconSize, true)
notificationBuilder!!.setContentTitle(song.title)
notificationBuilder!!.setContentText(song.artist)
notificationBuilder!!.setLargeIcon(bitmap)

View File

@ -18,7 +18,6 @@
*/
package org.moire.ultrasonic.service
import android.content.Context
import android.graphics.Bitmap
import android.text.TextUtils
import java.io.BufferedWriter
@ -204,8 +203,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun search(
criteria: SearchCriteria,
context: Context
criteria: SearchCriteria
): SearchResult {
return try {
if (
@ -270,8 +268,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getPlaylist(
id: String,
name: String?,
context: Context
name: String?
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api ->
api.getPlaylist(id).execute()
@ -318,8 +315,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getPlaylists(
refresh: Boolean,
context: Context
refresh: Boolean
): List<Playlist> {
val response = responseChecker.callWithResponseCheck { api ->
api.getPlaylists(null).execute()
@ -332,8 +328,7 @@ open class RESTMusicService(
override fun createPlaylist(
id: String?,
name: String?,
entries: List<MusicDirectory.Entry>,
context: Context
entries: List<MusicDirectory.Entry>
) {
val pSongIds: MutableList<String> = ArrayList(entries.size)
@ -349,8 +344,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun deletePlaylist(
id: String,
context: Context
id: String
) {
responseChecker.callWithResponseCheck { api -> api.deletePlaylist(id).execute() }
}
@ -360,8 +354,7 @@ open class RESTMusicService(
id: String,
name: String?,
comment: String?,
pub: Boolean,
context: Context?
pub: Boolean
) {
responseChecker.callWithResponseCheck { api ->
api.updatePlaylist(id, name, comment, pub, null, null)
@ -371,8 +364,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getPodcastsChannels(
refresh: Boolean,
context: Context
refresh: Boolean
): List<PodcastsChannel> {
val response = responseChecker.callWithResponseCheck { api ->
api.getPodcasts(false, null).execute()
@ -383,8 +375,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getPodcastEpisodes(
podcastChannelId: String?,
context: Context
podcastChannelId: String?
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api ->
api.getPodcasts(true, podcastChannelId).execute()
@ -410,8 +401,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getLyrics(
artist: String?,
title: String?,
context: Context
title: String?
): Lyrics {
val response = responseChecker.callWithResponseCheck { api ->
api.getLyrics(artist, title).execute()
@ -423,8 +413,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun scrobble(
id: String,
submission: Boolean,
context: Context
submission: Boolean
) {
responseChecker.callWithResponseCheck { api ->
api.scrobble(id, null, submission).execute()
@ -477,8 +466,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getRandomSongs(
size: Int,
context: Context
size: Int
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api ->
api.getRandomSongs(
@ -516,7 +504,6 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getCoverArt(
context: Context,
entry: MusicDirectory.Entry?,
size: Int,
saveToFile: Boolean,
@ -530,7 +517,7 @@ open class RESTMusicService(
synchronized(entry) {
// Use cached file, if existing.
var bitmap = FileUtil.getAlbumArtBitmap(context, entry, size, highQuality)
var bitmap = FileUtil.getAlbumArtBitmap(entry, size, highQuality)
val serverScaling = isServerScalingEnabled()
if (bitmap == null) {
@ -613,7 +600,6 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getVideoUrl(
context: Context,
id: String,
useFlash: Boolean
): String {
@ -641,8 +627,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun updateJukeboxPlaylist(
ids: List<String>?,
context: Context
ids: List<String>?
): JukeboxStatus {
val response = responseChecker.callWithResponseCheck { api ->
api.jukeboxControl(JukeboxAction.SET, null, null, ids, null)
@ -655,8 +640,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun skipJukebox(
index: Int,
offsetSeconds: Int,
context: Context
offsetSeconds: Int
): JukeboxStatus {
val response = responseChecker.callWithResponseCheck { api ->
api.jukeboxControl(JukeboxAction.SKIP, index, offsetSeconds, null, null)
@ -667,9 +651,7 @@ open class RESTMusicService(
}
@Throws(Exception::class)
override fun stopJukebox(
context: Context
): JukeboxStatus {
override fun stopJukebox(): JukeboxStatus {
val response = responseChecker.callWithResponseCheck { api ->
api.jukeboxControl(JukeboxAction.STOP, null, null, null, null)
.execute()
@ -679,9 +661,7 @@ open class RESTMusicService(
}
@Throws(Exception::class)
override fun startJukebox(
context: Context
): JukeboxStatus {
override fun startJukebox(): JukeboxStatus {
val response = responseChecker.callWithResponseCheck { api ->
api.jukeboxControl(JukeboxAction.START, null, null, null, null)
.execute()
@ -691,9 +671,7 @@ open class RESTMusicService(
}
@Throws(Exception::class)
override fun getJukeboxStatus(
context: Context
): JukeboxStatus {
override fun getJukeboxStatus(): JukeboxStatus {
val response = responseChecker.callWithResponseCheck { api ->
api.jukeboxControl(JukeboxAction.STATUS, null, null, null, null)
.execute()
@ -704,8 +682,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun setJukeboxGain(
gain: Float,
context: Context
gain: Float
): JukeboxStatus {
val response = responseChecker.callWithResponseCheck { api ->
api.jukeboxControl(JukeboxAction.SET_GAIN, null, null, null, gain)
@ -717,8 +694,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getShares(
refresh: Boolean,
context: Context
refresh: Boolean
): List<Share> {
val response = responseChecker.callWithResponseCheck { api -> api.getShares().execute() }
@ -738,8 +714,7 @@ open class RESTMusicService(
override fun getSongsByGenre(
genre: String,
count: Int,
offset: Int,
context: Context
offset: Int
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api ->
api.getSongsByGenre(genre, count, offset, null).execute()
@ -753,8 +728,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getUser(
username: String,
context: Context
username: String
): UserInfo {
val response = responseChecker.callWithResponseCheck { api ->
api.getUser(username).execute()
@ -765,8 +739,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getChatMessages(
since: Long?,
context: Context
since: Long?
): List<ChatMessage> {
val response = responseChecker.callWithResponseCheck { api ->
api.getChatMessages(since).execute()
@ -777,16 +750,13 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun addChatMessage(
message: String,
context: Context
message: String
) {
responseChecker.callWithResponseCheck { api -> api.addChatMessage(message).execute() }
}
@Throws(Exception::class)
override fun getBookmarks(
context: Context
): List<Bookmark> {
override fun getBookmarks(): List<Bookmark> {
val response = responseChecker.callWithResponseCheck { api -> api.getBookmarks().execute() }
return response.body()!!.bookmarkList.toDomainEntitiesList()
@ -795,8 +765,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun createBookmark(
id: String,
position: Int,
context: Context
position: Int
) {
responseChecker.callWithResponseCheck { api ->
api.createBookmark(id, position.toLong(), null).execute()
@ -805,16 +774,14 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun deleteBookmark(
id: String,
context: Context
id: String
) {
responseChecker.callWithResponseCheck { api -> api.deleteBookmark(id).execute() }
}
@Throws(Exception::class)
override fun getVideos(
refresh: Boolean,
context: Context
refresh: Boolean
): MusicDirectory {
val response = responseChecker.callWithResponseCheck { api -> api.getVideos().execute() }
@ -828,8 +795,7 @@ open class RESTMusicService(
override fun createShare(
ids: List<String>,
description: String?,
expires: Long?,
context: Context
expires: Long?
): List<Share> {
val response = responseChecker.callWithResponseCheck { api ->
api.createShare(ids, description, expires).execute()
@ -840,8 +806,7 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun deleteShare(
id: String,
context: Context
id: String
) {
responseChecker.callWithResponseCheck { api -> api.deleteShare(id).execute() }
}
@ -850,8 +815,7 @@ open class RESTMusicService(
override fun updateShare(
id: String,
description: String?,
expires: Long?,
context: Context
expires: Long?
) {
var expiresValue: Long? = expires
if (expires != null && expires == 0L) {
@ -865,7 +829,6 @@ open class RESTMusicService(
@Throws(Exception::class)
override fun getAvatar(
context: Context,
username: String?,
size: Int,
saveToFile: Boolean,

View File

@ -215,7 +215,7 @@ class DownloadHandler(
musicService.getMusicDirectory(id, name, false)
} else if (isShare) {
root = MusicDirectory()
val shares = musicService.getShares(true, activity)
val shares = musicService.getShares(true)
for (share in shares) {
if (share.id == id) {
for (entry in share.getEntries()) {
@ -225,7 +225,7 @@ class DownloadHandler(
}
}
} else {
root = musicService.getPlaylist(id, name, activity)
root = musicService.getPlaylist(id, name)
}
getSongsRecursively(root, songs)
}

View File

@ -82,7 +82,7 @@ class ShareHandler(val context: Context) {
timeInMillis = shareDetails.Expiration
}
val shares =
musicService.createShare(ids, shareDetails.Description, timeInMillis, context)
musicService.createShare(ids, shareDetails.Description, timeInMillis)
return shares[0]
}