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