use a singleton for okhttp so it will reduce OkHttpClients count
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package ru.vtosters.lite.di.singleton;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class VtOkHttpClient extends OkHttpClient {
|
||||
private static class LazyHolder {
|
||||
private static final VtOkHttpClient instance = new VtOkHttpClient();
|
||||
}
|
||||
|
||||
public static VtOkHttpClient getInstance() {
|
||||
return LazyHolder.instance;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.net.Request;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
@@ -38,7 +39,7 @@ public class FoafBase {
|
||||
private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"");
|
||||
private static final Pattern FOAF_REGEX_LAST_SEEN = Pattern.compile("<ya:lastLoggedIn dc:date=\"(.*)(((\\+|-)\\d\\d):(\\d\\d))\"");
|
||||
private static final String API_VKNEXT = "https://api.vtosters.app/v1/getBypassedOnlineInfo?json=1&ids=";
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
public static long getLastSeen(long origtime, int id) throws ParseException {
|
||||
var request = new okhttp3.Request.a()
|
||||
|
||||
@@ -29,11 +29,12 @@ import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class JsonInjectors {
|
||||
private static final OkHttpClient mClient = new OkHttpClient();
|
||||
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
|
||||
public static JSONObject profileButton(JSONObject orig) throws JSONException {
|
||||
var id = orig.getInt("id");
|
||||
|
||||
@@ -37,11 +37,12 @@ import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class PhotoViewer {
|
||||
static OkHttpClient client = new OkHttpClient();
|
||||
static OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
public static boolean interceptClick(AttachmentWithMedia attachment, MenuItem item, View view) {
|
||||
if (item.getItemId() == R.id.search_photo) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import okhttp3.FormBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.downloaders.AudioDownloader;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
@@ -35,7 +36,7 @@ public class LastFMScrobbler {
|
||||
private static final String KEY = "5965d63402414776c54c266db0211746";
|
||||
private static final String KEY_SECRET = "d982180eed13275bb948e41cf225f88f";
|
||||
private static final String URL = "https://ws.audioscrobbler.com/2.0/";
|
||||
private static final OkHttpClient CLIENT = new OkHttpClient();
|
||||
private static final OkHttpClient CLIENT = VtOkHttpClient.getInstance();
|
||||
private static final List<String> SCROBBLED_UUIDS = new ArrayList<>();
|
||||
|
||||
public static void grabMusicTrack(MusicTrack musictrack) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import javax.crypto.NoSuchPaddingException;
|
||||
import java8.util.concurrent.CompletableFuture;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.music.converter.ts.FFMpeg;
|
||||
import ru.vtosters.lite.music.converter.ts.TSMerger;
|
||||
import ru.vtosters.lite.music.downloader.ThumbnailDownloader;
|
||||
@@ -25,7 +26,7 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.IOUtils;
|
||||
|
||||
public class M3UDownloader implements ITrackDownloader {
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
public static M3UDownloader getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
|
||||
@@ -26,12 +26,13 @@ import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class CatalogJsonInjector {
|
||||
private static final OkHttpClient mClient = new OkHttpClient();
|
||||
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
|
||||
public static JSONObject music(JSONObject json) throws JSONException {
|
||||
var catalog = json.optJSONObject("catalog");
|
||||
|
||||
@@ -8,9 +8,10 @@ import java.util.Arrays;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class GithubList {
|
||||
private static final OkHttpClient mClient = new OkHttpClient();
|
||||
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
|
||||
public static ArrayList<String> getProxy(String url, String proxyname) throws IOException {
|
||||
Request link = new Request.a()
|
||||
|
||||
@@ -16,10 +16,11 @@ import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class DeepLTranslator extends BaseTranslator {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
private static final Pattern pattern = Pattern.compile("[i]");
|
||||
private static final String REQUEST_BODY_FORMAT = "{\n" +
|
||||
" \"method\": \"LMT_handle_texts\",\n" +
|
||||
|
||||
@@ -10,10 +10,11 @@ import java.net.URLEncoder;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class GoogleTranslator extends BaseTranslator {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
private static final String[] devices = new String[]{
|
||||
"Linux; U; Android 10; Pixel 4",
|
||||
"Linux; U; Android 10; Pixel 4 XL",
|
||||
|
||||
@@ -13,10 +13,11 @@ import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class YandexTranslator extends BaseTranslator {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
private static final String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
private static YandexTranslator instance;
|
||||
|
||||
@@ -22,10 +22,11 @@ import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class ServerDialog {
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
public static Boolean showAlert;
|
||||
private static String title;
|
||||
private static String message;
|
||||
|
||||
@@ -25,10 +25,11 @@ import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class ImageUtils {
|
||||
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
public static Bitmap bmp = null;
|
||||
|
||||
|
||||
@@ -12,12 +12,13 @@ import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class OTAUtils {
|
||||
|
||||
private static final String LATEST_RELEASE_URL = "https://api.github.com/repositories/473685743/releases/latest";
|
||||
private static final String LATEST_RELEASE_COMMIT_URL = "https://api.github.com/repositories/473685743/git/ref/tags/%s";
|
||||
private final OkHttpClient mClient = new OkHttpClient();
|
||||
private final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
private final OTAListener mListener;
|
||||
private JSONObject mReleaseJson;
|
||||
private JSONObject mCommitJson;
|
||||
|
||||
@@ -20,10 +20,11 @@ import java.util.HashMap;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
// Jesus cries
|
||||
public class ProfileHider {
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
public static void injectMap(HashMap<Integer, UserPresenter.a.a> hashMap) {
|
||||
if (VTVerifications.isServiceAccount(getUserId())) {
|
||||
|
||||
@@ -23,13 +23,14 @@ import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
public class VTVerifications {
|
||||
public static final List<Integer> sVerifications = new ArrayList<>();
|
||||
public static final List<Integer> sPrometheuses = new ArrayList<>();
|
||||
public static final List<Integer> sDevelopers = new ArrayList<>();
|
||||
public static final List<Integer> sServiceAccounts = new ArrayList<>();
|
||||
private static final OkHttpClient sClient = new OkHttpClient();
|
||||
private static final OkHttpClient sClient = VtOkHttpClient.getInstance();
|
||||
|
||||
public static void load(Context context) {
|
||||
var prefs = context.getSharedPreferences("vt_another_data", 0);
|
||||
|
||||
Reference in New Issue
Block a user