use of com.naman14.timber.models.Playlist in project Timber by naman14.
the class PlaylistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
final Playlist localItem = arraylist.get(i);
itemHolder.title.setText(localItem.name);
String s = getAlbumArtUri(i, localItem.id);
itemHolder.albumArt.setTag(firstAlbumID);
ImageLoader.getInstance().displayImage(s, itemHolder.albumArt, new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (isGrid) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if (swatch != null) {
int color = swatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(swatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
} else {
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
if (mutedSwatch != null) {
int color = mutedSwatch.getRgb();
itemHolder.footer.setBackgroundColor(color);
int textColor = TimberUtils.getBlackWhiteColor(mutedSwatch.getTitleTextColor());
itemHolder.title.setTextColor(textColor);
itemHolder.artist.setTextColor(textColor);
}
}
}
});
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (isGrid) {
itemHolder.footer.setBackgroundColor(0);
if (mContext != null) {
int textColorPrimary = Config.textColorPrimary(mContext, Helpers.getATEKey(mContext));
itemHolder.title.setTextColor(textColorPrimary);
itemHolder.artist.setTextColor(textColorPrimary);
}
}
}
});
itemHolder.artist.setText(" " + String.valueOf(songCountInt) + " " + mContext.getString(R.string.songs));
if (TimberUtils.isLollipop())
itemHolder.albumArt.setTransitionName("transition_album_art" + i);
}
use of com.naman14.timber.models.Playlist in project Timber by naman14.
the class PlaylistLoader method getPlaylists.
public static List<Playlist> getPlaylists(Context context, boolean defaultIncluded) {
mPlaylistList = new ArrayList<>();
if (defaultIncluded)
makeDefaultPlaylists(context);
mCursor = makePlaylistCursor(context);
if (mCursor != null && mCursor.moveToFirst()) {
do {
final long id = mCursor.getLong(0);
final String name = mCursor.getString(1);
final int songCount = TimberUtils.getSongCountForPlaylist(context, id);
final Playlist playlist = new Playlist(id, name, songCount);
mPlaylistList.add(playlist);
} while (mCursor.moveToNext());
}
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
return mPlaylistList;
}
use of com.naman14.timber.models.Playlist in project Timber by naman14.
the class PlaylistPagerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
showAuto = PreferencesUtility.getInstance(getActivity()).showAutoPlaylist();
View rootView = inflater.inflate(R.layout.fragment_playlist_pager, container, false);
final List<Playlist> playlists = PlaylistLoader.getPlaylists(getActivity(), showAuto);
pageNumber = getArguments().getInt(ARG_PAGE_NUMBER);
playlist = playlists.get(pageNumber);
playlistame = (TextView) rootView.findViewById(R.id.name);
playlistnumber = (TextView) rootView.findViewById(R.id.number);
songcount = (TextView) rootView.findViewById(R.id.songcount);
playlisttype = (TextView) rootView.findViewById(R.id.playlisttype);
playlistImage = (ImageView) rootView.findViewById(R.id.playlist_image);
foreground = rootView.findViewById(R.id.foreground);
playlistImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ArrayList<Pair> tranitionViews = new ArrayList<>();
tranitionViews.add(0, Pair.create((View) playlistame, "transition_playlist_name"));
tranitionViews.add(1, Pair.create((View) playlistImage, "transition_album_art"));
tranitionViews.add(2, Pair.create(foreground, "transition_foreground"));
NavigationUtils.navigateToPlaylistDetail(getActivity(), getPlaylistType(), firstAlbumID, String.valueOf(playlistame.getText()), foregroundColor, playlist.id, tranitionViews);
}
});
mContext = this.getContext();
setUpPlaylistDetails();
return rootView;
}
use of com.naman14.timber.models.Playlist in project Timber by naman14.
the class PlaylistDetailActivity method setUpSongs.
private void setUpSongs() {
Runnable navigation = playlistsMap.get(action);
if (navigation != null) {
navigation.run();
DragSortRecycler dragSortRecycler = new DragSortRecycler();
dragSortRecycler.setViewHandleId(R.id.reorder);
dragSortRecycler.setOnItemMovedListener(new DragSortRecycler.OnItemMovedListener() {
@Override
public void onItemMoved(int from, int to) {
Log.d("playlist", "onItemMoved " + from + " to " + to);
Song song = mAdapter.getSongAt(from);
mAdapter.removeSongAt(from);
mAdapter.addSongTo(to, song);
mAdapter.notifyDataSetChanged();
MediaStore.Audio.Playlists.Members.moveItem(getContentResolver(), playlistID, from, to);
}
});
recyclerView.addItemDecoration(dragSortRecycler);
recyclerView.addOnItemTouchListener(dragSortRecycler);
recyclerView.addOnScrollListener(dragSortRecycler.getScrollListener());
} else {
Log.d("PlaylistDetail", "mo action specified");
}
}
use of com.naman14.timber.models.Playlist in project Timber by naman14.
the class PlaylistLoader method makeDefaultPlaylists.
private static void makeDefaultPlaylists(Context context) {
final Resources resources = context.getResources();
/* Last added list */
final Playlist lastAdded = new Playlist(TimberUtils.PlaylistType.LastAdded.mId, resources.getString(TimberUtils.PlaylistType.LastAdded.mTitleId), -1);
mPlaylistList.add(lastAdded);
/* Recently Played */
final Playlist recentlyPlayed = new Playlist(TimberUtils.PlaylistType.RecentlyPlayed.mId, resources.getString(TimberUtils.PlaylistType.RecentlyPlayed.mTitleId), -1);
mPlaylistList.add(recentlyPlayed);
/* Top Tracks */
final Playlist topTracks = new Playlist(TimberUtils.PlaylistType.TopTracks.mId, resources.getString(TimberUtils.PlaylistType.TopTracks.mTitleId), -1);
mPlaylistList.add(topTracks);
}
Aggregations