Added Dagger

This commit is contained in:
h4h13 2019-09-05 01:00:24 +05:30
parent 074298dcb0
commit 6cdea14316
47 changed files with 1130 additions and 826 deletions

View file

@ -16,11 +16,12 @@ package code.name.monkey.retromusic.rest;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.File;
import java.util.concurrent.TimeUnit;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import code.name.monkey.retromusic.rest.service.LastFMService;
import okhttp3.Cache;
import okhttp3.Call;
@ -43,7 +44,7 @@ public class LastFMRestClient {
this(createDefaultOkHttpClientBuilder(context).build());
}
public LastFMRestClient(@NonNull Call.Factory client) {
private LastFMRestClient(@NonNull Call.Factory client) {
Retrofit restAdapter = new Retrofit.Builder()
.baseUrl(BASE_URL)
.callFactory(client)
@ -72,7 +73,8 @@ public class LastFMRestClient {
};
}
public static OkHttpClient.Builder createDefaultOkHttpClientBuilder(Context context) {
@NonNull
private static OkHttpClient.Builder createDefaultOkHttpClientBuilder(@NonNull Context context) {
return new OkHttpClient.Builder()
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
.retryOnConnectionFailure(true)
@ -83,6 +85,7 @@ public class LastFMRestClient {
.addInterceptor(createCacheControlInterceptor());
}
@NonNull
public LastFMService getApiService() {
return apiService;
}

View file

@ -16,9 +16,9 @@ package code.name.monkey.retromusic.rest.service;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import code.name.monkey.retromusic.rest.model.LastFmAlbum;
import code.name.monkey.retromusic.rest.model.LastFmArtist;
import code.name.monkey.retromusic.rest.model.LastFmTrack;
import io.reactivex.Observable;
import retrofit2.Call;
import retrofit2.http.GET;
@ -37,12 +37,11 @@ public interface LastFMService {
Observable<LastFmAlbum> getAlbumInfo(@Query("album") @NonNull String albumName, @Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language);
@NonNull
@GET("?api_key=" + API_KEY + "&format=json&autocorrect=1" + "&method=" + METHOD_TRACK)
Observable<LastFmTrack> getTrackInfo(@Query("artist") @NonNull String artist, @Query("track") @NonNull String track);
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
Call<LastFmArtist> getArtistInfo(@Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language, @Nullable @Header("Cache-Control") String cacheControl);
@NonNull
@GET(BASE_QUERY_PARAMETERS + "&method=artist.getinfo")
default Call<LastFmArtist> getArtistInfo(@Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language, @Nullable @Header("Cache-Control") String cacheControl) {
return null;
}
Observable<LastFmArtist> getArtistInfoFloable(@Query("artist") @NonNull String artistName, @Nullable @Query("lang") String language, @Nullable @Header("Cache-Control") String cacheControl);
}