Search in sources :

Example 1 with QueueFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment 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));
            }
        }
    }
}
Also used : LocalMusicViewPagerFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment) LocalMusicFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment) InputMethodManager(android.view.inputmethod.InputMethodManager) Intent(android.content.Intent) QueueFragment(com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment) DrawerLayout(android.support.v4.widget.DrawerLayout) ViewSavedDNA(com.sdsmdg.harjot.MusicDNA.fragments.ViewSavedDNAsFragment.ViewSavedDNA) PlayerFragment(com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment) EqualizerFragment(com.sdsmdg.harjot.MusicDNA.fragments.EqualizerFragment.EqualizerFragment)

Example 2 with QueueFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment in project MusicDNA by harjot-oberai.

the class HomeActivity method onComplete.

// //////////////////////////////////////////////////////////////////////////////////////////////
/*
     * PlayerFragment callbacks START
     * onComplete() -> called when a song ends or next button is clicked in player or notification.
     * onPreviousTrack() -> called when previous button is clicked in player or notification.
     * onEqualizerClicked() -> called when equalizer icon is clicked.
     * onQueueCLicked() -> called when queue icon is clicked.
     * onPrepared() -> called when media player prepareAsync() is completed.
     * onSettingsClicked() -> called when settings menu item is selected.
     * onFullScreen() -> called when fullscreen menu item is selected or player is long pressed.
     * onAddedtoFavfromPlayer() -> called when favourite icon is clicked.
     * onShuffleEnabled() / onShuffleEnabled() -> shuffle enebled or disabled.
     * onSmallPlayerTouched() -> called when the down icon at the top of the player ic clicked to hide the player.
     *
     */
@Override
public void onComplete() {
    // Check for sleep timer and whether it has timed out
    if (isSleepTimerEnabled && isSleepTimerTimeout) {
        Toast.makeText(ctx, "Sleep timer timed out, closing app", Toast.LENGTH_SHORT).show();
        if (playerFragment != null && playerFragment.timer != null)
            playerFragment.timer.cancel();
        // Remove the notification
        notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(1);
        // Finish the activity
        finish();
        return;
    }
    // Save the DNA if saving is enabled
    if (isSaveDNAEnabled) {
        new SaveTheDNAs().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
    QueueFragment qFrag = (QueueFragment) fragMan.findFragmentByTag("queue");
    queueCall = true;
    PlayerFragment plFrag = playerFragment;
    if (repeatOnceEnabled && !nextControllerClicked) {
        /*
            * Executed if repeat once is enabled and user did not click the next button from player.
            */
        // Set Progress bar to 0
        plFrag.progressBar.setProgress(0);
        plFrag.progressBar.setSecondaryProgress(0);
        // Get Visualizer and Visualizer View to initial state
        plFrag.mVisualizer.setEnabled(true);
        VisualizerView.w = screen_width;
        VisualizerView.h = screen_height;
        VisualizerView.conf = Bitmap.Config.ARGB_8888;
        VisualizerView.bmp = Bitmap.createBitmap(VisualizerView.w, VisualizerView.h, VisualizerView.conf);
        cacheCanvas = new Canvas(VisualizerView.bmp);
        // Play the song again by seeking media player to 0
        plFrag.mMediaPlayer.seekTo(0);
        // Setup the icons
        plFrag.mainTrackController.setImageResource(R.drawable.ic_pause_white_48dp);
        plFrag.isReplayIconVisible = false;
        plFrag.player_controller.setImageResource(R.drawable.ic_pause_white_48dp);
        // Resume the MediaPlayer
        plFrag.isPrepared = true;
        plFrag.mMediaPlayer.start();
    } else {
        if (queueCurrentIndex < queue.getQueue().size() - 1) {
            queueCurrentIndex++;
            nextControllerClicked = false;
            hasQueueEnded = false;
            if (qFrag != null) {
                qFrag.updateQueueAdapter();
            }
            if (queue.getQueue().get(queueCurrentIndex).getType()) {
                localSelectedTrack = queue.getQueue().get(queueCurrentIndex).getLocalTrack();
                streamSelected = false;
                localSelected = true;
                onLocalTrackSelected(-1);
            } else {
                selectedTrack = queue.getQueue().get(queueCurrentIndex).getStreamTrack();
                streamSelected = true;
                localSelected = false;
                onTrackSelected(-1);
            }
        } else {
            if ((repeatEnabled || repeatOnceEnabled) && (queue.getQueue().size() > 1)) {
                nextControllerClicked = false;
                hasQueueEnded = false;
                queueCurrentIndex = 0;
                if (qFrag != null) {
                    qFrag.updateQueueAdapter();
                }
                onQueueItemClicked(0);
            } else if ((repeatEnabled || repeatOnceEnabled) && (queue.getQueue().size() == 1)) {
                nextControllerClicked = false;
                hasQueueEnded = false;
                plFrag.progressBar.setProgress(0);
                plFrag.progressBar.setSecondaryProgress(0);
                plFrag.mVisualizer.setEnabled(true);
                plFrag.mMediaPlayer.seekTo(0);
                plFrag.mainTrackController.setImageResource(R.drawable.ic_pause_white_48dp);
                plFrag.isReplayIconVisible = false;
                plFrag.player_controller.setImageResource(R.drawable.ic_pause_white_48dp);
                plFrag.isPrepared = true;
                plFrag.mMediaPlayer.start();
            } else {
                if ((nextControllerClicked || hasQueueEnded) && (queue.getQueue().size() > 1)) {
                    nextControllerClicked = false;
                    hasQueueEnded = false;
                    queueCurrentIndex = 0;
                    if (qFrag != null) {
                        qFrag.updateQueueAdapter();
                    }
                    onQueueItemClicked(0);
                } else if ((nextControllerClicked || hasQueueEnded) && (queue.getQueue().size() == 1)) {
                    nextControllerClicked = false;
                    hasQueueEnded = false;
                    plFrag.progressBar.setProgress(0);
                    plFrag.progressBar.setSecondaryProgress(0);
                    if (plFrag.mVisualizer != null)
                        plFrag.mVisualizer.setEnabled(true);
                    plFrag.mMediaPlayer.seekTo(0);
                    plFrag.mainTrackController.setImageResource(R.drawable.ic_pause_white_48dp);
                    plFrag.isReplayIconVisible = false;
                    plFrag.player_controller.setImageResource(R.drawable.ic_pause_white_48dp);
                    plFrag.isPrepared = true;
                    plFrag.mMediaPlayer.start();
                } else {
                // keep queue at last track or you are doomed
                }
            }
        }
    }
}
Also used : Canvas(android.graphics.Canvas) QueueFragment(com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment) PlayerFragment(com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment)

Example 3 with QueueFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment 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();
    }
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecentsFragment(com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment) QueueFragment(com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment) TextPaint(android.text.TextPaint) PlayerFragment(com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment)

Example 4 with QueueFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment 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();
    }
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecentsFragment(com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment) QueueFragment(com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment) TextPaint(android.text.TextPaint) PlayerFragment(com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment)

Example 5 with QueueFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment 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();
    }
}
Also used : QueueFragment(com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment) StreamMusicFragment(com.sdsmdg.harjot.MusicDNA.fragments.StreamFragment.StreamMusicFragment) SettingsFragment(com.sdsmdg.harjot.MusicDNA.fragments.SettingsFragment.SettingsFragment) FolderFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllFoldersFragment.FolderFragment) ViewAlbumFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewAlbumFragment.ViewAlbumFragment) RecentsFragment(com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment) EditLocalSongFragment(com.sdsmdg.harjot.MusicDNA.fragments.EditSongFragment.EditLocalSongFragment) AboutFragment(com.sdsmdg.harjot.MusicDNA.fragments.AboutFragment.AboutFragment) NewPlaylistFragment(com.sdsmdg.harjot.MusicDNA.fragments.NewPlaylistFragment.NewPlaylistFragment) AllPlaylistsFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment) ViewSavedDNA(com.sdsmdg.harjot.MusicDNA.fragments.ViewSavedDNAsFragment.ViewSavedDNA) EqualizerFragment(com.sdsmdg.harjot.MusicDNA.fragments.EqualizerFragment.EqualizerFragment) FavouritesFragment(com.sdsmdg.harjot.MusicDNA.fragments.FavouritesFragment.FavouritesFragment) LocalMusicViewPagerFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment) ViewArtistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewArtistFragment.ViewArtistFragment) ViewPlaylistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewPlaylistFragment.ViewPlaylistFragment) FolderContentFragment(com.sdsmdg.harjot.MusicDNA.fragments.FolderContentFragment.FolderContentFragment)

Aggregations

QueueFragment (com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment)7 PlayerFragment (com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment)4 TextPaint (android.text.TextPaint)3 RecentsFragment (com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment)3 EqualizerFragment (com.sdsmdg.harjot.MusicDNA.fragments.EqualizerFragment.EqualizerFragment)2 LocalMusicViewPagerFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment)2 ViewSavedDNA (com.sdsmdg.harjot.MusicDNA.fragments.ViewSavedDNAsFragment.ViewSavedDNA)2 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)2 Intent (android.content.Intent)1 Canvas (android.graphics.Canvas)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AboutFragment (com.sdsmdg.harjot.MusicDNA.fragments.AboutFragment.AboutFragment)1 FolderFragment (com.sdsmdg.harjot.MusicDNA.fragments.AllFoldersFragment.FolderFragment)1 AllPlaylistsFragment (com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment)1 EditLocalSongFragment (com.sdsmdg.harjot.MusicDNA.fragments.EditSongFragment.EditLocalSongFragment)1 FavouritesFragment (com.sdsmdg.harjot.MusicDNA.fragments.FavouritesFragment.FavouritesFragment)1 FolderContentFragment (com.sdsmdg.harjot.MusicDNA.fragments.FolderContentFragment.FolderContentFragment)1 LocalMusicFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment)1 NewPlaylistFragment (com.sdsmdg.harjot.MusicDNA.fragments.NewPlaylistFragment.NewPlaylistFragment)1