use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method folderAddToQueue.
@Override
public void folderAddToQueue() {
List<LocalTrack> list = tempFolderContent;
for (LocalTrack lt : list) {
HomeActivity.queue.addToQueue(new UnifiedTrack(true, lt, null));
}
if (playerFragment != null && playerFragment.snappyRecyclerView != null) {
playerFragment.snappyRecyclerView.getAdapter().notifyDataSetChanged();
playerFragment.snappyRecyclerView.setTransparency();
}
Toast.makeText(ctx, "Added " + list.size() + " song(s) to queue", Toast.LENGTH_SHORT).show();
}
use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method onFavouriteItemClicked.
////////////////////////////////////////////////////////////////////////////////////////////////
/*
* FavouriteFragment callbacks START
* onFavouriteItemClicked() -> when a song is selected from favourites.
* onFavouritePlayAll() -> when favourite play all fab is selected.
* addFavToQueue() -> when `add favourite to queue` is selected.
*/
@Override
public void onFavouriteItemClicked(int position) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(position);
if (ut.getType()) {
LocalTrack track = ut.getLocalTrack();
if (queue.getQueue().size() == 0) {
queueCurrentIndex = 0;
queue.getQueue().add(new UnifiedTrack(true, track, null));
} else if (queueCurrentIndex == queue.getQueue().size() - 1) {
queueCurrentIndex++;
queue.getQueue().add(new UnifiedTrack(true, track, null));
} else if (isReloaded) {
isReloaded = false;
queueCurrentIndex = queue.getQueue().size();
queue.getQueue().add(new UnifiedTrack(true, track, null));
} else {
queue.getQueue().add(++queueCurrentIndex, new UnifiedTrack(true, track, null));
}
localSelectedTrack = track;
streamSelected = false;
localSelected = true;
queueCall = false;
isReloaded = false;
onLocalTrackSelected(position);
} else {
Track track = ut.getStreamTrack();
if (queue.getQueue().size() == 0) {
queueCurrentIndex = 0;
queue.getQueue().add(new UnifiedTrack(false, null, track));
} else if (queueCurrentIndex == queue.getQueue().size() - 1) {
queueCurrentIndex++;
queue.getQueue().add(new UnifiedTrack(false, null, track));
} else if (isReloaded) {
isReloaded = false;
queueCurrentIndex = queue.getQueue().size();
queue.getQueue().add(new UnifiedTrack(false, null, track));
} else {
queue.getQueue().add(++queueCurrentIndex, new UnifiedTrack(false, null, track));
}
selectedTrack = track;
streamSelected = true;
localSelected = false;
queueCall = false;
isReloaded = false;
onTrackSelected(position);
}
}
use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.
the class PlaylistTrackAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final PlaylistTrackAdapter.MyViewHolder holder, int position) {
UnifiedTrack ut = songList.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("");
}
holder.holderImg.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
mDragStartListener.onDragStarted(holder);
}
return false;
}
});
}
use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack 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.LocalTrack in project MusicDNA by harjot-oberai.
the class ViewPlaylistFragment method updateViewPlaylistFragment.
@Override
public void updateViewPlaylistFragment() {
title.setText(HomeActivity.tempPlaylist.getPlaylistName());
String s = "";
if (HomeActivity.tempPlaylist.getSongList().size() > 1)
s = "Songs";
else
s = "Song";
songsText.setText(HomeActivity.tempPlaylist.getSongList().size() + " " + s);
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);
}
}
Aggregations