clean up album and artist models
This commit is contained in:
parent
d5476cc9d0
commit
2900b8b9a9
8 changed files with 22 additions and 66 deletions
|
|
@ -67,7 +67,7 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
||||||
switch (getItemViewType(position)) {
|
switch (getItemViewType(position)) {
|
||||||
case ALBUM:
|
case ALBUM:
|
||||||
final Album album = (Album) dataSet.get(position);
|
final Album album = (Album) dataSet.get(position);
|
||||||
holder.title.setText(album.getTitle());
|
holder.title.setText(album.title);
|
||||||
holder.text.setText(MusicUtil.getAlbumInfoString(activity, album));
|
holder.text.setText(MusicUtil.getAlbumInfoString(activity, album));
|
||||||
CustomGlideRequest.Builder
|
CustomGlideRequest.Builder
|
||||||
.from(Glide.with(activity), album.primary)
|
.from(Glide.with(activity), album.primary)
|
||||||
|
|
@ -75,7 +75,7 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
||||||
break;
|
break;
|
||||||
case ARTIST:
|
case ARTIST:
|
||||||
final Artist artist = (Artist) dataSet.get(position);
|
final Artist artist = (Artist) dataSet.get(position);
|
||||||
holder.title.setText(artist.getName());
|
holder.title.setText(artist.name);
|
||||||
holder.text.setText(MusicUtil.getArtistInfoString(activity, artist));
|
holder.text.setText(MusicUtil.getArtistInfoString(activity, artist));
|
||||||
CustomGlideRequest.Builder
|
CustomGlideRequest.Builder
|
||||||
.from(Glide.with(activity), artist.primary)
|
.from(Glide.with(activity), artist.primary)
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAlbumTitle(Album album) {
|
protected String getAlbumTitle(Album album) {
|
||||||
return album.getTitle();
|
return album.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAlbumText(Album album) {
|
protected String getAlbumText(Album album) {
|
||||||
|
|
@ -166,7 +166,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getName(Album album) {
|
protected String getName(Album album) {
|
||||||
return album.getTitle();
|
return album.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -190,13 +190,13 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
||||||
@Nullable String sectionName = null;
|
@Nullable String sectionName = null;
|
||||||
switch (PreferenceUtil.getInstance(activity).getAlbumSortMethod()) {
|
switch (PreferenceUtil.getInstance(activity).getAlbumSortMethod()) {
|
||||||
case SortMethod.NAME:
|
case SortMethod.NAME:
|
||||||
sectionName = dataSet.get(position).getTitle();
|
sectionName = dataSet.get(position).title;
|
||||||
break;
|
break;
|
||||||
case SortMethod.ARTIST:
|
case SortMethod.ARTIST:
|
||||||
sectionName = dataSet.get(position).getArtistName();
|
sectionName = dataSet.get(position).artistName;
|
||||||
break;
|
break;
|
||||||
case SortMethod.YEAR:
|
case SortMethod.YEAR:
|
||||||
return MusicUtil.getYearString(dataSet.get(position).getYear());
|
return MusicUtil.getYearString(dataSet.get(position).year);
|
||||||
case SortMethod.RANDOM:
|
case SortMethod.RANDOM:
|
||||||
return activity.getResources().getString(R.string.random);
|
return activity.getResources().getString(R.string.random);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getAlbumText(Album album) {
|
protected String getAlbumText(Album album) {
|
||||||
return MusicUtil.getYearString(album.getYear());
|
return MusicUtil.getYearString(album.year);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder.title != null) {
|
if (holder.title != null) {
|
||||||
holder.title.setText(artist.getName());
|
holder.title.setText(artist.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder.text != null) {
|
if (holder.text != null) {
|
||||||
|
|
@ -155,7 +155,7 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getName(Artist artist) {
|
protected String getName(Artist artist) {
|
||||||
return artist.getName();
|
return artist.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -167,7 +167,7 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
||||||
private List<Song> getSongList(@NonNull List<Artist> artists) {
|
private List<Song> getSongList(@NonNull List<Artist> artists) {
|
||||||
final List<Song> songs = new ArrayList<>();
|
final List<Song> songs = new ArrayList<>();
|
||||||
for (Artist artist : artists) {
|
for (Artist artist : artists) {
|
||||||
songs.addAll(artist.getSongs());
|
songs.addAll(artist.songs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return songs;
|
return songs;
|
||||||
|
|
@ -176,7 +176,7 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String getSectionName(int position) {
|
public String getSectionName(int position) {
|
||||||
return MusicUtil.getSectionName(dataSet.get(position).getName());
|
return MusicUtil.getSectionName(dataSet.get(position).name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends MediaEntryViewHolder {
|
public class ViewHolder extends MediaEntryViewHolder {
|
||||||
|
|
|
||||||
|
|
@ -54,30 +54,6 @@ public class Album implements Parcelable {
|
||||||
this.songs = new ArrayList<>();
|
this.songs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArtistId() {
|
|
||||||
return artistId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArtistName() {
|
|
||||||
return artistName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getYear() {
|
|
||||||
return year;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSongCount() {
|
|
||||||
return songs.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|
|
||||||
|
|
@ -52,33 +52,13 @@ public class Artist implements Parcelable {
|
||||||
this.songs = new ArrayList<>();
|
this.songs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSongCount() {
|
|
||||||
return songs.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAlbumCount() {
|
|
||||||
return albums.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Song> getSongs() {
|
|
||||||
return songs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
Artist artist = (Artist) o;
|
Artist artist = (Artist) o;
|
||||||
return id.equals(artist.getId());
|
return id.equals(artist.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -328,11 +328,11 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
||||||
private void setAlbum(Album album) {
|
private void setAlbum(Album album) {
|
||||||
this.album = album;
|
this.album = album;
|
||||||
|
|
||||||
getSupportActionBar().setTitle(album.getTitle());
|
getSupportActionBar().setTitle(album.title);
|
||||||
artistTextView.setText(album.getArtistName());
|
artistTextView.setText(album.artistName);
|
||||||
songCountTextView.setText(MusicUtil.getSongCountString(this, album.getSongCount()));
|
songCountTextView.setText(MusicUtil.getSongCountString(this, album.songs.size()));
|
||||||
durationTextView.setText(MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, album.songs)));
|
durationTextView.setText(MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, album.songs)));
|
||||||
albumYearTextView.setText(MusicUtil.getYearString(album.getYear()));
|
albumYearTextView.setText(MusicUtil.getYearString(album.year));
|
||||||
|
|
||||||
if (album.songs.size() != 0) adapter.swapDataSet(album.songs);
|
if (album.songs.size() != 0) adapter.swapDataSet(album.songs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
||||||
songListView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
songListView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||||
songListView.addHeaderView(songListHeader);
|
songListView.addHeaderView(songListHeader);
|
||||||
|
|
||||||
songAdapter = new ArtistSongAdapter(this, getArtist().getSongs(), this);
|
songAdapter = new ArtistSongAdapter(this, getArtist().songs, this);
|
||||||
songListView.setAdapter(songAdapter);
|
songListView.setAdapter(songAdapter);
|
||||||
|
|
||||||
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
|
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
|
@ -350,10 +350,10 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
||||||
private void setArtist(Artist artist) {
|
private void setArtist(Artist artist) {
|
||||||
this.artist = artist;
|
this.artist = artist;
|
||||||
|
|
||||||
getSupportActionBar().setTitle(artist.getName());
|
getSupportActionBar().setTitle(artist.name);
|
||||||
songCountTextView.setText(MusicUtil.getSongCountString(this, artist.getSongCount()));
|
songCountTextView.setText(MusicUtil.getSongCountString(this, artist.songs.size()));
|
||||||
albumCountTextView.setText(MusicUtil.getAlbumCountString(this, artist.getAlbumCount()));
|
albumCountTextView.setText(MusicUtil.getAlbumCountString(this, artist.albums.size()));
|
||||||
durationTextView.setText(MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, artist.getSongs())));
|
durationTextView.setText(MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, artist.songs)));
|
||||||
|
|
||||||
// TODO this activity will crash when an artist is passed with an empty album array
|
// TODO this activity will crash when an artist is passed with an empty album array
|
||||||
// something in the album adapter is causing the issue
|
// something in the album adapter is causing the issue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue