public Track GetTrack(int position) { // Return Type: // 0 = Track // 1 = Artist // 2 = Album // 3 = Inside Artist // 4 = Inside Album if (returnType != 3 && returnType != 4) { Track t = trackList.get(position); listPosition = position; if (t != null) { return t; } else { return null; } } else if (returnType == 3) { listPosition = position; ArrayList<Track> byAr = new ArrayList<Track>(); for (Track t : trackList) { if (lastUsedArtist.contains(t.GetArtist())) { byAr.add(t); } } trackList = byAr; return byAr.get(position); } else { listPosition = position; ArrayList<Track> byAlbum = new ArrayList<Track>(); for (Track t : trackList) { if (lastUsedAlbum.contains(t.GetAlbum())) { byAlbum.add(t); } } trackList = byAlbum; return trackList.get(position); } }
public String[] GetTracksByArtist(int position) { // Return Type: // 0 = Track // 1 = Artist // 2 = Album // 3 = Inside Artist // 4 = Inside Album if (returnType == 1) { Collections.sort(artistList); String[] list = new String[trackList.size()]; String artistName = artistList.get(position); int i = 0; for (Track t : trackList) { if (artistName.contains(t.GetArtist())) { list[i] = t.GetTitle(); i++; } } String[] compact = new String[i]; for (int k = 0; k < i; k++) { if (list[k] != "" && list[k] != null) { compact[k] = list[k]; } } lastUsedArtist = artistName; returnType = 3; return compact; } else { return null; } }
public String[] GetList() { // Return Type: // 0 = Track // 1 = Artist // 2 = Album // 3 = Inside Artist // 4 = Inside Album int count = 0; String[] list; if (returnType == 0) { list = new String[trackList.size()]; for (Track t : trackList) { list[count] = t.GetTitle() + " - " + t.GetArtist(); count++; } } else if (returnType == 1) { ArrayList<String> tempArray = new ArrayList<String>(); for (Track t : trackList) { tempArray.add(t.GetArtist()); count++; } HashSet<String> h = new HashSet<String>(tempArray); tempArray.clear(); tempArray.addAll(h); Collections.sort(tempArray); int x = 0; for (String s : tempArray) { if (s != null && !s.equals("")) { x++; } } list = new String[x]; artistList.clear(); for (int i = 0; i < x; i++) { list[i] = tempArray.get(i); artistList.add(list[i]); } } else { ArrayList<String> tempArray = new ArrayList<String>(); for (Track t : trackList) { tempArray.add(t.GetAlbum()); count++; } HashSet<String> h = new HashSet<String>(tempArray); tempArray.clear(); tempArray.addAll(h); Collections.sort(tempArray); int x = 0; for (String s : tempArray) { if (s != null && !s.equals("")) { x++; } } list = new String[x]; albumList.clear(); for (int i = 0; i < x; i++) { list[i] = tempArray.get(i); albumList.add(list[i]); } } return list; }