use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class ViewPlaylistFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
fragmentTitle = (TextView) view.findViewById(R.id.playlist_fragment_title);
if (SplashActivity.tf4 != null)
fragmentTitle.setTypeface(SplashActivity.tf4);
title = (TextView) view.findViewById(R.id.playlist_title);
title.setText(HomeActivity.tempPlaylist.getPlaylistName());
songsText = (TextView) view.findViewById(R.id.playlist_tracks_text);
String s = "";
if (HomeActivity.tempPlaylist.getSongList().size() > 1)
s = "Songs";
else
s = "Song";
songsText.setText(HomeActivity.tempPlaylist.getSongList().size() + " " + s);
backBtn = (ImageView) view.findViewById(R.id.view_playlist_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
renameIcon = (ImageView) view.findViewById(R.id.rename_playlist_icon);
renameIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.playlistRename();
}
});
addToQueueIcon = (ImageView) view.findViewById(R.id.add_playlist_to_queue_icon);
addToQueueIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.playlistAddToQueue();
}
});
backdrop = (ImageView) view.findViewById(R.id.playlist_backdrop);
UnifiedTrack ut = HomeActivity.tempPlaylist.getSongList().get(0);
if (ut.getType()) {
LocalTrack lt = ut.getLocalTrack();
imgLoader.DisplayImage(lt.getPath(), backdrop);
} else {
Track t = ut.getStreamTrack();
Picasso.with(getContext()).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(backdrop);
}
playlistRecyler = (RecyclerView) view.findViewById(R.id.view_playlist_recycler);
plAdapter = new PlaylistTrackAdapter(HomeActivity.tempPlaylist.getSongList(), this, getContext());
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
playlistRecyler.setLayoutManager(mLayoutManager2);
playlistRecyler.setItemAnimator(new DefaultItemAnimator());
playlistRecyler.setAdapter(plAdapter);
playlistRecyler.addOnItemTouchListener(new ClickItemTouchListener(playlistRecyler) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
mCallback.onPlaylistItemClicked(position);
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, int position, long id) {
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
playAll = (FloatingActionButton) view.findViewById(R.id.play_all_fab);
if (HomeActivity.tempPlaylist.getSongList().size() == 0) {
playAll.setVisibility(View.GONE);
}
playAll.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
playAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int size = HomeActivity.tempPlaylist.getSongList().size();
HomeActivity.queue.getQueue().clear();
for (int i = 0; i < size; i++) {
HomeActivity.queue.addToQueue(HomeActivity.tempPlaylist.getSongList().get(i));
}
HomeActivity.queueCurrentIndex = 0;
mCallback.onPlaylistPlayAll();
}
});
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(plAdapter);
mItemTouchHelper = new ItemTouchHelper(callback);
mItemTouchHelper.attachToRecyclerView(playlistRecyler);
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class AllPlaylistsFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
backBtn = (ImageView) view.findViewById(R.id.all_playlist_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
allPlaylistFragmentTitle = (TextView) view.findViewById(R.id.all_playlist_fragment_title);
if (SplashActivity.tf4 != null)
allPlaylistFragmentTitle.setTypeface(SplashActivity.tf4);
playlistFragIcon = (ImageView) view.findViewById(R.id.all_playlist_frag_icon);
playlistFragIcon.setImageTintList(ColorStateList.valueOf(HomeActivity.themeColor));
initializeHeaderImages(view);
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
noPlaylistContent = (LinearLayout) view.findViewById(R.id.noPlaylistContent);
allPlaylistRecycler = (RecyclerView) view.findViewById(R.id.all_playlists_recycler);
addPlaylistFAB = (FloatingActionButton) view.findViewById(R.id.new_playlist_fab);
addPlaylistFAB.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
addPlaylistFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.newPlaylistListener();
}
});
if (SplashActivity.tf4 != null)
((TextView) view.findViewById(R.id.noPlaylistContentText)).setTypeface(SplashActivity.tf4);
if (HomeActivity.allPlaylists.getPlaylists().size() == 0) {
allPlaylistRecycler.setVisibility(View.INVISIBLE);
noPlaylistContent.setVisibility(View.VISIBLE);
} else {
allPlaylistRecycler.setVisibility(View.VISIBLE);
noPlaylistContent.setVisibility(View.INVISIBLE);
}
vpAdapter = new ViewAllPlaylistsRecyclerAdapter(HomeActivity.allPlaylists.getPlaylists(), getContext());
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
allPlaylistRecycler.setLayoutManager(mLayoutManager2);
allPlaylistRecycler.setItemAnimator(new DefaultItemAnimator());
allPlaylistRecycler.setAdapter(vpAdapter);
allPlaylistRecycler.addOnItemTouchListener(new ClickItemTouchListener(allPlaylistRecycler) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
mCallback.onPlaylistSelected(position);
return true;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
PopupMenu popup = new PopupMenu(getContext(), view);
popup.getMenuInflater().inflate(R.menu.playlist_popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getTitle().equals("Play")) {
HomeActivity.tempPlaylist = HomeActivity.allPlaylists.getPlaylists().get(position);
int size = HomeActivity.tempPlaylist.getSongList().size();
HomeActivity.queue.getQueue().clear();
for (int i = 0; i < size; i++) {
HomeActivity.queue.addToQueue(HomeActivity.tempPlaylist.getSongList().get(i));
}
HomeActivity.queueCurrentIndex = 0;
mCallback.onPlaylistMenuPLayAll();
} else if (item.getTitle().equals("Add to Queue")) {
Playlist pl = HomeActivity.allPlaylists.getPlaylists().get(position);
for (UnifiedTrack ut : pl.getSongList()) {
HomeActivity.queue.addToQueue(ut);
}
} else if (item.getTitle().equals("Delete")) {
HomeActivity.allPlaylists.getPlaylists().remove(position);
if (vpAdapter != null) {
vpAdapter.notifyItemRemoved(position);
}
if (HomeActivity.allPlaylists.getPlaylists().size() == 0) {
noPlaylistContent.setVisibility(View.VISIBLE);
}
new HomeActivity.SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
homeActivity.pAdapter.notifyItemRemoved(position);
} else if (item.getTitle().equals("Rename")) {
HomeActivity.renamePlaylistNumber = position;
mCallback.onPlaylistRename();
}
return true;
}
});
popup.show();
return true;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class AllPlaylistsFragment method initializeHeaderImages.
public void initializeHeaderImages(View v) {
imgView[0] = (ImageView) v.findViewById(R.id.all_playlist_img_1);
imgView[1] = (ImageView) v.findViewById(R.id.all_playlist_img_2);
imgView[2] = (ImageView) v.findViewById(R.id.all_playlist_img_3);
imgView[3] = (ImageView) v.findViewById(R.id.all_playlist_img_4);
imgView[4] = (ImageView) v.findViewById(R.id.all_playlist_img_5);
imgView[5] = (ImageView) v.findViewById(R.id.all_playlist_img_6);
imgView[6] = (ImageView) v.findViewById(R.id.all_playlist_img_7);
imgView[7] = (ImageView) v.findViewById(R.id.all_playlist_img_8);
imgView[8] = (ImageView) v.findViewById(R.id.all_playlist_img_9);
imgView[9] = (ImageView) v.findViewById(R.id.all_playlist_img_10);
int numPlaylists = HomeActivity.allPlaylists.getPlaylists().size();
Playlist pl1, pl2;
if (numPlaylists == 0) {
for (int i = 0; i < 10; i++) {
imgLoader.DisplayImage("all_playlist" + i, imgView[i]);
}
} else if (numPlaylists == 1) {
pl1 = HomeActivity.allPlaylists.getPlaylists().get(0);
for (int i = 0; i < Math.min(10, pl1.getSongList().size()); i++) {
UnifiedTrack ut = pl1.getSongList().get(i);
if (ut.getType())
imgLoader.DisplayImage(ut.getLocalTrack().getPath(), imgView[i]);
else
imgLoader.DisplayImage(ut.getStreamTrack().getArtworkURL(), imgView[i]);
}
if (pl1.getSongList().size() < 10) {
for (int i = pl1.getSongList().size(); i < 10; i++) {
imgLoader.DisplayImage("all_playlist" + i, imgView[i]);
}
}
} else {
pl1 = HomeActivity.allPlaylists.getPlaylists().get(0);
pl2 = HomeActivity.allPlaylists.getPlaylists().get(1);
for (int i = 0; i < Math.min(10, pl1.getSongList().size()); i++) {
UnifiedTrack ut = pl1.getSongList().get(i);
if (ut.getType())
imgLoader.DisplayImage(pl1.getSongList().get(i).getLocalTrack().getPath(), imgView[i]);
else
imgLoader.DisplayImage(pl1.getSongList().get(i).getStreamTrack().getArtworkURL(), imgView[i]);
}
if (pl1.getSongList().size() < 10) {
if (pl2.getSongList().size() >= (10 - pl1.getSongList().size())) {
for (int i = pl1.getSongList().size(); i < 10; i++) {
UnifiedTrack ut = pl2.getSongList().get(i - pl1.getSongList().size());
if (ut.getType())
imgLoader.DisplayImage(ut.getLocalTrack().getPath(), imgView[i]);
else
imgLoader.DisplayImage(ut.getStreamTrack().getArtworkURL(), imgView[i]);
}
} else {
for (int i = pl1.getSongList().size(); i < pl1.getSongList().size() + pl2.getSongList().size(); i++) {
UnifiedTrack ut = pl2.getSongList().get(i - pl1.getSongList().size());
if (ut.getType())
imgLoader.DisplayImage(ut.getLocalTrack().getPath(), imgView[i]);
else
imgLoader.DisplayImage(ut.getStreamTrack().getArtworkURL(), imgView[i]);
}
for (int i = pl1.getSongList().size() + pl2.getSongList().size(); i < 10; i++) {
imgLoader.DisplayImage("all_playlist" + i, imgView[i]);
}
}
}
}
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class RecentsListHorizontalAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
UnifiedTrack ut = recentslyPlayed.get(position);
if (ut.getType()) {
LocalTrack lt = ut.getLocalTrack();
imgLoader.DisplayImage(lt.getPath(), holder.art);
holder.title.setText(lt.getTitle());
holder.artist.setText(lt.getArtist());
} else {
Track t = ut.getStreamTrack();
Picasso.with(ctx).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(holder.art);
holder.title.setText(t.getTitle());
holder.artist.setText("");
}
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class CustomAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
UnifiedTrack ut = queue.get(position);
holder.albumArt.setAlpha(0.35f);
if (ut.getType()) {
Bitmap bmp = getBitmap(ut.getLocalTrack().getPath());
if (bmp != null) {
holder.albumArt.setScaleType(ImageView.ScaleType.CENTER_CROP);
holder.albumArt.setImageBitmap(bmp);
} else {
holder.albumArt.setScaleType(ImageView.ScaleType.CENTER);
holder.albumArt.setImageResource(R.drawable.ic_default);
}
} else {
Picasso.with(ctx).load(ut.getStreamTrack().getArtworkURL()).into(holder.albumArt);
}
}
Aggregations