mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
TEST - Added a first form of cache for retrofit
This commit is contained in:
parent
2bf42aaeea
commit
340385aa85
11 changed files with 178 additions and 34 deletions
|
|
@ -1,11 +1,15 @@
|
|||
package com.cappielloantonio.play.subsonic.api.albumsonglist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -14,11 +18,13 @@ import retrofit2.Retrofit;
|
|||
public class AlbumSongListClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private AlbumSongListService albumSongListService;
|
||||
private final AlbumSongListService albumSongListService;
|
||||
|
||||
public AlbumSongListClient(Subsonic subsonic) {
|
||||
public AlbumSongListClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -68,6 +74,9 @@ public class AlbumSongListClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -77,4 +86,9 @@ public class AlbumSongListClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package com.cappielloantonio.play.subsonic.api.browsing;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -14,11 +18,13 @@ import retrofit2.Retrofit;
|
|||
public class BrowsingClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private BrowsingService browsingService;
|
||||
private final BrowsingService browsingService;
|
||||
|
||||
public BrowsingClient(Subsonic subsonic) {
|
||||
public BrowsingClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -118,6 +124,9 @@ public class BrowsingClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -127,4 +136,9 @@ public class BrowsingClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package com.cappielloantonio.play.subsonic.api.mediaannotation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -14,11 +18,13 @@ import retrofit2.Retrofit;
|
|||
public class MediaAnnotationClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private MediaAnnotationService mediaAnnotationService;
|
||||
private final MediaAnnotationService mediaAnnotationService;
|
||||
|
||||
public MediaAnnotationClient(Subsonic subsonic) {
|
||||
public MediaAnnotationClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -53,6 +59,9 @@ public class MediaAnnotationClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -62,4 +71,9 @@ public class MediaAnnotationClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package com.cappielloantonio.play.subsonic.api.medialibraryscanning;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.api.system.SystemService;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -15,11 +19,13 @@ import retrofit2.Retrofit;
|
|||
public class MediaLibraryScanningClient {
|
||||
private static final String TAG = "SystemClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private MediaLibraryScanningService mediaLibraryScanningService;
|
||||
private final MediaLibraryScanningService mediaLibraryScanningService;
|
||||
|
||||
public MediaLibraryScanningClient(Subsonic subsonic) {
|
||||
public MediaLibraryScanningClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -44,6 +50,9 @@ public class MediaLibraryScanningClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -53,4 +62,9 @@ public class MediaLibraryScanningClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package com.cappielloantonio.play.subsonic.api.mediaretrieval;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -14,11 +18,13 @@ import retrofit2.Retrofit;
|
|||
public class MediaRetrievalClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private MediaRetrievalService mediaRetrievalService;
|
||||
private final MediaRetrievalService mediaRetrievalService;
|
||||
|
||||
public MediaRetrievalClient(Subsonic subsonic) {
|
||||
public MediaRetrievalClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -43,6 +49,9 @@ public class MediaRetrievalClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -52,4 +61,9 @@ public class MediaRetrievalClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
package com.cappielloantonio.play.subsonic.api.playlist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -16,11 +20,13 @@ import retrofit2.Retrofit;
|
|||
public class PlaylistClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private PlaylistService playlistService;
|
||||
private final PlaylistService playlistService;
|
||||
|
||||
public PlaylistClient(Subsonic subsonic) {
|
||||
public PlaylistClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -60,6 +66,9 @@ public class PlaylistClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -69,4 +78,9 @@ public class PlaylistClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package com.cappielloantonio.play.subsonic.api.searching;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -14,11 +18,13 @@ import retrofit2.Retrofit;
|
|||
public class SearchingClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private SearchingService searchingService;
|
||||
private final SearchingService searchingService;
|
||||
|
||||
public SearchingClient(Subsonic subsonic) {
|
||||
public SearchingClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -43,6 +49,9 @@ public class SearchingClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -52,4 +61,9 @@ public class SearchingClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
package com.cappielloantonio.play.subsonic.api.system;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.tickaroo.tikxml.retrofit.TikXmlConverterFactory;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Call;
|
||||
|
|
@ -14,11 +18,13 @@ import retrofit2.Retrofit;
|
|||
public class SystemClient {
|
||||
private static final String TAG = "SystemClient";
|
||||
|
||||
private Subsonic subsonic;
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private Retrofit retrofit;
|
||||
private SystemService systemService;
|
||||
private final SystemService systemService;
|
||||
|
||||
public SystemClient(Subsonic subsonic) {
|
||||
public SystemClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
this.subsonic = subsonic;
|
||||
|
||||
this.retrofit = new Retrofit.Builder()
|
||||
|
|
@ -43,6 +49,9 @@ public class SystemClient {
|
|||
private OkHttpClient getOkHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(getHttpLoggingInterceptor())
|
||||
.addInterceptor(CacheUtil.offlineInterceptor)
|
||||
.addNetworkInterceptor(CacheUtil.onlineInterceptor)
|
||||
.cache(getCache())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -52,4 +61,9 @@ public class SystemClient {
|
|||
|
||||
return loggingInterceptor;
|
||||
}
|
||||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue