use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method addArtistToQueue.
@Override
public void addArtistToQueue() {
List<LocalTrack> list = tempArtist.getArtistSongs();
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.UnifiedTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method onQueueItemClicked.
// //////////////////////////////////////////////////////////////////////////////////////////////
/*
* QueueFragment callbacks START
* onQueueItemClicked() -> when a song is selected from queue.
* onQueueSave() -> queue save as playlist fab is clicked.
* onQueueClear() -> when queue clear option is selected.
*/
@Override
public void onQueueItemClicked(final int position) {
if (isPlayerVisible && isQueueVisible)
showPlayer3();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
queueCurrentIndex = position;
UnifiedTrack ut = queue.getQueue().get(position);
if (ut.getType()) {
LocalTrack track = ut.getLocalTrack();
localSelectedTrack = track;
streamSelected = false;
localSelected = true;
queueCall = false;
isReloaded = false;
onLocalTrackSelected(position);
} else {
Track track = ut.getStreamTrack();
selectedTrack = track;
streamSelected = true;
localSelected = false;
queueCall = false;
isReloaded = false;
onTrackSelected(position);
}
}
}, 500);
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method onShuffleEnabled.
@Override
public void onShuffleEnabled() {
originalQueue = new Queue();
for (UnifiedTrack ut : queue.getQueue()) {
originalQueue.addToQueue(ut);
}
originalQueueIndex = queueCurrentIndex;
UnifiedTrack ut = queue.getQueue().get(queueCurrentIndex);
Collections.shuffle(queue.getQueue());
for (int i = 0; i < queue.getQueue().size(); i++) {
if (ut.equals(queue.getQueue().get(i))) {
queue.getQueue().remove(i);
break;
}
}
queue.getQueue().add(0, ut);
queueCurrentIndex = 0;
new SaveQueue().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method newPlaylistNameDialog.
public void newPlaylistNameDialog() {
final Dialog dialog = new Dialog(ctx);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.save_image_dialog);
TextView titleText = (TextView) dialog.findViewById(R.id.dialog_title);
titleText.setText("Playlist Name");
if (SplashActivity.tf4 != null)
titleText.setTypeface(SplashActivity.tf4);
Button btn = (Button) dialog.findViewById(R.id.save_image_btn);
final EditText newName = (EditText) dialog.findViewById(R.id.save_image_filename_text);
CheckBox cb = (CheckBox) dialog.findViewById(R.id.text_checkbox);
cb.setVisibility(GONE);
btn.setBackgroundColor(themeColor);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isNameRepeat = false;
if (newName.getText().toString().trim().equals("")) {
newName.setError("Enter Playlist Name!");
} else {
for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
if (newName.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
isNameRepeat = true;
newName.setError("Playlist with same name exists!");
break;
}
}
if (!isNameRepeat) {
UnifiedTrack ut;
Playlist pl = new Playlist(newName.getText().toString());
for (int i = 0; i < finalSelectedTracks.size(); i++) {
ut = new UnifiedTrack(true, finalSelectedTracks.get(i), null);
pl.getSongList().add(ut);
}
allPlaylists.addPlaylist(pl);
finalSelectedTracks.clear();
if (pAdapter != null) {
pAdapter.notifyDataSetChanged();
if (allPlaylists.getPlaylists().size() > 0) {
playlistsRecycler.setVisibility(View.VISIBLE);
playlistNothingText.setVisibility(View.INVISIBLE);
}
}
AllPlaylistsFragment plFrag = (AllPlaylistsFragment) fragMan.findFragmentByTag("allPlaylists");
if (plFrag != null) {
plFrag.dataChanged();
}
new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dialog.dismiss();
onBackPressed();
}
}
}
});
dialog.show();
}
use of com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack in project MusicDNA by harjot-oberai.
the class HomeActivity method onFolderContentPlayAll.
// //////////////////////////////////////////////////////////////////////////////////////////////
/*
* FolderContentFragment callbacks START
*/
@Override
public void onFolderContentPlayAll() {
queue.getQueue().clear();
for (int i = 0; i < tempFolderContent.size(); i++) {
queue.getQueue().add(new UnifiedTrack(true, tempFolderContent.get(i), null));
}
queueCurrentIndex = 0;
onPlaylistMenuPLayAll();
}
Aggregations