Search in sources :

Example 1 with Song

use of com.naman14.timber.models.Song in project Timber by naman14.

the class SearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
    switch(getItemViewType(i)) {
        case 0:
            Song song = (Song) searchResults.get(i);
            itemHolder.title.setText(song.title);
            itemHolder.songartist.setText(song.albumName);
            ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(song.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
            setOnPopupMenuListener(itemHolder, i);
            break;
        case 1:
            Album album = (Album) searchResults.get(i);
            itemHolder.albumtitle.setText(album.title);
            itemHolder.albumartist.setText(album.artistName);
            ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(album.id).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
            break;
        case 2:
            Artist artist = (Artist) searchResults.get(i);
            itemHolder.artisttitle.setText(artist.name);
            String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, artist.albumCount);
            String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, artist.songCount);
            itemHolder.albumsongcount.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
            LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(artist.name), new ArtistInfoListener() {

                @Override
                public void artistInfoSucess(LastfmArtist artist) {
                    if (artist != null && itemHolder.artistImage != null) {
                        ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
                    }
                }

                @Override
                public void artistInfoFailed() {
                }
            });
            break;
        case 10:
            itemHolder.sectionHeader.setText((String) searchResults.get(i));
        case 3:
            break;
    }
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) Song(com.naman14.timber.models.Song) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) Album(com.naman14.timber.models.Album) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist)

Example 2 with Song

use of com.naman14.timber.models.Song in project Timber by naman14.

the class ArtistMusicFragment method setUpSongs.

private void setUpSongs() {
    songsRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
    ArrayList<Song> songList;
    songList = ArtistSongLoader.getSongsForArtist(getActivity(), artistID);
    // adding one dummy song to top of arraylist
    //there will be albums header at this position in recyclerview
    songList.add(0, new Song(-1, -1, -1, "dummy", "dummy", "dummy", -1, -1));
    mSongAdapter = new ArtistSongAdapter(getActivity(), songList, artistID);
    songsRecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    songsRecyclerview.setAdapter(mSongAdapter);
}
Also used : Song(com.naman14.timber.models.Song) ArtistSongAdapter(com.naman14.timber.adapters.ArtistSongAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.naman14.timber.widgets.DividerItemDecoration)

Example 3 with Song

use of com.naman14.timber.models.Song in project Timber by naman14.

the class ArtistSongAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
    if (getItemViewType(i) == 0) {
        //nothing
        setUpAlbums(itemHolder.albumsRecyclerView);
    } else {
        Song localItem = arraylist.get(i);
        itemHolder.title.setText(localItem.title);
        itemHolder.album.setText(localItem.albumName);
        ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build());
        setOnPopupMenuListener(itemHolder, i - 1);
    }
}
Also used : Song(com.naman14.timber.models.Song) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 4 with Song

use of com.naman14.timber.models.Song in project Timber by naman14.

the class BaseQueueAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
    Song localItem = arraylist.get(i);
    itemHolder.title.setText(localItem.title);
    itemHolder.artist.setText(localItem.artistName);
    if (MusicPlayer.getCurrentAudioId() == localItem.id) {
        itemHolder.title.setTextColor(Config.accentColor(mContext, ateKey));
        if (MusicPlayer.isPlaying()) {
            itemHolder.visualizer.setColor(Config.accentColor(mContext, ateKey));
            itemHolder.visualizer.setVisibility(View.VISIBLE);
        }
    } else {
        itemHolder.title.setTextColor(Config.textColorPrimary(mContext, ateKey));
        itemHolder.visualizer.setVisibility(View.GONE);
    }
    ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build());
    setOnPopupMenuListener(itemHolder, i);
}
Also used : Song(com.naman14.timber.models.Song) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 5 with Song

use of com.naman14.timber.models.Song in project Timber by naman14.

the class PlayingQueueAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ItemHolder itemHolder, int i) {
    Song localItem = arraylist.get(i);
    itemHolder.title.setText(localItem.title);
    itemHolder.artist.setText(localItem.artistName);
    if (MusicPlayer.getCurrentAudioId() == localItem.id) {
        itemHolder.title.setTextColor(Config.accentColor(mContext, ateKey));
        if (MusicPlayer.isPlaying()) {
            itemHolder.visualizer.setColor(Config.accentColor(mContext, ateKey));
            itemHolder.visualizer.setVisibility(View.VISIBLE);
        }
    } else {
        itemHolder.title.setTextColor(Config.textColorPrimary(mContext, ateKey));
        itemHolder.visualizer.setVisibility(View.GONE);
    }
    ImageLoader.getInstance().displayImage(TimberUtils.getAlbumArtUri(localItem.albumId).toString(), itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build());
    setOnPopupMenuListener(itemHolder, i);
}
Also used : Song(com.naman14.timber.models.Song) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

Song (com.naman14.timber.models.Song)20 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)7 ArrayList (java.util.ArrayList)5 Cursor (android.database.Cursor)3 DividerItemDecoration (com.naman14.timber.widgets.DividerItemDecoration)2 ContentResolver (android.content.ContentResolver)1 Uri (android.net.Uri)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 AlbumSongsAdapter (com.naman14.timber.adapters.AlbumSongsAdapter)1 ArtistSongAdapter (com.naman14.timber.adapters.ArtistSongAdapter)1 TopTracksLoader (com.naman14.timber.dataloaders.TopTracksLoader)1 ArtistInfoListener (com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)1 ArtistQuery (com.naman14.timber.lastfmapi.models.ArtistQuery)1 LastfmArtist (com.naman14.timber.lastfmapi.models.LastfmArtist)1 Album (com.naman14.timber.models.Album)1 Artist (com.naman14.timber.models.Artist)1 DragSortRecycler (com.naman14.timber.widgets.DragSortRecycler)1 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)1 File (java.io.File)1