124 lines
4.5 KiB
Java
124 lines
4.5 KiB
Java
|
package o;
|
||
|
|
||
|
import com.google.gson.JsonElement;
|
||
|
import com.google.gson.JsonObject;
|
||
|
import com.google.gson.JsonParser;
|
||
|
import com.google.gson.JsonSyntaxException;
|
||
|
import java.io.BufferedOutputStream;
|
||
|
import java.io.BufferedReader;
|
||
|
import java.io.File;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.io.FileReader;
|
||
|
import java.util.concurrent.Callable;
|
||
|
import okhttp3.OkHttpClient;
|
||
|
import okhttp3.Request;
|
||
|
import okhttp3.Response;
|
||
|
import org.json.JSONObject;
|
||
|
|
||
|
/* renamed from: o.gr, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public final class C15458gr {
|
||
|
public static JsonObject a(String str) {
|
||
|
if (gjJ.b((CharSequence) str)) {
|
||
|
return new JsonObject();
|
||
|
}
|
||
|
try {
|
||
|
JsonElement parse = new JsonParser().parse(str);
|
||
|
if (parse == null) {
|
||
|
return new JsonObject();
|
||
|
}
|
||
|
try {
|
||
|
return parse.getAsJsonObject();
|
||
|
} catch (IllegalStateException e) {
|
||
|
StringBuilder sb = new StringBuilder("IllegalStateException: ");
|
||
|
sb.append(e.getLocalizedMessage());
|
||
|
guQ.a(sb.toString(), e);
|
||
|
return new JsonObject();
|
||
|
}
|
||
|
} catch (JsonSyntaxException e2) {
|
||
|
StringBuilder sb2 = new StringBuilder("getJsonObject: ");
|
||
|
sb2.append(e2.getLocalizedMessage());
|
||
|
guQ.a(sb2.toString(), e2);
|
||
|
return new JsonObject();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static AbstractC13163fSk<JSONObject> c(File file, final OkHttpClient okHttpClient, final String str) {
|
||
|
final File file2 = new File(file, str.substring(str.lastIndexOf(47) + 1));
|
||
|
if (!file2.exists()) {
|
||
|
return AbstractC13163fSk.fromCallable(new Callable(str, okHttpClient) { // from class: o.gu
|
||
|
private OkHttpClient c;
|
||
|
private String d;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final Object call() {
|
||
|
return this.c.newCall(new Request.Builder().url(this.d).build()).execute();
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.d = str;
|
||
|
this.c = okHttpClient;
|
||
|
}
|
||
|
}).flatMap(new fSS(file2) { // from class: o.gs
|
||
|
private File d;
|
||
|
|
||
|
@Override // o.fSS
|
||
|
public final Object a(Object obj) {
|
||
|
final File file3 = this.d;
|
||
|
final Response response = (Response) obj;
|
||
|
return AbstractC13163fSk.fromCallable(new Callable(file3, response) { // from class: o.gt
|
||
|
private Response a;
|
||
|
private File e;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final Object call() {
|
||
|
File file4 = this.e;
|
||
|
Response response2 = this.a;
|
||
|
file4.createNewFile();
|
||
|
String string = response2.body().string();
|
||
|
byte[] bytes = string.getBytes();
|
||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file4));
|
||
|
bufferedOutputStream.write(bytes);
|
||
|
bufferedOutputStream.flush();
|
||
|
bufferedOutputStream.close();
|
||
|
return new JSONObject(string);
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.e = file3;
|
||
|
this.a = response;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.d = file2;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
return AbstractC13163fSk.fromCallable(new Callable(file2) { // from class: o.gq
|
||
|
private File e;
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
public final Object call() {
|
||
|
File file3 = this.e;
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
BufferedReader bufferedReader = new BufferedReader(new FileReader(file3));
|
||
|
while (true) {
|
||
|
String readLine = bufferedReader.readLine();
|
||
|
if (readLine != null) {
|
||
|
sb.append(readLine);
|
||
|
} else {
|
||
|
bufferedReader.close();
|
||
|
return new JSONObject(sb.toString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.e = file2;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|