Search in sources :

Example 36 with Song

use of com.kabouzeid.gramophone.model.Song in project Phonograph by kabouzeid.

the class ArtistGlideRequest method createBaseRequest.

public static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Artist artist, boolean noCustomImage) {
    boolean hasCustomImage = CustomArtistImageUtil.getInstance(App.getInstance()).hasCustomArtistImage(artist);
    if (noCustomImage || !hasCustomImage) {
        final List<AlbumCover> songs = new ArrayList<>();
        for (final Album album : artist.albums) {
            final Song song = album.safeGetFirstSong();
            songs.add(new AlbumCover(album.getYear(), song.data));
        }
        return requestManager.load(new ArtistImage(artist.getName(), songs));
    } else {
        return requestManager.load(CustomArtistImageUtil.getFile(artist));
    }
}
Also used : Song(com.kabouzeid.gramophone.model.Song) ArrayList(java.util.ArrayList) Album(com.kabouzeid.gramophone.model.Album) AlbumCover(com.kabouzeid.gramophone.glide.artistimage.AlbumCover) ArtistImage(com.kabouzeid.gramophone.glide.artistimage.ArtistImage)

Example 37 with Song

use of com.kabouzeid.gramophone.model.Song in project Phonograph by kabouzeid.

the class M3UWriter method write.

public static File write(Context context, File dir, Playlist playlist) throws IOException {
    if (// noinspection ResultOfMethodCallIgnored
    !dir.exists())
        dir.mkdirs();
    File file = new File(dir, playlist.name.concat("." + EXTENSION));
    List<? extends Song> songs;
    if (playlist instanceof AbsCustomPlaylist) {
        songs = ((AbsCustomPlaylist) playlist).getSongs(context);
    } else {
        songs = PlaylistSongLoader.getPlaylistSongList(context, playlist.id);
    }
    if (songs.size() > 0) {
        BufferedWriter bw = new BufferedWriter(new FileWriter(file));
        bw.write(HEADER);
        for (Song song : songs) {
            bw.newLine();
            bw.write(ENTRY + song.duration + DURATION_SEPARATOR + song.artistName + " - " + song.title);
            bw.newLine();
            bw.write(song.data);
        }
        bw.close();
    }
    return file;
}
Also used : Song(com.kabouzeid.gramophone.model.Song) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) FileWriter(java.io.FileWriter) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Aggregations

Song (com.kabouzeid.gramophone.model.Song)37 Drawable (android.graphics.drawable.Drawable)11 Intent (android.content.Intent)8 Bitmap (android.graphics.Bitmap)7 Point (android.graphics.Point)6 NonNull (androidx.annotation.NonNull)6 Activity (android.app.Activity)5 RemoteViews (android.widget.RemoteViews)5 BitmapPaletteWrapper (com.kabouzeid.gramophone.glide.palette.BitmapPaletteWrapper)5 AbsSlidingMusicPanelActivity (com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity)5 Context (android.content.Context)4 AsyncTask (android.os.AsyncTask)4 TextView (android.widget.TextView)4 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)4 Palette (androidx.palette.graphics.Palette)4 PendingIntent (android.app.PendingIntent)3 View (android.view.View)3 SleepTimerDialog (com.kabouzeid.gramophone.dialogs.SleepTimerDialog)3 ArrayList (java.util.ArrayList)3 ContentValues (android.content.ContentValues)2