Update a bunch of libraries.

- The project had been stale for a couple of months, so a lot of libraries were outdated. I updated most of the outdated libraries and verified everything kept working correctly.
- Simplified the ServiceGenerator, removing some stuff that is not used.
This commit is contained in:
Severiano Jaramillo 2019-08-22 11:02:09 -05:00
parent 1e75e369dc
commit 2b4b520c5d
2 changed files with 23 additions and 55 deletions

View file

@ -59,7 +59,7 @@ android {
dependencies {
def lifecycle_version = "2.0.0"
def room_version = "2.1.0-alpha07"
def room_version = "2.1.0"
def rx_bindings_version = "3.0.0-alpha2"
implementation fileTree(dir: 'libs', include: ['*.jar'])
@ -67,16 +67,16 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// AndroidX
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
// Google
implementation 'com.google.zxing:core:3.3.1'
implementation 'com.google.zxing:core:3.3.3'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5'
// AAC Lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
// AAC Room
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
@ -87,21 +87,20 @@ dependencies {
// Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_coroutine"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version_coroutine"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0-alpha04"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha03"
// RxBindings
implementation "com.jakewharton.rxbinding3:rxbinding:$rx_bindings_version"
implementation "com.jakewharton.rxbinding3:rxbinding-material:$rx_bindings_version" // Material Components widgets
implementation "com.jakewharton.rxbinding3:rxbinding-appcompat:$rx_bindings_version" // AndroidX appcompat widgets
// Retrofit & OkHttp
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
implementation 'com.google.firebase:firebase-core:17.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
// PDF and CSV generation
implementation 'com.itextpdf:itextpdf:5.5.13'
implementation 'com.opencsv:opencsv:3.7'
@ -117,12 +116,12 @@ dependencies {
// Testing libs
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'com.jraska.livedata:testing-ktx:1.0.0'
}

View file

@ -5,53 +5,34 @@ import com.google.gson.GsonBuilder;
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import cy.agorise.bitsybitshareswallet.models.coingecko.MarketData;
import cy.agorise.bitsybitshareswallet.models.coingecko.MarketDataDeserializer;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
public class ServiceGenerator{
public static String API_BASE_URL;
private static HttpLoggingInterceptor logging;
private static OkHttpClient.Builder httpClient;
private static Retrofit.Builder builder;
private static HashMap<Class<?>, Object> Services;
private static HashMap<Class<?>, Object> Services = new HashMap<>();
public ServiceGenerator(String apiBaseUrl, Gson gson) {
API_BASE_URL= apiBaseUrl;
logging = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
private ServiceGenerator(String apiBaseUrl, Gson gson) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient = new OkHttpClient.Builder().addInterceptor(logging);
builder = new Retrofit.Builder()
.baseUrl(API_BASE_URL)
.baseUrl(apiBaseUrl)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
Services = new HashMap<Class<?>, Object>();
}
public ServiceGenerator(String apiBaseUrl){
this(apiBaseUrl, new Gson());
}
/**
* Customizes the Gson instance with specific de-serialization logic
*/
private Gson getGson(){
GsonBuilder builder = new GsonBuilder();
return builder.create();
}
public void setCallbackExecutor(Executor executor){
builder.callbackExecutor(executor);
}
public static <T> void setService(Class<T> klass, T thing) {
private static <T> void setService(Class<T> klass, T thing) {
Services.put(klass, thing);
}
@ -65,21 +46,9 @@ public class ServiceGenerator{
return service;
}
public static <S> S createService(Class<S> serviceClass) {
httpClient.interceptors().add(new Interceptor() {
@Override
public okhttp3.Response intercept(Interceptor.Chain chain) throws IOException {
okhttp3.Request original = chain.request();
// Request customization: add request headers
okhttp3.Request.Builder requestBuilder = original.newBuilder().method(original.method(), original.body());
okhttp3.Request request = requestBuilder.build();
return chain.proceed(request);
}
});
httpClient.readTimeout(5, TimeUnit.MINUTES);
httpClient.connectTimeout(5, TimeUnit.MINUTES);
private static <S> S createService(Class<S> serviceClass) {
httpClient.readTimeout(15, TimeUnit.SECONDS);
httpClient.connectTimeout(15, TimeUnit.SECONDS);
OkHttpClient client = httpClient.build();
if(serviceClass == CoingeckoService.class){
// The MarketData class needs a custom de-serializer