184 lines
5.4 KiB
Java
184 lines
5.4 KiB
Java
package o;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.graphics.Typeface;
|
|
import android.os.CancellationSignal;
|
|
import com.prolificinteractive.materialcalendarview.TitleChanger;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.lang.reflect.Field;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import o.Szw;
|
|
import o.ubj;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public class TMM {
|
|
private ConcurrentHashMap<Long, Szw.IeS> a = new ConcurrentHashMap<>();
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public interface HBt<T> {
|
|
boolean b(T t);
|
|
|
|
int e(T t);
|
|
}
|
|
|
|
private static <T> T a(T[] tArr, int i, HBt<T> hBt) {
|
|
return (T) b(tArr, (i & 1) == 0 ? TitleChanger.DEFAULT_ANIMATION_DELAY : 700, (i & 2) != 0, hBt);
|
|
}
|
|
|
|
private static <T> T b(T[] tArr, int i, boolean z, HBt<T> hBt) {
|
|
T t = null;
|
|
int i2 = Integer.MAX_VALUE;
|
|
for (T t2 : tArr) {
|
|
int abs = (Math.abs(hBt.e(t2) - i) << 1) + (hBt.b(t2) == z ? 0 : 1);
|
|
if (t == null || i2 > abs) {
|
|
t = t2;
|
|
i2 = abs;
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
|
|
private static long pi_(Typeface typeface) {
|
|
if (typeface == null) {
|
|
return 0L;
|
|
}
|
|
try {
|
|
Field declaredField = Typeface.class.getDeclaredField("native_instance");
|
|
declaredField.setAccessible(true);
|
|
return ((Number) declaredField.get(typeface)).longValue();
|
|
} catch (IllegalAccessException | NoSuchFieldException unused) {
|
|
return 0L;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public ubj.HBt a(ubj.HBt[] hBtArr, int i) {
|
|
return (ubj.HBt) a(hBtArr, i, new HBt<ubj.HBt>(this) { // from class: o.TMM.5
|
|
final TMM d;
|
|
|
|
{
|
|
this.d = this;
|
|
}
|
|
|
|
@Override // o.TMM.HBt
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public int e(ubj.HBt hBt) {
|
|
return hBt.c();
|
|
}
|
|
|
|
@Override // o.TMM.HBt
|
|
/* renamed from: c, reason: merged with bridge method [inline-methods] */
|
|
public boolean b(ubj.HBt hBt) {
|
|
return hBt.e();
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public Typeface pl_(Context context, InputStream inputStream) {
|
|
File b = ioR.b(context);
|
|
if (b == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
if (ioR.e(b, inputStream)) {
|
|
return Typeface.createFromFile(b.getPath());
|
|
}
|
|
return null;
|
|
} catch (RuntimeException unused) {
|
|
return null;
|
|
} finally {
|
|
b.delete();
|
|
}
|
|
}
|
|
|
|
public Typeface pk_(Context context, CancellationSignal cancellationSignal, ubj.HBt[] hBtArr, int i) {
|
|
InputStream inputStream;
|
|
InputStream inputStream2 = null;
|
|
if (hBtArr.length <= 0) {
|
|
return null;
|
|
}
|
|
try {
|
|
inputStream = context.getContentResolver().openInputStream(a(hBtArr, i).qG_());
|
|
} catch (IOException unused) {
|
|
inputStream = null;
|
|
} catch (Throwable th) {
|
|
th = th;
|
|
}
|
|
try {
|
|
Typeface pl_ = pl_(context, inputStream);
|
|
ioR.a(inputStream);
|
|
return pl_;
|
|
} catch (IOException unused2) {
|
|
ioR.a(inputStream);
|
|
return null;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
inputStream2 = inputStream;
|
|
ioR.a(inputStream2);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
private Szw.LWm a(Szw.IeS ieS, int i) {
|
|
return (Szw.LWm) a(ieS.c(), i, new HBt<Szw.LWm>(this) { // from class: o.TMM.1
|
|
final TMM d;
|
|
|
|
{
|
|
this.d = this;
|
|
}
|
|
|
|
@Override // o.TMM.HBt
|
|
/* renamed from: b, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
|
|
public int e(Szw.LWm lWm) {
|
|
return lWm.c();
|
|
}
|
|
|
|
@Override // o.TMM.HBt
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public boolean b(Szw.LWm lWm) {
|
|
return lWm.i();
|
|
}
|
|
});
|
|
}
|
|
|
|
public Typeface pj_(Context context, Szw.IeS ieS, Resources resources, int i) {
|
|
Szw.LWm a = a(ieS, i);
|
|
if (a == null) {
|
|
return null;
|
|
}
|
|
Typeface oM_ = TaO.oM_(context, resources, a.a(), a.d(), 0, i);
|
|
ph_(oM_, ieS);
|
|
return oM_;
|
|
}
|
|
|
|
public Typeface pm_(Context context, Resources resources, int i, String str, int i2) {
|
|
File b = ioR.b(context);
|
|
if (b == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
if (ioR.pn_(b, resources, i)) {
|
|
return Typeface.createFromFile(b.getPath());
|
|
}
|
|
return null;
|
|
} catch (RuntimeException unused) {
|
|
return null;
|
|
} finally {
|
|
b.delete();
|
|
}
|
|
}
|
|
|
|
private void ph_(Typeface typeface, Szw.IeS ieS) {
|
|
long pi_ = pi_(typeface);
|
|
if (pi_ != 0) {
|
|
this.a.put(Long.valueOf(pi_), ieS);
|
|
}
|
|
}
|
|
}
|