Fix minor formattings, other improvements
This commit is contained in:
@@ -3,7 +3,7 @@ package org.mian.gitnex.clients;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.helpers.MemorizingTrustManager;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -36,7 +36,8 @@ public class IssuesService {
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
try { // try-catch can be problematic here
|
||||
try {
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||
@@ -44,6 +45,7 @@ public class IssuesService {
|
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
//.addInterceptor(logging)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||
.addInterceptor(new Interceptor() {
|
||||
@@ -63,10 +65,14 @@ public class IssuesService {
|
||||
}
|
||||
}).build();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder().baseUrl(instanceURL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create());
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
.baseUrl(instanceURL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
Retrofit retrofit = builder.build();
|
||||
return retrofit.create(serviceClass);
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.e("onFailure", e.toString());
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.squareup.picasso.OkHttp3Downloader;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import org.mian.gitnex.helpers.MemorizingTrustManager;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Objects;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
@@ -41,14 +41,17 @@ public class PicassoService {
|
||||
|
||||
Log.e("PicassoService", Objects.requireNonNull(uri.toString())); // important!!
|
||||
Log.e("PicassoService", exception.toString());
|
||||
|
||||
});
|
||||
|
||||
picasso = builder.build();
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
Log.e("PicassoService", e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Picasso get() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.mian.gitnex.clients;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.helpers.MemorizingTrustManager;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -36,7 +36,8 @@ public class PullRequestsService {
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
try { // try-catch can be problematic here
|
||||
try {
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||
@@ -44,6 +45,7 @@ public class PullRequestsService {
|
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
//.addInterceptor(logging)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||
.hostnameVerifier(memorizingTrustManager.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier()))
|
||||
.addInterceptor(new Interceptor() {
|
||||
@@ -63,7 +65,10 @@ public class PullRequestsService {
|
||||
}
|
||||
}).build();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder().baseUrl(instanceURL).client(okHttpClient).addConverterFactory(GsonConverterFactory.create());
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
.baseUrl(instanceURL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
Retrofit retrofit = builder.build();
|
||||
return retrofit.create(serviceClass);
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.mian.gitnex.clients;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.helpers.MemorizingTrustManager;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import java.io.File;
|
||||
import java.security.SecureRandom;
|
||||
@@ -36,7 +36,8 @@ public class RetrofitClient {
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
try { // try-catch can be problematic here
|
||||
try {
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
|
||||
MemorizingTrustManager memorizingTrustManager = new MemorizingTrustManager(ctx);
|
||||
@@ -59,7 +60,11 @@ public class RetrofitClient {
|
||||
return chain.proceed(request);
|
||||
});
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder().baseUrl(instanceUrl).client(okHttpClient.build()).addConverterFactory(ScalarsConverterFactory.create()).addConverterFactory(GsonConverterFactory.create());
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
.baseUrl(instanceUrl)
|
||||
.client(okHttpClient.build())
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
retrofit = builder.build();
|
||||
|
||||
@@ -67,15 +72,14 @@ public class RetrofitClient {
|
||||
catch(Exception e) {
|
||||
Log.e("onFailure", e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static synchronized RetrofitClient getInstance(String instanceUrl, Context ctx) {
|
||||
|
||||
return new RetrofitClient(instanceUrl, ctx);
|
||||
}
|
||||
|
||||
public ApiInterface getApiInterface() {
|
||||
|
||||
return retrofit.create(ApiInterface.class);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user