Migrated to RetroFit 2.0.0 beta
This commit is contained in:
parent
5cd9b4c7ad
commit
7fbbf52a6c
18 changed files with 211 additions and 670 deletions
|
|
@ -77,6 +77,10 @@ android {
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
packagingOptions {
|
||||||
|
exclude 'META-INF/LICENSE'
|
||||||
|
exclude 'META-INF/NOTICE'
|
||||||
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
disable 'MissingTranslation'
|
disable 'MissingTranslation'
|
||||||
disable 'InvalidPackage'
|
disable 'InvalidPackage'
|
||||||
|
|
@ -106,8 +110,9 @@ dependencies {
|
||||||
compile 'com.github.semoncat.seekarc:library:0.1'
|
compile 'com.github.semoncat.seekarc:library:0.1'
|
||||||
compile 'com.sothree.slidinguppanel:library:3.1.1'
|
compile 'com.sothree.slidinguppanel:library:3.1.1'
|
||||||
|
|
||||||
compile 'com.squareup.retrofit:retrofit:1.9.0'
|
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
|
||||||
compile 'com.squareup.okhttp:okhttp:2.4.0'
|
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'
|
compile 'com.github.kabouzeid:Android-Universal-Image-Loader:8ffb5d4afa'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient;
|
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.loader.AlbumSongLoader;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.util.LastFMUtil;
|
import com.kabouzeid.gramophone.util.LastFMUtil;
|
||||||
|
|
@ -64,8 +64,8 @@ public class PhonographImageDownloader extends BaseImageDownloader {
|
||||||
return super.getStream("", extra);
|
return super.getStream("", extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtistInfo artistInfo = lastFMRestClient.getApiService().getArtistInfo(artistName, data[0].equals("") ? null : data[0]);
|
LastFmArtist lastFmArtist = lastFMRestClient.getApiService().getArtistInfo(artistName, data[0].equals("") ? null : data[0]).execute().body();
|
||||||
return super.getStream(LastFMUtil.getLargestArtistImageUrl(artistInfo.getArtist().getImage()), extra);
|
return super.getStream(LastFMUtil.getLargestArtistImageUrl(lastFmArtist.getArtist().getImage()), extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,23 @@ import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.lastfm.rest.service.LastFMService;
|
import com.kabouzeid.gramophone.lastfm.rest.service.LastFMService;
|
||||||
import com.squareup.okhttp.Cache;
|
import com.squareup.okhttp.Cache;
|
||||||
|
import com.squareup.okhttp.Interceptor;
|
||||||
import com.squareup.okhttp.OkHttpClient;
|
import com.squareup.okhttp.OkHttpClient;
|
||||||
|
import com.squareup.okhttp.Request;
|
||||||
|
import com.squareup.okhttp.Response;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import retrofit.RequestInterceptor;
|
import retrofit.GsonConverterFactory;
|
||||||
import retrofit.RestAdapter;
|
import retrofit.Retrofit;
|
||||||
import retrofit.client.OkClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class LastFMRestClient {
|
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;
|
private LastFMService apiService;
|
||||||
|
|
||||||
|
|
@ -33,15 +36,20 @@ public class LastFMRestClient {
|
||||||
okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS);
|
okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS);
|
||||||
okHttpClient.setReadTimeout(20, TimeUnit.SECONDS);
|
okHttpClient.setReadTimeout(20, TimeUnit.SECONDS);
|
||||||
|
|
||||||
RestAdapter restAdapter = new RestAdapter.Builder()
|
okHttpClient.interceptors().add(new Interceptor() {
|
||||||
.setEndpoint(BASE_URL)
|
@Override
|
||||||
.setClient(new OkClient(okHttpClient))
|
public Response intercept(Chain chain) throws IOException {
|
||||||
.setRequestInterceptor(new RequestInterceptor() {
|
Request modifiedRequest = chain.request().newBuilder()
|
||||||
@Override
|
.addHeader("Cache-Control", String.format("max-age=%d, max-stale=%d", 31536000, 31536000))
|
||||||
public void intercept(@NonNull RequestInterceptor.RequestFacade request) {
|
.build();
|
||||||
request.addHeader("Cache-Control", String.format("max-age=%d, max-stale=%d", 31536000, 31536000));
|
return chain.proceed(modifiedRequest);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
Retrofit restAdapter = new Retrofit.Builder()
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
|
.client(okHttpClient)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
apiService = restAdapter.create(LastFMService.class);
|
apiService = restAdapter.create(LastFMService.class);
|
||||||
|
|
|
||||||
|
|
@ -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> image = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<Image> getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(List<Image> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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> image = new ArrayList<>();
|
||||||
|
@Expose
|
||||||
|
private Bio bio;
|
||||||
|
|
||||||
|
public List<Image> getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(List<Image> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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> image = new ArrayList<Image>();
|
|
||||||
@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<Image> getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param image The image
|
|
||||||
*/
|
|
||||||
public void setImage(List<Image> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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> image = new ArrayList<Image>();
|
|
||||||
@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<Image> getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param image The image
|
|
||||||
*/
|
|
||||||
public void setImage(List<Image> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -2,10 +2,10 @@ package com.kabouzeid.gramophone.lastfm.rest.service;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.lastfm.rest.model.albuminfo.AlbumInfo;
|
import com.kabouzeid.gramophone.lastfm.rest.model.LastFmAlbum;
|
||||||
import com.kabouzeid.gramophone.lastfm.rest.model.artistinfo.ArtistInfo;
|
import com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist;
|
||||||
|
|
||||||
import retrofit.Callback;
|
import retrofit.Call;
|
||||||
import retrofit.http.GET;
|
import retrofit.http.GET;
|
||||||
import retrofit.http.Header;
|
import retrofit.http.Header;
|
||||||
import retrofit.http.Query;
|
import retrofit.http.Query;
|
||||||
|
|
@ -15,17 +15,11 @@ import retrofit.http.Query;
|
||||||
*/
|
*/
|
||||||
public interface LastFMService {
|
public interface LastFMService {
|
||||||
String API_KEY = "bd9c6ea4d55ec9ed3af7d276e5ece304";
|
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")
|
@GET(BASE_QUERY_PARAMETERS + "&method=album.getinfo")
|
||||||
void getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName, Callback<AlbumInfo> callback);
|
Call<LastFmAlbum> getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName);
|
||||||
|
|
||||||
@GET(BASE_QUERY_PARAMETERS + "&method=album.getinfo")
|
|
||||||
AlbumInfo getAlbumInfo(@Query("album") String albumName, @Query("artist") String artistName);
|
|
||||||
|
|
||||||
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
|
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
|
||||||
void getArtistInfo(@Query("artist") String artistName, @Nullable @Header("Cache-Control") String cacheControl, Callback<ArtistInfo> callback);
|
Call<LastFmArtist> getArtistInfo(@Query("artist") String artistName, @Nullable @Header("Cache-Control") String cacheControl);
|
||||||
|
|
||||||
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
|
|
||||||
ArtistInfo getArtistInfo(@Query("artist") String artistName, @Nullable @Header("Cache-Control") String cacheControl);
|
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +37,7 @@ import com.kabouzeid.gramophone.imageloader.BlurProcessor;
|
||||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||||
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
||||||
import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient;
|
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.ArtistAlbumLoader;
|
||||||
import com.kabouzeid.gramophone.loader.ArtistLoader;
|
import com.kabouzeid.gramophone.loader.ArtistLoader;
|
||||||
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
||||||
|
|
@ -63,8 +63,7 @@ import java.util.ArrayList;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
import retrofit.RetrofitError;
|
import retrofit.Response;
|
||||||
import retrofit.client.Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Be careful when changing things in this Activity!
|
* Be careful when changing things in this Activity!
|
||||||
|
|
@ -256,11 +255,12 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBiography() {
|
private void loadBiography() {
|
||||||
lastFMRestClient.getApiService().getArtistInfo(artist.name, null, new Callback<ArtistInfo>() {
|
lastFMRestClient.getApiService().getArtistInfo(artist.name, null).enqueue(new Callback<LastFmArtist>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(@NonNull ArtistInfo artistInfo, Response response) {
|
public void onResponse(Response<LastFmArtist> response) {
|
||||||
if (artistInfo.getArtist() != null) {
|
LastFmArtist lastFmArtist = response.body();
|
||||||
String bio = artistInfo.getArtist().getBio().getContent();
|
if (lastFmArtist.getArtist() != null) {
|
||||||
|
String bio = lastFmArtist.getArtist().getBio().getContent();
|
||||||
if (bio != null && !bio.trim().equals("")) {
|
if (bio != null && !bio.trim().equals("")) {
|
||||||
biography = Html.fromHtml(bio);
|
biography = Html.fromHtml(bio);
|
||||||
return;
|
return;
|
||||||
|
|
@ -270,7 +270,8 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void onFailure(Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
biography = null;
|
biography = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.lastfm.rest.LastFMRestClient;
|
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.loader.AlbumSongLoader;
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
import com.kabouzeid.gramophone.model.Song;
|
||||||
import com.kabouzeid.gramophone.util.ImageUtil;
|
import com.kabouzeid.gramophone.util.ImageUtil;
|
||||||
|
|
@ -41,8 +41,7 @@ import java.util.Map;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
import retrofit.RetrofitError;
|
import retrofit.Response;
|
||||||
import retrofit.client.Response;
|
|
||||||
|
|
||||||
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
|
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();
|
Toast.makeText(this, getResources().getString(R.string.album_or_artist_empty), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastFMRestClient.getApiService().getAlbumInfo(albumTitleStr, albumArtistNameStr, new Callback<AlbumInfo>() {
|
lastFMRestClient.getApiService().getAlbumInfo(albumTitleStr, albumArtistNameStr).enqueue(new Callback<LastFmAlbum>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(@NonNull AlbumInfo albumInfo, Response response) {
|
public void onResponse(Response<LastFmAlbum> response) {
|
||||||
if (albumInfo.getAlbum() != null) {
|
LastFmAlbum lastFmAlbum = response.body();
|
||||||
|
if (lastFmAlbum.getAlbum() != null) {
|
||||||
final int smallerScreenSize = Util.getSmallerScreenSize(AlbumTagEditorActivity.this);
|
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()
|
new DisplayImageOptions.Builder()
|
||||||
.preProcessor(new BitmapProcessor() {
|
.preProcessor(new BitmapProcessor() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -140,7 +140,7 @@ public class AlbumTagEditorActivity extends AbsTagEditorActivity implements Text
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void onFailure(Throwable t) {
|
||||||
toastLoadingFailed();
|
toastLoadingFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.util;
|
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.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -15,9 +16,9 @@ public class LastFMUtil {
|
||||||
SMALL, MEDIUM, LARGE, EXTRALARGE, MEGA, UNKNOWN
|
SMALL, MEDIUM, LARGE, EXTRALARGE, MEGA, UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLargestArtistImageUrl(List<Image> images) {
|
public static String getLargestArtistImageUrl(List<Artist.Image> images) {
|
||||||
Map<ImageSize, String> imageUrls = new HashMap<>();
|
Map<ImageSize, String> imageUrls = new HashMap<>();
|
||||||
for (Image image : images) {
|
for (Artist.Image image : images) {
|
||||||
ImageSize size = null;
|
ImageSize size = null;
|
||||||
final String attribute = image.getSize();
|
final String attribute = image.getSize();
|
||||||
if (attribute == null) {
|
if (attribute == null) {
|
||||||
|
|
@ -36,9 +37,9 @@ public class LastFMUtil {
|
||||||
return getLargestImageUrl(imageUrls);
|
return getLargestImageUrl(imageUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLargestAlbumImageUrl(List<com.kabouzeid.gramophone.lastfm.rest.model.albuminfo.Image> images) {
|
public static String getLargestAlbumImageUrl(List<Album.Image> images) {
|
||||||
Map<ImageSize, String> imageUrls = new HashMap<>();
|
Map<ImageSize, String> imageUrls = new HashMap<>();
|
||||||
for (com.kabouzeid.gramophone.lastfm.rest.model.albuminfo.Image image : images) {
|
for (Album.Image image : images) {
|
||||||
ImageSize size = null;
|
ImageSize size = null;
|
||||||
final String attribute = image.getSize();
|
final String attribute = image.getSize();
|
||||||
if (attribute == null) {
|
if (attribute == null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue