Search in sources :

Example 1 with LocalMusicFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment 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();
    }
}
Also used : ViewArtistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewArtistFragment.ViewArtistFragment) ArtistFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.ArtistFragment) LocalMusicViewPagerFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment) LocalMusicFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment) AlbumFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.AlbumFragment) ViewAlbumFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewAlbumFragment.ViewAlbumFragment)

Example 2 with LocalMusicFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment 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 3 with LocalMusicFragment

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

the class HomeActivity method updateLocalList.

private void updateLocalList(String query) {
    LocalMusicViewPagerFragment flmFrag = (LocalMusicViewPagerFragment) fragMan.findFragmentByTag("local");
    LocalMusicFragment lFrag = null;
    if (flmFrag != null)
        lFrag = (LocalMusicFragment) flmFrag.getFragmentByPosition(0);
    if (lFrag != null)
        lFrag.hideShuffleFab();
    if (!isLocalVisible)
        localRecyclerContainer.setVisibility(View.VISIBLE);
    finalLocalSearchResultList.clear();
    for (int i = 0; i < localTrackList.size(); i++) {
        LocalTrack lt = localTrackList.get(i);
        String tmp1 = lt.getTitle().toLowerCase();
        String tmp2 = query.toLowerCase();
        if (tmp1.contains(tmp2)) {
            finalLocalSearchResultList.add(lt);
        }
    }
    if (!isLocalVisible && localsongsRecyclerView != null) {
        if (finalLocalSearchResultList.size() == 0) {
            localsongsRecyclerView.setVisibility(GONE);
            localNothingText.setVisibility(View.VISIBLE);
        } else {
            localsongsRecyclerView.setVisibility(View.VISIBLE);
            localNothingText.setVisibility(View.INVISIBLE);
        }
        (localsongsRecyclerView.getAdapter()).notifyDataSetChanged();
    }
    if (lFrag != null)
        lFrag.updateAdapter();
    if (query.equals("")) {
        localRecyclerContainer.setVisibility(GONE);
    }
    if (query.equals("") && isLocalVisible) {
        if (lFrag != null)
            lFrag.showShuffleFab();
    }
}
Also used : LocalMusicViewPagerFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment) LocalMusicFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) TextPaint(android.text.TextPaint)

Aggregations

LocalMusicFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicFragment)3 LocalMusicViewPagerFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment)3 Intent (android.content.Intent)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 TextPaint (android.text.TextPaint)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 EqualizerFragment (com.sdsmdg.harjot.MusicDNA.fragments.EqualizerFragment.EqualizerFragment)1 AlbumFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.AlbumFragment)1 ArtistFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.ArtistFragment)1 PlayerFragment (com.sdsmdg.harjot.MusicDNA.fragments.PlayerFragment.PlayerFragment)1 QueueFragment (com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment)1 ViewAlbumFragment (com.sdsmdg.harjot.MusicDNA.fragments.ViewAlbumFragment.ViewAlbumFragment)1 ViewArtistFragment (com.sdsmdg.harjot.MusicDNA.fragments.ViewArtistFragment.ViewArtistFragment)1 ViewSavedDNA (com.sdsmdg.harjot.MusicDNA.fragments.ViewSavedDNAsFragment.ViewSavedDNA)1 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)1