mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Code decontextualization
This commit is contained in:
parent
f16650a74b
commit
a4b31a9c02
108 changed files with 569 additions and 952 deletions
|
|
@ -1,7 +1,5 @@
|
|||
package com.cappielloantonio.play.subsonic;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.api.albumsonglist.AlbumSongListClient;
|
||||
import com.cappielloantonio.play.subsonic.api.browsing.BrowsingClient;
|
||||
import com.cappielloantonio.play.subsonic.api.mediaannotation.MediaAnnotationClient;
|
||||
|
|
@ -19,8 +17,6 @@ import java.util.Map;
|
|||
public class Subsonic {
|
||||
private static final Version API_MAX_VERSION = Version.of("1.15.0");
|
||||
|
||||
private final Context context;
|
||||
|
||||
private final Version apiVersion = API_MAX_VERSION;
|
||||
private final SubsonicPreferences preferences;
|
||||
|
||||
|
|
@ -34,8 +30,7 @@ public class Subsonic {
|
|||
private PodcastClient podcastClient;
|
||||
private MediaLibraryScanningClient mediaLibraryScanningClient;
|
||||
|
||||
public Subsonic(Context context, SubsonicPreferences preferences) {
|
||||
this.context = context;
|
||||
public Subsonic(SubsonicPreferences preferences) {
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
|
|
@ -45,63 +40,63 @@ public class Subsonic {
|
|||
|
||||
public SystemClient getSystemClient() {
|
||||
if (systemClient == null) {
|
||||
systemClient = new SystemClient(context, this);
|
||||
systemClient = new SystemClient(this);
|
||||
}
|
||||
return systemClient;
|
||||
}
|
||||
|
||||
public BrowsingClient getBrowsingClient() {
|
||||
if (browsingClient == null) {
|
||||
browsingClient = new BrowsingClient(context, this);
|
||||
browsingClient = new BrowsingClient(this);
|
||||
}
|
||||
return browsingClient;
|
||||
}
|
||||
|
||||
public MediaRetrievalClient getMediaRetrievalClient() {
|
||||
if (mediaRetrievalClient == null) {
|
||||
mediaRetrievalClient = new MediaRetrievalClient(context, this);
|
||||
mediaRetrievalClient = new MediaRetrievalClient(this);
|
||||
}
|
||||
return mediaRetrievalClient;
|
||||
}
|
||||
|
||||
public PlaylistClient getPlaylistClient() {
|
||||
if (playlistClient == null) {
|
||||
playlistClient = new PlaylistClient(context, this);
|
||||
playlistClient = new PlaylistClient(this);
|
||||
}
|
||||
return playlistClient;
|
||||
}
|
||||
|
||||
public SearchingClient getSearchingClient() {
|
||||
if (searchingClient == null) {
|
||||
searchingClient = new SearchingClient(context, this);
|
||||
searchingClient = new SearchingClient(this);
|
||||
}
|
||||
return searchingClient;
|
||||
}
|
||||
|
||||
public AlbumSongListClient getAlbumSongListClient() {
|
||||
if (albumSongListClient == null) {
|
||||
albumSongListClient = new AlbumSongListClient(context, this);
|
||||
albumSongListClient = new AlbumSongListClient(this);
|
||||
}
|
||||
return albumSongListClient;
|
||||
}
|
||||
|
||||
public MediaAnnotationClient getMediaAnnotationClient() {
|
||||
if (mediaAnnotationClient == null) {
|
||||
mediaAnnotationClient = new MediaAnnotationClient(context, this);
|
||||
mediaAnnotationClient = new MediaAnnotationClient(this);
|
||||
}
|
||||
return mediaAnnotationClient;
|
||||
}
|
||||
|
||||
public PodcastClient getPodcastClient() {
|
||||
if (podcastClient == null) {
|
||||
podcastClient = new PodcastClient(context, this);
|
||||
podcastClient = new PodcastClient(this);
|
||||
}
|
||||
return podcastClient;
|
||||
}
|
||||
|
||||
public MediaLibraryScanningClient getMediaLibraryScanningClient() {
|
||||
if (mediaLibraryScanningClient == null) {
|
||||
mediaLibraryScanningClient = new MediaLibraryScanningClient(context, this);
|
||||
mediaLibraryScanningClient = new MediaLibraryScanningClient(this);
|
||||
}
|
||||
return mediaLibraryScanningClient;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class AlbumSongListClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final AlbumSongListService albumSongListService;
|
||||
|
||||
public AlbumSongListClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public AlbumSongListClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -74,7 +71,7 @@ public class AlbumSongListClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 60, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(60, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -101,6 +98,6 @@ public class AlbumSongListClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return new Cache(context.getCacheDir(), cacheSize);
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class BrowsingClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final BrowsingService browsingService;
|
||||
|
||||
public BrowsingClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public BrowsingClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -124,7 +121,7 @@ public class BrowsingClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 60, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(60, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -147,6 +144,6 @@ public class BrowsingClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class MediaAnnotationClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final MediaAnnotationService mediaAnnotationService;
|
||||
|
||||
public MediaAnnotationClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public MediaAnnotationClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -59,7 +56,7 @@ public class MediaAnnotationClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 0, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(0, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -81,6 +78,6 @@ public class MediaAnnotationClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class MediaLibraryScanningClient {
|
||||
private static final String TAG = "SystemClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final MediaLibraryScanningService mediaLibraryScanningService;
|
||||
|
||||
public MediaLibraryScanningClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public MediaLibraryScanningClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -49,7 +46,7 @@ public class MediaLibraryScanningClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 0, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(0, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -71,6 +68,6 @@ public class MediaLibraryScanningClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class MediaRetrievalClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final MediaRetrievalService mediaRetrievalService;
|
||||
|
||||
public MediaRetrievalClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public MediaRetrievalClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -54,7 +51,7 @@ public class MediaRetrievalClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 0, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(0, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -77,6 +74,6 @@ public class MediaRetrievalClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -22,12 +21,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class PlaylistClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final PlaylistService playlistService;
|
||||
|
||||
public PlaylistClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public PlaylistClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -65,7 +62,7 @@ public class PlaylistClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 0, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(0, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -87,6 +84,6 @@ public class PlaylistClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package com.cappielloantonio.play.subsonic.api.podcast;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.subsonic.Subsonic;
|
||||
import com.cappielloantonio.play.subsonic.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class PodcastClient {
|
||||
private static final String TAG = "SystemClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final PodcastService podcastService;
|
||||
|
||||
public PodcastClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public PodcastClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -54,7 +51,7 @@ public class PodcastClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 60, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(60, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -77,6 +74,6 @@ public class PodcastClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class SearchingClient {
|
||||
private static final String TAG = "BrowsingClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final SearchingService searchingService;
|
||||
|
||||
public SearchingClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public SearchingClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -49,7 +46,7 @@ public class SearchingClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 60, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(60, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -72,6 +69,6 @@ public class SearchingClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
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.base.ApiResponse;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.subsonic.utils.CacheUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
|
@ -21,12 +20,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
public class SystemClient {
|
||||
private static final String TAG = "SystemClient";
|
||||
|
||||
private final Context context;
|
||||
private final Subsonic subsonic;
|
||||
private final SystemService systemService;
|
||||
|
||||
public SystemClient(Context context, Subsonic subsonic) {
|
||||
this.context = context;
|
||||
public SystemClient(Subsonic subsonic) {
|
||||
this.subsonic = subsonic;
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
|
|
@ -49,7 +46,7 @@ public class SystemClient {
|
|||
}
|
||||
|
||||
private OkHttpClient getOkHttpClient() {
|
||||
CacheUtil cacheUtil = new CacheUtil(context, 0, 60 * 60 * 24 * 30);
|
||||
CacheUtil cacheUtil = new CacheUtil(0, 60 * 60 * 24 * 30);
|
||||
|
||||
return new OkHttpClient.Builder()
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
|
|
@ -72,6 +69,6 @@ public class SystemClient {
|
|||
|
||||
private Cache getCache() {
|
||||
int cacheSize = 10 * 1024 * 1024;
|
||||
return context != null ? new Cache(context.getCacheDir(), cacheSize) : null;
|
||||
return new Cache(App.getContext().getCacheDir(), cacheSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ import android.content.Context;
|
|||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class CacheUtil {
|
||||
private final Context context;
|
||||
private int maxAge; // 60 seconds
|
||||
private int maxStale; // 60 * 60 * 24 * 30 = 30 days (60 seconds * 60 minutes * 24 hours * 30 days)
|
||||
|
||||
public CacheUtil(Context context, int maxAge, int maxStale) {
|
||||
this.context = context;
|
||||
public CacheUtil(int maxAge, int maxStale) {
|
||||
this.maxAge = maxAge;
|
||||
this.maxStale = maxStale;
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public class CacheUtil {
|
|||
};
|
||||
|
||||
private boolean isConnected() {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) App.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return (netInfo != null && netInfo.isConnected());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue