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();
}
}
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();
}
}
Aggregations