use of com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method onLocalTrackSelected.
public void onLocalTrackSelected(int position) {
isReloaded = false;
HideBottomFakeToolbar();
if (!queueCall) {
CommonUtils.hideKeyboard(this);
searchView.setQuery("", true);
searchView.setIconified(true);
new Thread(new CancelCall()).start();
// hideTabs();
isPlayerVisible = true;
PlayerFragment frag = playerFragment;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
PlayerFragment newFragment = new PlayerFragment();
if (frag == null) {
playerFragment = newFragment;
int flag = 0;
for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(i);
if (ut.getType() && ut.getLocalTrack().getTitle().equals(localSelectedTrack.getTitle())) {
flag = 1;
isFavourite = true;
break;
}
}
if (flag == 0) {
isFavourite = false;
}
playerFragment.localIsPlaying = true;
playerFragment.localTrack = localSelectedTrack;
fm.beginTransaction().setCustomAnimations(R.anim.slide_up, R.anim.slide_down, R.anim.slide_up, R.anim.slide_down).add(R.id.player_frag_container, newFragment, "player").show(newFragment).commitAllowingStateLoss();
} else {
if (playerFragment.localTrack != null && playerFragment.localIsPlaying && localSelectedTrack.getTitle() == playerFragment.localTrack.getTitle()) {
} else {
int flag = 0;
for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(i);
if (ut.getType() && ut.getLocalTrack().getTitle().equals(localSelectedTrack.getTitle())) {
flag = 1;
isFavourite = true;
break;
}
}
if (flag == 0) {
isFavourite = false;
}
playerFragment.localIsPlaying = true;
playerFragment.localTrack = localSelectedTrack;
frag.refresh();
}
}
if (!isQueueVisible)
showPlayer();
} else {
PlayerFragment frag = playerFragment;
playerFragment.localIsPlaying = true;
playerFragment.localTrack = localSelectedTrack;
int flag = 0;
for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(i);
if (ut.getType() && ut.getLocalTrack().getTitle().equals(localSelectedTrack.getTitle())) {
flag = 1;
isFavourite = true;
break;
}
}
if (flag == 0) {
isFavourite = false;
}
if (frag != null)
frag.refresh();
}
if (playerFragment != null && playerFragment.snappyRecyclerView != null) {
playerFragment.snappyRecyclerView.getAdapter().notifyDataSetChanged();
playerFragment.snappyRecyclerView.setTransparency();
}
QueueFragment qFrag = (QueueFragment) fragMan.findFragmentByTag("queue");
if (qFrag != null) {
qFrag.updateQueueAdapter();
}
UnifiedTrack track = new UnifiedTrack(true, playerFragment.localTrack, null);
for (int i = 0; i < recentlyPlayed.getRecentlyPlayed().size(); i++) {
if (recentlyPlayed.getRecentlyPlayed().get(i).getType() && recentlyPlayed.getRecentlyPlayed().get(i).getLocalTrack().getTitle().equals(track.getLocalTrack().getTitle())) {
recentlyPlayed.getRecentlyPlayed().remove(i);
// rAdapter.notifyItemRemoved(i);
break;
}
}
recentlyPlayed.getRecentlyPlayed().add(0, track);
if (recentlyPlayed.getRecentlyPlayed().size() == 51) {
recentlyPlayed.getRecentlyPlayed().remove(50);
}
recentsRecycler.setVisibility(View.VISIBLE);
recentsNothingText.setVisibility(View.INVISIBLE);
continuePlayingList.clear();
for (int i = 0; i < Math.min(10, recentlyPlayed.getRecentlyPlayed().size()); i++) {
continuePlayingList.add(recentlyPlayed.getRecentlyPlayed().get(i));
}
rAdapter.notifyDataSetChanged();
refreshHeaderImages();
RecentsFragment rFrag = (RecentsFragment) fragMan.findFragmentByTag("recent");
if (rFrag != null && rFrag.rtAdpater != null) {
rFrag.rtAdpater.notifyDataSetChanged();
}
}
use of com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method onTrackSelected.
// //////////////////////////////////////////////////////////////////////////////////////////////
/*
* Methods for playing selected songs
* onTrackSelected -> Used to stream tracks from soundcloud
* onLocalTrackSelected -> Used to play local songs
*/
public void onTrackSelected(int position) {
isReloaded = false;
HideBottomFakeToolbar();
if (!queueCall) {
CommonUtils.hideKeyboard(this);
searchView.setQuery("", false);
searchView.setIconified(true);
new Thread(new CancelCall()).start();
isPlayerVisible = true;
PlayerFragment frag = playerFragment;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
PlayerFragment newFragment = new PlayerFragment();
if (frag == null) {
playerFragment = newFragment;
int flag = 0;
for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(i);
if (!ut.getType() && ut.getStreamTrack().getTitle().equals(selectedTrack.getTitle())) {
flag = 1;
isFavourite = true;
break;
}
}
if (flag == 0) {
isFavourite = false;
}
playerFragment.localIsPlaying = false;
playerFragment.track = selectedTrack;
fm.beginTransaction().setCustomAnimations(R.anim.slide_up, R.anim.slide_down, R.anim.slide_up, R.anim.slide_down).add(R.id.player_frag_container, newFragment, "player").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else {
if (playerFragment.track != null && !playerFragment.localIsPlaying && selectedTrack.getTitle() == playerFragment.track.getTitle()) {
} else {
int flag = 0;
for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(i);
if (!ut.getType() && ut.getStreamTrack().getTitle().equals(selectedTrack.getTitle())) {
flag = 1;
isFavourite = true;
break;
}
}
if (flag == 0) {
isFavourite = false;
}
playerFragment.localIsPlaying = false;
playerFragment.track = selectedTrack;
frag.refresh();
}
}
if (!isQueueVisible)
showPlayer();
} else {
PlayerFragment frag = playerFragment;
playerFragment.localIsPlaying = false;
playerFragment.track = selectedTrack;
int flag = 0;
for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) {
UnifiedTrack ut = favouriteTracks.getFavourite().get(i);
if (!ut.getType() && ut.getStreamTrack().getTitle().equals(selectedTrack.getTitle())) {
flag = 1;
isFavourite = true;
break;
}
}
if (flag == 0) {
isFavourite = false;
}
frag.refresh();
}
if (playerFragment != null && playerFragment.snappyRecyclerView != null) {
playerFragment.snappyRecyclerView.getAdapter().notifyDataSetChanged();
playerFragment.snappyRecyclerView.setTransparency();
}
QueueFragment qFrag = (QueueFragment) fragMan.findFragmentByTag("queue");
if (qFrag != null) {
qFrag.updateQueueAdapter();
}
UnifiedTrack track = new UnifiedTrack(false, null, playerFragment.track);
for (int i = 0; i < recentlyPlayed.getRecentlyPlayed().size(); i++) {
if (!recentlyPlayed.getRecentlyPlayed().get(i).getType() && recentlyPlayed.getRecentlyPlayed().get(i).getStreamTrack().getTitle().equals(track.getStreamTrack().getTitle())) {
recentlyPlayed.getRecentlyPlayed().remove(i);
// rAdapter.notifyItemRemoved(i);
break;
}
}
recentlyPlayed.getRecentlyPlayed().add(0, track);
if (recentlyPlayed.getRecentlyPlayed().size() > 50) {
recentlyPlayed.getRecentlyPlayed().remove(50);
}
recentsRecycler.setVisibility(View.VISIBLE);
recentsNothingText.setVisibility(View.INVISIBLE);
continuePlayingList.clear();
for (int i = 0; i < Math.min(10, recentlyPlayed.getRecentlyPlayed().size()); i++) {
continuePlayingList.add(recentlyPlayed.getRecentlyPlayed().get(i));
}
rAdapter.notifyDataSetChanged();
refreshHeaderImages();
RecentsFragment rFrag = (RecentsFragment) fragMan.findFragmentByTag("recent");
if (rFrag != null && rFrag.rtAdpater != null) {
rFrag.rtAdpater.notifyDataSetChanged();
}
}
use of com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method showFragment.
public void showFragment(String type) {
if (!type.equals("viewAlbum") && !type.equals("folderContent") && !type.equals("viewArtist") && !type.equals("playlist") && !type.equals("newPlaylist") && !type.equals("About") && !type.equals("Edit"))
hideAllFrags();
if (!searchView.isIconified()) {
searchView.setQuery("", true);
searchView.setIconified(true);
streamRecyclerContainer.setVisibility(GONE);
new Thread(new CancelCall()).start();
}
if (type.equals("local") && !isLocalVisible) {
navigationView.setCheckedItem(R.id.nav_local);
isLocalVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
LocalMusicViewPagerFragment newFragment = (LocalMusicViewPagerFragment) fm.findFragmentByTag("local");
if (newFragment == null) {
newFragment = new LocalMusicViewPagerFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "local").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("queue") && !isQueueVisible) {
hideAllFrags();
isQueueVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
QueueFragment newFragment = (QueueFragment) fm.findFragmentByTag("queue");
if (newFragment == null) {
newFragment = new QueueFragment();
}
fm.beginTransaction().add(R.id.equalizer_queue_frag_container, newFragment, "queue").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("stream") && !isStreamVisible) {
isStreamVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
StreamMusicFragment newFragment = (StreamMusicFragment) fm.findFragmentByTag("stream");
if (newFragment == null) {
newFragment = new StreamMusicFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "stream").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("playlist") && !isPlaylistVisible) {
isPlaylistVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
ViewPlaylistFragment newFragment = (ViewPlaylistFragment) fm.findFragmentByTag("playlist");
if (newFragment == null) {
newFragment = new ViewPlaylistFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "playlist").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("equalizer") && !isEqualizerVisible) {
isEqualizerVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
EqualizerFragment newFragment = (EqualizerFragment) fm.findFragmentByTag("equalizer");
if (newFragment == null) {
newFragment = new EqualizerFragment();
}
fm.beginTransaction().add(R.id.equalizer_queue_frag_container, newFragment, "equalizer").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("favourite") && !isFavouriteVisible) {
navigationView.setCheckedItem(R.id.nav_fav);
isFavouriteVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
FavouritesFragment newFragment = (FavouritesFragment) fm.findFragmentByTag("favourite");
if (newFragment == null) {
newFragment = new FavouritesFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "favourite").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("newPlaylist") && !isNewPlaylistVisible) {
navigationView.setCheckedItem(R.id.nav_playlists);
isNewPlaylistVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
NewPlaylistFragment newFragment = (NewPlaylistFragment) fm.findFragmentByTag("newPlaylist");
if (newFragment == null) {
newFragment = new NewPlaylistFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "newPlaylist").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("allPlaylists") && !isAllPlaylistVisible) {
navigationView.setCheckedItem(R.id.nav_playlists);
isAllPlaylistVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
AllPlaylistsFragment newFragment = (AllPlaylistsFragment) fm.findFragmentByTag("allPlaylists");
if (newFragment == null) {
newFragment = new AllPlaylistsFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "allPlaylists").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("folderContent") && !isFolderContentVisible) {
isFolderContentVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
FolderContentFragment newFragment = (FolderContentFragment) fm.findFragmentByTag("folderContent");
if (newFragment == null) {
newFragment = new FolderContentFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "folderContent").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("allFolders") && !isAllFolderVisible) {
navigationView.setCheckedItem(R.id.nav_folder);
isAllFolderVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
FolderFragment newFragment = (FolderFragment) fm.findFragmentByTag("allFolders");
if (newFragment == null) {
newFragment = new FolderFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "allFolders").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("allSavedDNAs") && !isAllSavedDnaVisisble) {
navigationView.setCheckedItem(R.id.nav_view);
isAllSavedDnaVisisble = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
ViewSavedDNA newFragment = (ViewSavedDNA) fm.findFragmentByTag("allSavedDNAs");
if (newFragment == null) {
newFragment = new ViewSavedDNA();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "allSavedDNAs").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("viewAlbum") && !isAlbumVisible) {
isAlbumVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
ViewAlbumFragment newFragment = (ViewAlbumFragment) fm.findFragmentByTag("viewAlbum");
if (newFragment == null) {
newFragment = new ViewAlbumFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "viewAlbum").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("viewArtist") && !isArtistVisible) {
isArtistVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
ViewArtistFragment newFragment = (ViewArtistFragment) fm.findFragmentByTag("viewArtist");
if (newFragment == null) {
newFragment = new ViewArtistFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "viewArtist").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("recent") && !isRecentVisible) {
navigationView.setCheckedItem(R.id.nav_recent);
isRecentVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
RecentsFragment newFragment = (RecentsFragment) fm.findFragmentByTag("recent");
if (newFragment == null) {
newFragment = new RecentsFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "recent").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("settings") && !isSettingsVisible) {
isSettingsVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
SettingsFragment newFragment = (SettingsFragment) fm.findFragmentByTag("settings");
if (newFragment == null) {
newFragment = new SettingsFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "settings").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("About") && !isAboutVisible) {
setTitle("About");
isAboutVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
AboutFragment newFragment = (AboutFragment) fm.findFragmentByTag("About");
if (newFragment == null) {
newFragment = new AboutFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "About").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
} else if (type.equals("Edit") && !isEditVisible) {
isEditVisible = true;
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
EditLocalSongFragment newFragment = (EditLocalSongFragment) fm.findFragmentByTag("Edit");
if (newFragment == null) {
newFragment = new EditLocalSongFragment();
}
fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "Edit").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
}
}
Aggregations