Untitled
unknown
plain_text
9 months ago
14 kB
3
Indexable
Utilities.java
package com.sahibinden.api;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.net.Uri;
import android.view.View;
import androidx.core.content.FileProvider;
import androidx.exifinterface.media.ExifInterface;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.sahibinden.arch.util.ValidationUtilities;
import com.sahibinden.arch.util.device.OsUtilities;
import com.sahibinden.base.ApiApplication;
import com.sahibinden.model.search.recognition.VehicleImageRecognitionInitiateResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.UUID;
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
public class Utilities {
/* renamed from: a reason: collision with root package name */
public static final char[] f61722a = "0123456789ABCDEF".toCharArray();
/* renamed from: b reason: collision with root package name */
public static final TimeZone f61723b = TimeZone.getTimeZone("UTC");
/* renamed from: c reason: collision with root package name */
public static final Long f61724c = 2629800000L;
@SuppressLint({"SimpleDateFormat"})
public static class UtcAdapter implements JsonSerializer<Date>, JsonDeserializer<Date> {
/* renamed from: c */
public Date a(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
String s;
if (jsonElement == null || !jsonElement.w() || (s = jsonElement.s()) == null || s.length() < 1) {
return null;
}
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
simpleDateFormat.setTimeZone(Utilities.f61723b);
return simpleDateFormat.parse(s);
} catch (ParseException e2) {
throw new JsonParseException((Throwable) e2);
}
}
/* renamed from: d */
public JsonElement b(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
if (date == null) {
return null;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
simpleDateFormat.setTimeZone(Utilities.f61723b);
return new JsonPrimitive(simpleDateFormat.format(date));
}
private UtcAdapter() {
}
}
public static String c(byte[] bArr) {
char[] cArr = new char[(bArr.length * 2)];
for (int i2 = 0; i2 < bArr.length; i2++) {
byte b2 = bArr[i2];
int i3 = i2 * 2;
char[] cArr2 = f61722a;
cArr[i3] = cArr2[(b2 & 255) >>> 4];
cArr[i3 + 1] = cArr2[b2 & 15];
}
return new String(cArr);
}
public static int d(BitmapFactory.Options options, int i2, int i3) {
int i4 = options.outHeight;
int i5 = options.outWidth;
int i6 = 1;
if (i4 > i3 || i5 > i2) {
int i7 = i4 / 2;
int i8 = i5 / 2;
while (i7 / i6 > i3 && i8 / i6 > i2) {
i6 *= 2;
}
for (long j2 = (long) ((i5 * i4) / i6); j2 > ((long) (i2 * i3 * 2)); j2 /= 2) {
i6 *= 2;
}
}
return i6;
}
public static Bitmap e(View view) {
view.measure(0, 0);
Bitmap createBitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.draw(canvas);
return createBitmap;
}
public static Gson f() {
GsonBuilder g2 = new GsonBuilder().c().d().g();
g2.f(Date.class, new UtcAdapter());
return g2.b();
}
public static Bitmap g(String str, int i2, int i3) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(str, options);
options.inSampleSize = d(options, i2, i3);
options.inMutable = true;
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(str, options);
}
public static String h(int i2, boolean z) {
int i3 = i2 / 3600;
int i4 = (i2 / 60) % 60;
int i5 = i2 % 60;
if (i3 != 0) {
return String.format(Locale.US, "%d:%02d:%02d", new Object[]{Integer.valueOf(i3), Integer.valueOf(i4), Integer.valueOf(i5)});
} else if (z) {
return String.format(Locale.US, "%02d:%02d", new Object[]{Integer.valueOf(i4), Integer.valueOf(i5)});
} else {
return String.format(Locale.US, "%d:%02d", new Object[]{Integer.valueOf(i4), Integer.valueOf(i5)});
}
}
public static String i(int i2) {
return h(i2, false);
}
public static float j(Context context, Uri uri) {
InputStream inputStream = null;
try {
InputStream openInputStream = context.getContentResolver().openInputStream(uri);
int attributeInt = new ExifInterface(openInputStream).getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
if (openInputStream != null) {
try {
openInputStream.close();
} catch (IOException unused) {
}
}
if (attributeInt == 3) {
return 180.0f;
}
if (attributeInt == 6) {
return 90.0f;
}
if (attributeInt != 8) {
return 0.0f;
}
return 270.0f;
} catch (IOException unused2) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException unused3) {
}
}
return 0.0f;
} catch (Throwable th) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException unused4) {
}
}
throw th;
}
}
public static float k(Context context, String str) {
return j(context, Uri.parse(str));
}
public static Bitmap l(Bitmap bitmap, int i2, int i3) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(((float) i2) / ((float) width), ((float) i3) / ((float) height));
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
}
public static Uri m(Context context, Bitmap bitmap, VehicleImageRecognitionInitiateResponse vehicleImageRecognitionInitiateResponse, File file, boolean z) {
float width;
float f2;
int width2 = bitmap.getWidth();
int height = bitmap.getHeight();
if (vehicleImageRecognitionInitiateResponse == null) {
vehicleImageRecognitionInitiateResponse = new VehicleImageRecognitionInitiateResponse(299, 299, true, 1);
}
if (height > width2) {
width = (float) vehicleImageRecognitionInitiateResponse.getHeight();
f2 = (float) height;
} else {
width = (float) vehicleImageRecognitionInitiateResponse.getWidth();
f2 = (float) width2;
}
float f3 = width / f2;
return x(context, l(bitmap, (int) (((float) width2) * f3), (int) (f3 * ((float) height))), file, z);
}
public static String n(Integer num) {
if (num.intValue() == 1) {
return "vehicleDamageInquiry";
}
return "vehicleDetailInquiry";
}
public static String o(String str) {
if (ValidationUtilities.p(str) || !str.equals("VEHICLE_DAMAGE")) {
return "vehicleDetailInquiry";
}
return "vehicleDamageInquiry";
}
public static String p(Integer num) {
if (num.intValue() == 1) {
return "DAMAGE";
}
return "DETAIL";
}
public static String q(String str) {
if (ValidationUtilities.p(str) || !str.equals("VEHICLE_DAMAGE")) {
return "DETAIL";
}
return "DAMAGE";
}
public static MessageDigest r() {
try {
return MessageDigest.getInstance(McElieceCCA2KeyGenParameterSpec.SHA1);
} catch (NoSuchAlgorithmException unused) {
return null;
}
}
public static String s() {
return UUID.randomUUID().toString();
}
public static Uri t(Context context, File file) {
if (context == null || file == null) {
return null;
}
if (!OsUtilities.c()) {
return Uri.fromFile(file);
}
return FileProvider.getUriForFile(context, ((ApiApplication) context.getApplicationContext()).v().a() + ".fileprovider", file);
}
/* JADX WARNING: Removed duplicated region for block: B:12:0x003b A[ORIG_RETURN, RETURN, SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:13:? A[RETURN, SYNTHETIC] */
/* Code decompiled incorrectly, please refer to instructions dump. */
public static boolean u() {
/*
r0 = 1
r1 = 0
java.util.concurrent.ExecutorService r2 = java.util.concurrent.Executors.newSingleThreadExecutor() // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
T22 r3 = new T22 // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
r3.<init>() // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
java.util.concurrent.Future r2 = r2.submit(r3) // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
r3 = 1000(0x3e8, float:1.401E-42)
long r3 = (long) r3 // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
java.util.concurrent.TimeUnit r5 = java.util.concurrent.TimeUnit.MILLISECONDS // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
java.lang.Object r3 = r2.get(r3, r5) // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
java.net.InetAddress r3 = (java.net.InetAddress) r3 // Catch:{ InterruptedException -> 0x0029, ExecutionException -> 0x0027, TimeoutException -> 0x0024 }
r2.cancel(r0) // Catch:{ InterruptedException -> 0x0022, ExecutionException -> 0x0020, TimeoutException -> 0x001e }
goto L_0x0030
L_0x001e:
r2 = move-exception
goto L_0x002b
L_0x0020:
r2 = move-exception
goto L_0x002b
L_0x0022:
r2 = move-exception
goto L_0x002b
L_0x0024:
r2 = move-exception
L_0x0025:
r3 = r1
goto L_0x002b
L_0x0027:
r2 = move-exception
goto L_0x0025
L_0x0029:
r2 = move-exception
goto L_0x0025
L_0x002b:
java.lang.String r4 = "CHECK_NETWORK_CONNECTION_ERROR"
com.sahibinden.arch.util.network.FirabaseUtil.m(r4, r2, r1)
L_0x0030:
if (r3 == 0) goto L_0x003b
java.lang.String r1 = ""
boolean r1 = r3.equals(r1)
if (r1 != 0) goto L_0x003b
goto L_0x003c
L_0x003b:
r0 = 0
L_0x003c:
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.sahibinden.api.Utilities.u():boolean");
}
public static /* synthetic */ InetAddress v() {
try {
return InetAddress.getByName("google.com");
} catch (UnknownHostException unused) {
return null;
}
}
public static int w(long j2) {
if (j2 >= -2147483648L && j2 <= 2147483647L) {
return (int) j2;
}
throw new IllegalArgumentException(j2 + " cannot be cast to int without changing its value.");
}
public static Uri x(Context context, Bitmap bitmap, File file, boolean z) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 95, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(byteArray);
fileOutputStream.close();
} catch (FileNotFoundException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
if (!z || !OsUtilities.c()) {
return Uri.fromFile(file);
}
return t(context, file);
}
}
Editor is loading...
Leave a Comment