diff --git a/app/build.gradle b/app/build.gradle index 1cffd483..f7887d64 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,6 +77,10 @@ android { signingConfig signingConfigs.debug } } + packagingOptions { + exclude 'META-INF/LICENSE' + exclude 'META-INF/NOTICE' + } lintOptions { disable 'MissingTranslation' disable 'InvalidPackage' @@ -106,8 +110,9 @@ dependencies { compile 'com.github.semoncat.seekarc:library:0.1' compile 'com.sothree.slidinguppanel:library:3.1.1' - compile 'com.squareup.retrofit:retrofit:1.9.0' - compile 'com.squareup.okhttp:okhttp:2.4.0' + compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' + compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' + compile 'com.squareup.okhttp:okhttp:2.5.0' compile 'com.github.kabouzeid:Android-Universal-Image-Loader:8ffb5d4afa' diff --git a/app/src/main/java/com/kabouzeid/gramophone/imageloader/PhonographImageDownloader.java b/app/src/main/java/com/kabouzeid/gramophone/imageloader/PhonographImageDownloader.java index d1c2bf7a..e16d288f 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/imageloader/PhonographImageDownloader.java +++ b/app/src/main/java/com/kabouzeid/gramophone/imageloader/PhonographImageDownloader.java @@ -5,7 +5,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient; -import com.kabouzeid.gramophone.lastfm.rest.model.artistinfo.ArtistInfo; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist; import com.kabouzeid.gramophone.loader.AlbumSongLoader; import com.kabouzeid.gramophone.model.Song; import com.kabouzeid.gramophone.util.LastFMUtil; @@ -64,8 +64,8 @@ public class PhonographImageDownloader extends BaseImageDownloader { return super.getStream("", extra); } - ArtistInfo artistInfo = lastFMRestClient.getApiService().getArtistInfo(artistName, data[0].equals("") ? null : data[0]); - return super.getStream(LastFMUtil.getLargestArtistImageUrl(artistInfo.getArtist().getImage()), extra); + LastFmArtist lastFmArtist = lastFMRestClient.getApiService().getArtistInfo(artistName, data[0].equals("") ? null : data[0]).execute().body(); + return super.getStream(LastFMUtil.getLargestArtistImageUrl(lastFmArtist.getArtist().getImage()), extra); } @Nullable diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/LastFMRestClient.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/LastFMRestClient.java index 79dc9f3e..a249af26 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/LastFMRestClient.java +++ b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/LastFMRestClient.java @@ -5,20 +5,23 @@ import android.support.annotation.NonNull; import com.kabouzeid.gramophone.lastfm.rest.service.LastFMService; import com.squareup.okhttp.Cache; +import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; import java.io.File; +import java.io.IOException; import java.util.concurrent.TimeUnit; -import retrofit.RequestInterceptor; -import retrofit.RestAdapter; -import retrofit.client.OkClient; +import retrofit.GsonConverterFactory; +import retrofit.Retrofit; /** * @author Karim Abou Zeid (kabouzeid) */ public class LastFMRestClient { - public static final String BASE_URL = "http://ws.audioscrobbler.com/2.0"; + public static final String BASE_URL = "http://ws.audioscrobbler.com/2.0/"; private LastFMService apiService; @@ -33,15 +36,20 @@ public class LastFMRestClient { okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS); okHttpClient.setReadTimeout(20, TimeUnit.SECONDS); - RestAdapter restAdapter = new RestAdapter.Builder() - .setEndpoint(BASE_URL) - .setClient(new OkClient(okHttpClient)) - .setRequestInterceptor(new RequestInterceptor() { - @Override - public void intercept(@NonNull RequestInterceptor.RequestFacade request) { - request.addHeader("Cache-Control", String.format("max-age=%d, max-stale=%d", 31536000, 31536000)); - } - }) + okHttpClient.interceptors().add(new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + Request modifiedRequest = chain.request().newBuilder() + .addHeader("Cache-Control", String.format("max-age=%d, max-stale=%d", 31536000, 31536000)) + .build(); + return chain.proceed(modifiedRequest); + } + }); + + Retrofit restAdapter = new Retrofit.Builder() + .baseUrl(BASE_URL) + .client(okHttpClient) + .addConverterFactory(GsonConverterFactory.create()) .build(); apiService = restAdapter.create(LastFMService.class); diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/LastFmAlbum.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/LastFmAlbum.java new file mode 100644 index 00000000..1992b7e3 --- /dev/null +++ b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/LastFmAlbum.java @@ -0,0 +1,62 @@ + +package com.kabouzeid.gramophone.lastfm.rest.model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; + +public class LastFmAlbum { + + @Expose + private Album album; + + public Album getAlbum() { + return album; + } + + public void setAlbum(Album album) { + this.album = album; + } + + public static class Album { + + @Expose + private List image = new ArrayList<>(); + + public List getImage() { + return image; + } + + public void setImage(List image) { + this.image = image; + } + + public static class Image { + + @SerializedName("#text") + @Expose + private String Text; + @Expose + private String size; + + public String getText() { + return Text; + } + + public void setText(String Text) { + this.Text = Text; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + } + } + +} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/LastFmArtist.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/LastFmArtist.java new file mode 100644 index 00000000..42478cfd --- /dev/null +++ b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/LastFmArtist.java @@ -0,0 +1,89 @@ + +package com.kabouzeid.gramophone.lastfm.rest.model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; + +public class LastFmArtist { + + @Expose + private Artist artist; + + public Artist getArtist() { + return artist; + } + + public void setArtist(Artist artist) { + this.artist = artist; + } + + public static class Artist { + + @Expose + private List image = new ArrayList<>(); + @Expose + private Bio bio; + + public List getImage() { + return image; + } + + public void setImage(List image) { + this.image = image; + } + + public Bio getBio() { + return bio; + } + + public void setBio(Bio bio) { + this.bio = bio; + } + + public class Bio { + + @Expose + private String content; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + } + + public static class Image { + + @SerializedName("#text") + @Expose + private String Text; + @Expose + private String size; + + public String getText() { + return Text; + } + + public void setText(String Text) { + this.Text = Text; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + } + + } + +} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Album.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Album.java deleted file mode 100644 index 990e19e6..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Album.java +++ /dev/null @@ -1,172 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.albuminfo; - -import com.google.gson.annotations.Expose; - -import java.util.ArrayList; -import java.util.List; - -public class Album { - - @Expose - private String name; - @Expose - private String artist; - @Expose - private String id; - @Expose - private String mbid; - @Expose - private String url; - @Expose - private String releasedate; - @Expose - private List image = new ArrayList(); - @Expose - private String listeners; - @Expose - private String playcount; - @Expose - private Wiki wiki; - - /** - * @return The name - */ - public String getName() { - return name; - } - - /** - * @param name The name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return The artist - */ - public String getArtist() { - return artist; - } - - /** - * @param artist The artist - */ - public void setArtist(String artist) { - this.artist = artist; - } - - /** - * @return The id - */ - public String getId() { - return id; - } - - /** - * @param id The id - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return The mbid - */ - public String getMbid() { - return mbid; - } - - /** - * @param mbid The mbid - */ - public void setMbid(String mbid) { - this.mbid = mbid; - } - - /** - * @return The url - */ - public String getUrl() { - return url; - } - - /** - * @param url The url - */ - public void setUrl(String url) { - this.url = url; - } - - /** - * @return The releasedate - */ - public String getReleasedate() { - return releasedate; - } - - /** - * @param releasedate The releasedate - */ - public void setReleasedate(String releasedate) { - this.releasedate = releasedate; - } - - /** - * @return The image - */ - public List getImage() { - return image; - } - - /** - * @param image The image - */ - public void setImage(List image) { - this.image = image; - } - - /** - * @return The listeners - */ - public String getListeners() { - return listeners; - } - - /** - * @param listeners The listeners - */ - public void setListeners(String listeners) { - this.listeners = listeners; - } - - /** - * @return The playcount - */ - public String getPlaycount() { - return playcount; - } - - /** - * @param playcount The playcount - */ - public void setPlaycount(String playcount) { - this.playcount = playcount; - } - - /** - * @return The wiki - */ - public Wiki getWiki() { - return wiki; - } - - /** - * @param wiki The wiki - */ - public void setWiki(Wiki wiki) { - this.wiki = wiki; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/AlbumInfo.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/AlbumInfo.java deleted file mode 100644 index e2b74ca6..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/AlbumInfo.java +++ /dev/null @@ -1,25 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.albuminfo; - -import com.google.gson.annotations.Expose; - -public class AlbumInfo { - - @Expose - private Album album; - - /** - * @return The album - */ - public Album getAlbum() { - return album; - } - - /** - * @param album The album - */ - public void setAlbum(Album album) { - this.album = album; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Image.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Image.java deleted file mode 100644 index 1d825384..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Image.java +++ /dev/null @@ -1,43 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.albuminfo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Image { - - @SerializedName("#text") - @Expose - private String Text; - @Expose - private String size; - - /** - * @return The Text - */ - public String getText() { - return Text; - } - - /** - * @param Text The #text - */ - public void setText(String Text) { - this.Text = Text; - } - - /** - * @return The size - */ - public String getSize() { - return size; - } - - /** - * @param size The size - */ - public void setSize(String size) { - this.size = size; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Wiki.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Wiki.java deleted file mode 100644 index 09a2b8f8..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/albuminfo/Wiki.java +++ /dev/null @@ -1,57 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.albuminfo; - -import com.google.gson.annotations.Expose; - -public class Wiki { - - @Expose - private String published; - @Expose - private String summary; - @Expose - private String content; - - /** - * @return The published - */ - public String getPublished() { - return published; - } - - /** - * @param published The published - */ - public void setPublished(String published) { - this.published = published; - } - - /** - * @return The summary - */ - public String getSummary() { - return summary; - } - - /** - * @param summary The summary - */ - public void setSummary(String summary) { - this.summary = summary; - } - - /** - * @return The content - */ - public String getContent() { - return content; - } - - /** - * @param content The content - */ - public void setContent(String content) { - this.content = content; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Artist.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Artist.java deleted file mode 100644 index 692d75b5..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Artist.java +++ /dev/null @@ -1,124 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.artistinfo; - -import com.google.gson.annotations.Expose; - -import java.util.ArrayList; -import java.util.List; - -public class Artist { - - @Expose - private String name; - @Expose - private String mbid; - @Expose - private String url; - @Expose - private List image = new ArrayList(); - @Expose - private String ontour; - @Expose - private Stats stats; - @Expose - private Bio bio; - - /** - * @return The name - */ - public String getName() { - return name; - } - - /** - * @param name The name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return The mbid - */ - public String getMbid() { - return mbid; - } - - /** - * @param mbid The mbid - */ - public void setMbid(String mbid) { - this.mbid = mbid; - } - - /** - * @return The url - */ - public String getUrl() { - return url; - } - - /** - * @param url The url - */ - public void setUrl(String url) { - this.url = url; - } - - /** - * @return The image - */ - public List getImage() { - return image; - } - - /** - * @param image The image - */ - public void setImage(List image) { - this.image = image; - } - - /** - * @return The ontour - */ - public String getOntour() { - return ontour; - } - - /** - * @param ontour The ontour - */ - public void setOntour(String ontour) { - this.ontour = ontour; - } - - /** - * @return The stats - */ - public Stats getStats() { - return stats; - } - - /** - * @param stats The stats - */ - public void setStats(Stats stats) { - this.stats = stats; - } - - /** - * @return The bio - */ - public Bio getBio() { - return bio; - } - - /** - * @param bio The bio - */ - public void setBio(Bio bio) { - this.bio = bio; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/ArtistInfo.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/ArtistInfo.java deleted file mode 100644 index 4c489ad1..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/ArtistInfo.java +++ /dev/null @@ -1,25 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.artistinfo; - -import com.google.gson.annotations.Expose; - -public class ArtistInfo { - - @Expose - private Artist artist; - - /** - * @return The artist - */ - public Artist getArtist() { - return artist; - } - - /** - * @param artist The artist - */ - public void setArtist(Artist artist) { - this.artist = artist; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Bio.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Bio.java deleted file mode 100644 index 54d51eec..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Bio.java +++ /dev/null @@ -1,89 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.artistinfo; - -import com.google.gson.annotations.Expose; - -public class Bio { - - @Expose - private String published; - @Expose - private String summary; - @Expose - private String content; - @Expose - private String placeformed; - @Expose - private String yearformed; - - /** - * @return The published - */ - public String getPublished() { - return published; - } - - /** - * @param published The published - */ - public void setPublished(String published) { - this.published = published; - } - - /** - * @return The summary - */ - public String getSummary() { - return summary; - } - - /** - * @param summary The summary - */ - public void setSummary(String summary) { - this.summary = summary; - } - - /** - * @return The content - */ - public String getContent() { - return content; - } - - /** - * @param content The content - */ - public void setContent(String content) { - this.content = content; - } - - /** - * @return The placeformed - */ - public String getPlaceformed() { - return placeformed; - } - - /** - * @param placeformed The placeformed - */ - public void setPlaceformed(String placeformed) { - this.placeformed = placeformed; - } - - /** - * @return The yearformed - */ - public String getYearformed() { - return yearformed; - } - - /** - * @param yearformed The yearformed - */ - public void setYearformed(String yearformed) { - this.yearformed = yearformed; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Image.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Image.java deleted file mode 100644 index 59f3b908..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Image.java +++ /dev/null @@ -1,43 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.artistinfo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Image { - - @SerializedName("#text") - @Expose - private String Text; - @Expose - private String size; - - /** - * @return The Text - */ - public String getText() { - return Text; - } - - /** - * @param Text The #text - */ - public void setText(String Text) { - this.Text = Text; - } - - /** - * @return The size - */ - public String getSize() { - return size; - } - - /** - * @param size The size - */ - public void setSize(String size) { - this.size = size; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Stats.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Stats.java deleted file mode 100644 index 18a8fd4e..00000000 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/model/artistinfo/Stats.java +++ /dev/null @@ -1,41 +0,0 @@ - -package com.kabouzeid.gramophone.lastfm.rest.model.artistinfo; - -import com.google.gson.annotations.Expose; - -public class Stats { - - @Expose - private String listeners; - @Expose - private String playcount; - - /** - * @return The listeners - */ - public String getListeners() { - return listeners; - } - - /** - * @param listeners The listeners - */ - public void setListeners(String listeners) { - this.listeners = listeners; - } - - /** - * @return The playcount - */ - public String getPlaycount() { - return playcount; - } - - /** - * @param playcount The playcount - */ - public void setPlaycount(String playcount) { - this.playcount = playcount; - } - -} diff --git a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/service/LastFMService.java b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/service/LastFMService.java index 164d1cf4..df9194aa 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/service/LastFMService.java +++ b/app/src/main/java/com/kabouzeid/gramophone/lastfm/rest/service/LastFMService.java @@ -2,10 +2,10 @@ package com.kabouzeid.gramophone.lastfm.rest.service; import android.support.annotation.Nullable; -import com.kabouzeid.gramophone.lastfm.rest.model.albuminfo.AlbumInfo; -import com.kabouzeid.gramophone.lastfm.rest.model.artistinfo.ArtistInfo; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmAlbum; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist; -import retrofit.Callback; +import retrofit.Call; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.Query; @@ -15,17 +15,11 @@ import retrofit.http.Query; */ public interface LastFMService { String API_KEY = "bd9c6ea4d55ec9ed3af7d276e5ece304"; - String BASE_QUERY_PARAMETERS = "/?format=json&autocorrect=1&api_key=" + API_KEY; + String BASE_QUERY_PARAMETERS = "?format=json&autocorrect=1&api_key=" + API_KEY; @GET(BASE_QUERY_PARAMETERS + "&method=album.getinfo") - void getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName, Callback callback); - - @GET(BASE_QUERY_PARAMETERS + "&method=album.getinfo") - AlbumInfo getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName); + Call getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName); @GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo") - void getArtistInfo(@Query("artist") String artistName, @Nullable @Header("Cache-Control") String cacheControl, Callback callback); - - @GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo") - ArtistInfo getArtistInfo(@Query("artist") String artistName, @Nullable @Header("Cache-Control") String cacheControl); + Call getArtistInfo(@Query("artist") String artistName, @Nullable @Header("Cache-Control") String cacheControl); } \ No newline at end of file diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java index d9e99bdf..9946b97e 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java +++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java @@ -37,7 +37,7 @@ import com.kabouzeid.gramophone.imageloader.BlurProcessor; import com.kabouzeid.gramophone.interfaces.CabHolder; import com.kabouzeid.gramophone.interfaces.PaletteColorHolder; import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient; -import com.kabouzeid.gramophone.lastfm.rest.model.artistinfo.ArtistInfo; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist; import com.kabouzeid.gramophone.loader.ArtistAlbumLoader; import com.kabouzeid.gramophone.loader.ArtistLoader; import com.kabouzeid.gramophone.loader.ArtistSongLoader; @@ -63,8 +63,7 @@ import java.util.ArrayList; import butterknife.Bind; import butterknife.ButterKnife; import retrofit.Callback; -import retrofit.RetrofitError; -import retrofit.client.Response; +import retrofit.Response; /** * Be careful when changing things in this Activity! @@ -256,11 +255,12 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement } private void loadBiography() { - lastFMRestClient.getApiService().getArtistInfo(artist.name, null, new Callback() { + lastFMRestClient.getApiService().getArtistInfo(artist.name, null).enqueue(new Callback() { @Override - public void success(@NonNull ArtistInfo artistInfo, Response response) { - if (artistInfo.getArtist() != null) { - String bio = artistInfo.getArtist().getBio().getContent(); + public void onResponse(Response response) { + LastFmArtist lastFmArtist = response.body(); + if (lastFmArtist.getArtist() != null) { + String bio = lastFmArtist.getArtist().getBio().getContent(); if (bio != null && !bio.trim().equals("")) { biography = Html.fromHtml(bio); return; @@ -270,7 +270,8 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement } @Override - public void failure(RetrofitError error) { + public void onFailure(Throwable t) { + t.printStackTrace(); biography = null; } }); diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/tageditor/AlbumTagEditorActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/tageditor/AlbumTagEditorActivity.java index f75eb2a6..53b4d0db 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/tageditor/AlbumTagEditorActivity.java +++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/tageditor/AlbumTagEditorActivity.java @@ -13,7 +13,7 @@ import android.widget.Toast; import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient; -import com.kabouzeid.gramophone.lastfm.rest.model.albuminfo.AlbumInfo; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmAlbum; import com.kabouzeid.gramophone.loader.AlbumSongLoader; import com.kabouzeid.gramophone.model.Song; import com.kabouzeid.gramophone.util.ImageUtil; @@ -41,8 +41,7 @@ import java.util.Map; import butterknife.Bind; import butterknife.ButterKnife; import retrofit.Callback; -import retrofit.RetrofitError; -import retrofit.client.Response; +import retrofit.Response; public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher { @@ -101,12 +100,13 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text Toast.makeText(this, getResources().getString(R.string.album_or_artist_empty), Toast.LENGTH_SHORT).show(); return; } - lastFMRestClient.getApiService().getAlbumInfo(albumTitleStr, albumArtistNameStr, new Callback() { + lastFMRestClient.getApiService().getAlbumInfo(albumTitleStr, albumArtistNameStr).enqueue(new Callback() { @Override - public void success(@NonNull AlbumInfo albumInfo, Response response) { - if (albumInfo.getAlbum() != null) { + public void onResponse(Response response) { + LastFmAlbum lastFmAlbum = response.body(); + if (lastFmAlbum.getAlbum() != null) { final int smallerScreenSize = Util.getSmallerScreenSize(AlbumTagEditorActivity.this); - ImageLoader.getInstance().loadImage(LastFMUtil.getLargestAlbumImageUrl(albumInfo.getAlbum().getImage()), + ImageLoader.getInstance().loadImage(LastFMUtil.getLargestAlbumImageUrl(lastFmAlbum.getAlbum().getImage()), new DisplayImageOptions.Builder() .preProcessor(new BitmapProcessor() { @Override @@ -140,7 +140,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text } @Override - public void failure(RetrofitError error) { + public void onFailure(Throwable t) { toastLoadingFailed(); } diff --git a/app/src/main/java/com/kabouzeid/gramophone/util/LastFMUtil.java b/app/src/main/java/com/kabouzeid/gramophone/util/LastFMUtil.java index 9290324a..57a1b5d6 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/util/LastFMUtil.java +++ b/app/src/main/java/com/kabouzeid/gramophone/util/LastFMUtil.java @@ -1,6 +1,7 @@ package com.kabouzeid.gramophone.util; -import com.kabouzeid.gramophone.lastfm.rest.model.artistinfo.Image; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmAlbum.Album; +import com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist.Artist; import java.util.HashMap; import java.util.List; @@ -15,9 +16,9 @@ public class LastFMUtil { SMALL, MEDIUM, LARGE, EXTRALARGE, MEGA, UNKNOWN } - public static String getLargestArtistImageUrl(List images) { + public static String getLargestArtistImageUrl(List images) { Map imageUrls = new HashMap<>(); - for (Image image : images) { + for (Artist.Image image : images) { ImageSize size = null; final String attribute = image.getSize(); if (attribute == null) { @@ -36,9 +37,9 @@ public class LastFMUtil { return getLargestImageUrl(imageUrls); } - public static String getLargestAlbumImageUrl(List images) { + public static String getLargestAlbumImageUrl(List images) { Map imageUrls = new HashMap<>(); - for (com.kabouzeid.gramophone.lastfm.rest.model.albuminfo.Image image : images) { + for (Album.Image image : images) { ImageSize size = null; final String attribute = image.getSize(); if (attribute == null) {