use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method updateAlbumList.
private void updateAlbumList(String query) {
finalAlbums.clear();
for (int i = 0; i < albums.size(); i++) {
Album album = albums.get(i);
String tmp1 = album.getName().toLowerCase();
String tmp2 = query.toLowerCase();
if (tmp1.contains(tmp2)) {
finalAlbums.add(album);
}
}
LocalMusicViewPagerFragment flmFrag = (LocalMusicViewPagerFragment) fragMan.findFragmentByTag("local");
if (flmFrag != null) {
AlbumFragment aFrag = (AlbumFragment) flmFrag.getFragmentByPosition(1);
if (aFrag != null) {
aFrag.updateAdapter();
}
}
}
use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method onBackPressed.
////////////////////////////////////////////////////////////////////////////////////////////////
/*
* Standard Activity methods
*/
@Override
public void onBackPressed() {
PlayerFragment plFrag = playerFragment;
LocalMusicViewPagerFragment flmFrag = (LocalMusicViewPagerFragment) fragMan.findFragmentByTag("local");
LocalMusicFragment lFrag = null;
if (flmFrag != null) {
lFrag = (LocalMusicFragment) flmFrag.getFragmentByPosition(0);
}
QueueFragment qFrag = (QueueFragment) fragMan.findFragmentByTag("queue");
EqualizerFragment eqFrag = (EqualizerFragment) fragMan.findFragmentByTag("equalizer");
ViewSavedDNA vsdFrag = (ViewSavedDNA) fragMan.findFragmentByTag("allSavedDNAs");
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else if (showCase != null && showCase.isShowing()) {
showCase.hide();
} else if (plFrag != null && plFrag.isShowcaseVisible()) {
plFrag.hideShowcase();
} else if (lFrag != null && lFrag.isShowcaseVisible()) {
lFrag.hideShowcase();
} else if (qFrag != null && qFrag.isShowcaseVisible()) {
qFrag.hideShowcase();
} else if (eqFrag != null && eqFrag.isShowcaseVisible()) {
eqFrag.hideShowcase();
} else if (vsdFrag != null && vsdFrag.isShowcaseVisible()) {
vsdFrag.hideShowcase();
} else if (isFullScreenEnabled) {
isFullScreenEnabled = false;
plFrag.bottomContainer.setVisibility(View.VISIBLE);
plFrag.seekBarContainer.setVisibility(View.VISIBLE);
plFrag.toggleContainer.setVisibility(View.VISIBLE);
plFrag.spToolbar.setVisibility(View.VISIBLE);
onFullScreen();
} else if (isEqualizerVisible) {
showPlayer2();
} else if (isQueueVisible) {
showPlayer3();
} else if (isPlayerVisible && !isPlayerTransitioning && playerFragment.smallPlayer != null) {
hidePlayer();
// showTabs();
isPlayerVisible = false;
} else if (isLocalVisible && flmFrag != null && flmFrag.searchBox != null && flmFrag.isSearchboxVisible) {
flmFrag.searchBox.setText("");
flmFrag.searchBox.setVisibility(View.INVISIBLE);
flmFrag.isSearchboxVisible = false;
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
flmFrag.searchIcon.setImageResource(R.drawable.ic_search);
flmFrag.fragTitle.setVisibility(View.VISIBLE);
} else if (!searchView.isIconified()) {
searchView.setQuery("", true);
searchView.setIconified(true);
new Thread(new CancelCall()).start();
if (localRecyclerContainer.getVisibility() == View.VISIBLE || streamRecyclerContainer.getVisibility() == View.VISIBLE) {
localRecyclerContainer.setVisibility(GONE);
streamRecyclerContainer.setVisibility(GONE);
}
} else if (localRecyclerContainer.getVisibility() == View.VISIBLE || streamRecyclerContainer.getVisibility() == View.VISIBLE) {
localRecyclerContainer.setVisibility(GONE);
streamRecyclerContainer.setVisibility(GONE);
} else {
if (isEditVisible) {
hideFragment("Edit");
} else if (isAlbumVisible) {
hideFragment("viewAlbum");
} else if (isArtistVisible) {
hideFragment("viewArtist");
} else {
if (isLocalVisible) {
hideFragment("local");
setTitle("Music DNA");
} else if (isQueueVisible) {
hideFragment("queue");
setTitle("Music DNA");
} else if (isStreamVisible) {
hideFragment("stream");
setTitle("Music DNA");
} else if (isPlaylistVisible) {
hideFragment("playlist");
setTitle("Music DNA");
} else if (isNewPlaylistVisible) {
hideFragment("newPlaylist");
setTitle("Music DNA");
} else if (isEqualizerVisible) {
finalSelectedTracks.clear();
hideFragment("equalizer");
setTitle("Music DNA");
} else if (isFavouriteVisible) {
hideFragment("favourite");
setTitle("Music DNA");
} else if (isAllPlaylistVisible) {
hideFragment("allPlaylists");
setTitle("Music DNA");
} else if (isFolderContentVisible) {
hideFragment("folderContent");
setTitle("Folders");
} else if (isAllFolderVisible) {
hideFragment("allFolders");
setTitle("Music DNA");
} else if (isAllSavedDnaVisisble) {
hideFragment("allSavedDNAs");
setTitle("Music DNA");
} else if (isSavedDNAVisible) {
hideFragment("savedDNA");
setTitle("Music DNA");
} else if (isRecentVisible) {
hideFragment("recent");
setTitle("Music DNA");
} else if (isAboutVisible) {
hideFragment("About");
setTitle("Settings");
} else if (isSettingsVisible) {
hideFragment("settings");
new SaveSettings().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
setTitle("Music DNA");
} else if (!isPlayerTransitioning) {
startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
}
}
}
}
use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method updateArtistList.
private void updateArtistList(String query) {
finalArtists.clear();
for (int i = 0; i < artists.size(); i++) {
Artist artist = artists.get(i);
String tmp1 = artist.getName().toLowerCase();
String tmp2 = query.toLowerCase();
if (tmp1.contains(tmp2)) {
finalArtists.add(artist);
}
}
LocalMusicViewPagerFragment flmFrag = (LocalMusicViewPagerFragment) fragMan.findFragmentByTag("local");
if (flmFrag != null) {
ArtistFragment aFrag = (ArtistFragment) flmFrag.getFragmentByPosition(2);
if (aFrag != null) {
aFrag.updateAdapter();
}
}
}
use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment in project MusicDNA by harjot-oberai.
the class HomeActivity method onEditSongSave.
////////////////////////////////////////////////////////////////////////////////////////////////
/*
* EditSongFragment callbacks START
* onEditSongSave() -> called when save is clicked to store edited fields.
* deleteMediaStoreCache() -> used to delete the media store cache so that it is rebuilt and new album art is cached.
* getNewBitmap() -> called to statr the image picker intent for album art.
*/
@Override
public void onEditSongSave(boolean wasSaveSuccessful) {
hideFragment("Edit");
if (!wasSaveSuccessful) {
Toast.makeText(this, "Error occured while editing", Toast.LENGTH_SHORT).show();
return;
}
MediaCacheUtils.updateMediaCache(editSong.getTitle(), editSong.getArtist(), editSong.getAlbum(), editSong.getId(), this);
refreshAlbumAndArtists();
if (isAlbumVisible) {
hideFragment("viewAlbum");
} else if (isArtistVisible) {
hideFragment("viewArtist");
}
LocalMusicViewPagerFragment flmFrag = (LocalMusicViewPagerFragment) fragMan.findFragmentByTag("local");
LocalMusicFragment lFrag = null;
if (flmFrag != null) {
lFrag = (LocalMusicFragment) flmFrag.getFragmentByPosition(0);
}
if (lFrag != null) {
lFrag.updateAdapter();
}
ArtistFragment artFrag = null;
if (flmFrag != null) {
artFrag = (ArtistFragment) flmFrag.getFragmentByPosition(2);
}
if (artFrag != null) {
artFrag.updateAdapter();
}
AlbumFragment albFrag = null;
if (flmFrag != null) {
albFrag = (AlbumFragment) flmFrag.getFragmentByPosition(1);
}
if (albFrag != null) {
albFrag.updateAdapter();
}
}
use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment 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