Use a single instance of OkHttp to fetch feeds icons (it's WAY faster)

This commit is contained in:
Shinokuni 2020-01-17 21:38:46 +01:00
parent 5a9ba348f7
commit 9a3f3017c4
1 changed files with 3 additions and 4 deletions

View File

@ -14,12 +14,12 @@ import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.readrops.readropslibrary.utils.HttpManager;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import java.io.InputStream; import java.io.InputStream;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
@ -35,9 +35,7 @@ public final class Utils {
public static Bitmap getImageFromUrl(String url) { public static Bitmap getImageFromUrl(String url) {
try { try {
OkHttpClient okHttpClient = new OkHttpClient.Builder() OkHttpClient okHttpClient = HttpManager.getInstance().getOkHttpClient();
.callTimeout(5, TimeUnit.SECONDS)
.build();
Request request = new Request.Builder().url(url).build(); Request request = new Request.Builder().url(url).build();
Response response = okHttpClient.newCall(request).execute(); Response response = okHttpClient.newCall(request).execute();
@ -100,6 +98,7 @@ public final class Utils {
/** /**
* Remove html tags and trim the text * Remove html tags and trim the text
*
* @param text string to clean * @param text string to clean
* @return cleaned text * @return cleaned text
*/ */