Added control for the auto download setting.
This commit is contained in:
parent
dc0e5ed7f8
commit
d15f056e00
3 changed files with 71 additions and 31 deletions
|
|
@ -98,6 +98,7 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
|
||||
@Nullable
|
||||
private Spanned wiki;
|
||||
private MaterialDialog wikiDialog;
|
||||
private LastFMRestClient lastFMRestClient;
|
||||
|
||||
@Override
|
||||
|
|
@ -255,14 +256,6 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
return true;
|
||||
}
|
||||
|
||||
private MaterialDialog getWikiDialog() {
|
||||
return new MaterialDialog.Builder(AlbumDetailActivity.this)
|
||||
.title(getAlbum().getTitle())
|
||||
.content(wiki != null ? wiki : "")
|
||||
.positiveText(android.R.string.ok)
|
||||
.build();
|
||||
}
|
||||
|
||||
private void loadWiki() {
|
||||
final Callback<LastFmAlbum> wikiCallback = new Callback<LastFmAlbum>(){
|
||||
@Override
|
||||
|
|
@ -272,14 +265,17 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
String wik = lastFmAlbum.getAlbum().getWiki().getContent();
|
||||
if (wik != null && !wik.trim().equals("")) {
|
||||
wiki = Html.fromHtml(wik);
|
||||
wikiReady();
|
||||
return;
|
||||
}
|
||||
else if(call.request().url().queryParameter("lang") != null) {
|
||||
//If the "lang" parameter is set and no wiki is given, retry with default language
|
||||
lastFMRestClient.getApiService().getAlbumInfo(getAlbum().getTitle(), getAlbum().getArtistName(), null).enqueue(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(call.request().url().queryParameter("lang") != null){
|
||||
//If the "lang" parameter is set and no wiki is given, retry with default language
|
||||
lastFMRestClient.getApiService().getAlbumInfo(getAlbum().getTitle(), getAlbum().getArtistName(), null).enqueue(this);
|
||||
}
|
||||
wiki = null;
|
||||
wikiReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -291,6 +287,17 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
lastFMRestClient.getApiService().getAlbumInfo(getAlbum().getTitle(), getAlbum().getArtistName(), Locale.getDefault().getLanguage()).enqueue(wikiCallback);
|
||||
}
|
||||
|
||||
private void wikiReady(){
|
||||
if(!Util.isAllowedToAutoDownload(AlbumDetailActivity.this)) {
|
||||
if(wiki != null) {
|
||||
wikiDialog.setContent(wiki);
|
||||
} else {
|
||||
wikiDialog.dismiss();
|
||||
Toast.makeText(AlbumDetailActivity.this, getResources().getString(R.string.wiki_unavailable), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
|
@ -316,10 +323,17 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
NavigationUtil.goToArtist(this, getAlbum().getArtistId());
|
||||
return true;
|
||||
case R.id.action_wiki:
|
||||
if (wiki != null) {
|
||||
getWikiDialog().show();
|
||||
} else {
|
||||
Toast.makeText(AlbumDetailActivity.this, getResources().getString(R.string.wiki_unavailable), Toast.LENGTH_SHORT).show();
|
||||
if(Util.isAllowedToAutoDownload(AlbumDetailActivity.this)) {
|
||||
if (wiki != null) {
|
||||
wikiDialog.setContent(wiki);
|
||||
wikiDialog.show();
|
||||
} else {
|
||||
Toast.makeText(AlbumDetailActivity.this, getResources().getString(R.string.wiki_unavailable), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
wikiDialog.show();
|
||||
loadWiki();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -388,7 +402,13 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
|||
private void setAlbum(Album album) {
|
||||
this.album = album;
|
||||
loadAlbumCover();
|
||||
loadWiki();
|
||||
if(Util.isAllowedToAutoDownload(AlbumDetailActivity.this))
|
||||
loadWiki();
|
||||
wikiDialog=new MaterialDialog.Builder(AlbumDetailActivity.this)
|
||||
.title(album.getTitle())
|
||||
.content("")
|
||||
.positiveText(android.R.string.ok)
|
||||
.build();
|
||||
albumTitleView.setText(album.getTitle());
|
||||
adapter.swapDataSet(album.songs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
private Artist artist;
|
||||
@Nullable
|
||||
private Spanned biography;
|
||||
private MaterialDialog biographyDialog;
|
||||
private HorizontalAlbumAdapter albumAdapter;
|
||||
private ArtistSongAdapter songAdapter;
|
||||
|
||||
|
|
@ -233,14 +234,17 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
String bio = lastFmArtist.getArtist().getBio().getContent();
|
||||
if (bio != null && !bio.trim().equals("")) {
|
||||
biography = Html.fromHtml(bio);
|
||||
biographyReady();
|
||||
return;
|
||||
}
|
||||
else if(call.request().url().queryParameter("lang") != null){
|
||||
//If the "lang" parameter is set and no bio is given, retry with default language
|
||||
else if(call.request().url().queryParameter("lang") != null) {
|
||||
//If the "lang" parameter is set and no biography is given, retry with default language
|
||||
lastFMRestClient.getApiService().getArtistInfo(getArtist().getName(), null, null).enqueue(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
biography = null;
|
||||
biographyReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -252,12 +256,15 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
lastFMRestClient.getApiService().getArtistInfo(getArtist().getName(), Locale.getDefault().getLanguage(), null).enqueue(bioCallback);
|
||||
}
|
||||
|
||||
private MaterialDialog getBiographyDialog() {
|
||||
return new MaterialDialog.Builder(ArtistDetailActivity.this)
|
||||
.title(getArtist().getName())
|
||||
.content(biography != null ? biography : "")
|
||||
.positiveText(android.R.string.ok)
|
||||
.build();
|
||||
private void biographyReady() {
|
||||
if(!Util.isAllowedToAutoDownload(ArtistDetailActivity.this)) {
|
||||
if(biography != null) {
|
||||
biographyDialog.setContent(biography);
|
||||
} else {
|
||||
biographyDialog.dismiss();
|
||||
Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.biography_unavailable), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArtistImage(final boolean forceDownload) {
|
||||
|
|
@ -350,10 +357,17 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
super.onBackPressed();
|
||||
return true;
|
||||
case R.id.action_biography:
|
||||
if (biography != null) {
|
||||
getBiographyDialog().show();
|
||||
} else {
|
||||
Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.biography_unavailable), Toast.LENGTH_SHORT).show();
|
||||
if(Util.isAllowedToAutoDownload(ArtistDetailActivity.this)) {
|
||||
if (biography != null) {
|
||||
biographyDialog.setContent(biography);
|
||||
biographyDialog.show();
|
||||
} else {
|
||||
Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.biography_unavailable), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
biographyDialog.show();
|
||||
loadBiography();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_re_download_artist_image:
|
||||
|
|
@ -421,7 +435,13 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
private void setArtist(Artist artist) {
|
||||
this.artist = artist;
|
||||
loadArtistImage(false);
|
||||
loadBiography();
|
||||
if(Util.isAllowedToAutoDownload(ArtistDetailActivity.this))
|
||||
loadBiography();
|
||||
biographyDialog=new MaterialDialog.Builder(ArtistDetailActivity.this)
|
||||
.title(artist.getName())
|
||||
.content("")
|
||||
.positiveText(android.R.string.ok)
|
||||
.build();
|
||||
artistName.setText(artist.getName());
|
||||
songAdapter.swapDataSet(artist.getSongs());
|
||||
albumAdapter.swapDataSet(artist.albums);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue