Search in sources :

Example 31 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack 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)

Example 32 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.

the class HomeActivity method refreshAlbumAndArtists.

public void refreshAlbumAndArtists() {
    albums.clear();
    finalAlbums.clear();
    artists.clear();
    finalArtists.clear();
    for (int i = 0; i < localTrackList.size(); i++) {
        LocalTrack lt = localTrackList.get(i);
        String thisAlbum = lt.getAlbum();
        int pos = checkAlbum(thisAlbum);
        if (pos != -1) {
            albums.get(pos).getAlbumSongs().add(lt);
        } else {
            List<LocalTrack> llt = new ArrayList<>();
            llt.add(lt);
            Album ab = new Album(thisAlbum, llt);
            albums.add(ab);
        }
        if (pos != -1) {
            finalAlbums.get(pos).getAlbumSongs().add(lt);
        } else {
            List<LocalTrack> llt = new ArrayList<>();
            llt.add(lt);
            Album ab = new Album(thisAlbum, llt);
            finalAlbums.add(ab);
        }
        String thisArtist = lt.getArtist();
        pos = checkArtist(thisArtist);
        if (pos != -1) {
            artists.get(pos).getArtistSongs().add(lt);
        } else {
            List<LocalTrack> llt = new ArrayList<>();
            llt.add(lt);
            Artist ab = new Artist(thisArtist, llt);
            artists.add(ab);
        }
        if (pos != -1) {
            finalArtists.get(pos).getArtistSongs().add(lt);
        } else {
            List<LocalTrack> llt = new ArrayList<>();
            llt.add(lt);
            Artist ab = new Artist(thisArtist, llt);
            finalArtists.add(ab);
        }
    }
    System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
    try {
        if (localTrackList.size() > 0) {
            Collections.sort(localTrackList, new LocalMusicComparator());
            Collections.sort(finalLocalSearchResultList, new LocalMusicComparator());
        }
        if (albums.size() > 0) {
            Collections.sort(albums, new AlbumComparator());
            Collections.sort(finalAlbums, new AlbumComparator());
        }
        if (artists.size() > 0) {
            Collections.sort(artists, new ArtistComparator());
            Collections.sort(finalArtists, new ArtistComparator());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Artist(com.sdsmdg.harjot.MusicDNA.models.Artist) ArrayList(java.util.ArrayList) Album(com.sdsmdg.harjot.MusicDNA.models.Album) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) LocalMusicComparator(com.sdsmdg.harjot.MusicDNA.utilities.comparators.LocalMusicComparator) AlbumComparator(com.sdsmdg.harjot.MusicDNA.utilities.comparators.AlbumComparator) TextPaint(android.text.TextPaint) ArtistComparator(com.sdsmdg.harjot.MusicDNA.utilities.comparators.ArtistComparator) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)32 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)24 Track (com.sdsmdg.harjot.MusicDNA.models.Track)15 RecyclerView (android.support.v7.widget.RecyclerView)12 View (android.view.View)12 ImageView (android.widget.ImageView)11 TextView (android.widget.TextView)11 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)8 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)8 TextPaint (android.text.TextPaint)4 CustomLocalBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog)4 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)3 MotionEvent (android.view.MotionEvent)3 CustomGeneralBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog)3 LocalTrackRecyclerAdapter (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalTrackRecyclerAdapter)3 SimpleItemTouchHelperCallback (com.sdsmdg.harjot.MusicDNA.itemtouchhelpers.SimpleItemTouchHelperCallback)3 FileNotFoundException (java.io.FileNotFoundException)3 Random (java.util.Random)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2