package org.moire.ultrasonic.util; import android.content.Context; import org.moire.ultrasonic.domain.MusicDirectory; import java.util.HashSet; import java.util.Set; public class AlbumHeader { private boolean isAllVideo; private long totalDuration; private Set artists; private Set grandParents; private Set genres; private Set years; public boolean getIsAllVideo() { return isAllVideo; } public long getTotalDuration() { return totalDuration; } public Set getArtists() { return artists; } public Set getGrandParents() { return this.grandParents; } public Set getGenres() { return this.genres; } public Set getYears() { return this.years; } public AlbumHeader() { this.artists = new HashSet(); this.grandParents = new HashSet(); this.genres = new HashSet(); this.years = new HashSet(); this.isAllVideo = true; this.totalDuration = 0; } public static AlbumHeader processEntries(Context context, Iterable entries) { AlbumHeader albumHeader = new AlbumHeader(); for (MusicDirectory.Entry entry : entries) { if (!entry.isVideo()) { albumHeader.isAllVideo = false; } if (!entry.isDirectory()) { if (Settings.getShouldUseFolderForArtistName()) { albumHeader.processGrandParents(entry); } if (entry.getArtist() != null) { Integer duration = entry.getDuration(); if (duration != null) { albumHeader.totalDuration += duration; } albumHeader.artists.add(entry.getArtist()); } if (entry.getGenre() != null) { albumHeader.genres.add(entry.getGenre()); } if (entry.getYear() != null) { albumHeader.years.add(entry.getYear()); } } } return albumHeader; } private void processGrandParents(MusicDirectory.Entry entry) { String grandParent = Util.getGrandparent(entry.getPath()); if (grandParent != null) { this.grandParents.add(grandParent); } } }