what-the-bank/sources/o/XxC.java

769 lines
26 KiB
Java

package o;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.TextView;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.Projection;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.maps.android.ui.SquareTextView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import o.C8949daW;
import o.YPs;
import o.pEI;
import org.bouncycastle.asn1.x509.DisplayText;
/* loaded from: classes2.dex */
public class XxC<T extends YPs> implements AHS<T> {
static final int[] e = {10, 20, 50, 100, DisplayText.DISPLAY_TEXT_MAXIMUM_SIZE, 500, 1000};
private static final TimeInterpolator f = new DecelerateInterpolator();
private static final boolean i = true;
ShapeDrawable b;
final bNC d;
private final C8949daW<T> g;
private C8949daW.HBt<T> h;
private C8949daW.LWm<T> k;
private C8949daW.IeS<T> l;
private Set<? extends InterfaceC5208boh<T>> n;
/* renamed from: o, reason: collision with root package name */
private final float f8456o;
private C8949daW.Sts<T> q;
private final GoogleMap r;
private IeS<T> t;
private final XxC<T>.jbe u;
private float x;
private Set<RVV> s = Collections.newSetFromMap(new ConcurrentHashMap());
SparseArray<BitmapDescriptor> c = new SparseArray<>();
int a = 4;
private Map<Marker, InterfaceC5208boh<T>> p = new HashMap();
private Map<InterfaceC5208boh<T>, Marker> m = new HashMap();
private boolean j = true;
public void e(T t, MarkerOptions markerOptions) {
}
public XxC(Context context, GoogleMap googleMap, C8949daW<T> c8949daW) {
byte b = 0;
this.t = new IeS<>(b);
this.u = new jbe(this, b);
this.r = googleMap;
float f2 = context.getResources().getDisplayMetrics().density;
this.f8456o = f2;
bNC bnc = new bNC(context);
this.d = bnc;
SquareTextView squareTextView = new SquareTextView(context);
squareTextView.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
squareTextView.setId(pEI.RVV.amu_text);
int i2 = (int) (12.0f * f2);
squareTextView.setPadding(i2, i2, i2, i2);
bnc.c.removeAllViews();
bnc.c.addView(squareTextView);
bnc.a = squareTextView;
View findViewById = bnc.c.findViewById(pEI.RVV.amu_text);
bnc.h = findViewById instanceof TextView ? (TextView) findViewById : null;
int i3 = pEI.Sts.amu_ClusterIcon_TextAppearance;
Context context2 = bnc.d;
TextView textView = bnc.h;
if (textView != null) {
textView.setTextAppearance(context2, i3);
}
this.b = new ShapeDrawable(new OvalShape());
ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
shapeDrawable.getPaint().setColor(-2130706433);
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{shapeDrawable, this.b});
int i4 = (int) (f2 * 3.0f);
layerDrawable.setLayerInset(1, i4, i4, i4, i4);
bnc.NJ_(layerDrawable);
this.g = c8949daW;
}
/* loaded from: classes2.dex */
class jbe extends Handler {
private boolean a;
XxC<T>.tOB b;
final XxC d;
private jbe(XxC xxC) {
this.d = xxC;
this.a = false;
this.b = null;
}
/* synthetic */ jbe(XxC xxC, byte b) {
this(xxC);
}
@Override // android.os.Handler
public final void handleMessage(Message message) {
XxC<T>.tOB tob;
if (message.what == 1) {
this.a = false;
if (this.b != null) {
sendEmptyMessage(0);
return;
}
return;
}
removeMessages(0);
if (this.a || this.b == null) {
return;
}
Projection projection = this.d.r.getProjection();
synchronized (this) {
tob = this.b;
this.b = null;
this.a = true;
}
tob.d = new Runnable(this) { // from class: o.XxC.jbe.4
private jbe d;
{
this.d = this;
}
@Override // java.lang.Runnable
public final void run() {
this.d.sendEmptyMessage(1);
}
};
tob.a = projection;
tob.e = this.d.r.getCameraPosition().zoom;
tob.b = new yZd(Math.pow(2.0d, Math.min(r7, tob.c.x)) * 256.0d);
new Thread(tob).start();
}
}
/* loaded from: classes2.dex */
class tOB implements Runnable {
Projection a;
yZd b;
final XxC c;
Runnable d;
float e;
private Set<? extends InterfaceC5208boh<T>> j;
/* synthetic */ tOB(XxC xxC, Set set, byte b) {
this(xxC, set);
}
private tOB(XxC xxC, Set<? extends InterfaceC5208boh<T>> set) {
this.c = xxC;
this.j = set;
}
@Override // java.lang.Runnable
public final void run() {
LatLngBounds build;
ArrayList arrayList;
if (this.j.equals(this.c.n)) {
this.d.run();
return;
}
Sts sts = new Sts(this.c, (byte) 0);
float f = this.e;
byte b = f > this.c.x ? (byte) 1 : (byte) 0;
float f2 = this.c.x;
Set<RVV> set = this.c.s;
try {
build = this.a.getVisibleRegion().latLngBounds;
} catch (Exception unused) {
build = LatLngBounds.builder().include(new LatLng(0.0d, 0.0d)).build();
}
ArrayList arrayList2 = null;
if (this.c.n != null && XxC.i && this.c.j) {
arrayList = new ArrayList();
for (InterfaceC5208boh interfaceC5208boh : this.c.n) {
if (interfaceC5208boh.d() > this.c.a && build.contains(interfaceC5208boh.c())) {
arrayList.add(this.b.b(interfaceC5208boh.c()));
}
}
} else {
arrayList = null;
}
Set newSetFromMap = Collections.newSetFromMap(new ConcurrentHashMap());
for (InterfaceC5208boh<T> interfaceC5208boh2 : this.j) {
boolean contains = build.contains(interfaceC5208boh2.c());
if (b != 0 && contains && XxC.i && this.c.j) {
HTs d = XxC.d(this.c, arrayList, this.b.b(interfaceC5208boh2.c()));
if (d != null) {
sts.d(true, (HBt) new HBt(this.c, interfaceC5208boh2, newSetFromMap, this.b.d(d)));
} else {
sts.d(true, (HBt) new HBt(this.c, interfaceC5208boh2, newSetFromMap, null));
}
} else {
sts.d(contains, new HBt(this.c, interfaceC5208boh2, newSetFromMap, null));
}
}
sts.c();
set.removeAll(newSetFromMap);
if (XxC.i && this.c.j) {
arrayList2 = new ArrayList();
for (InterfaceC5208boh<T> interfaceC5208boh3 : this.j) {
if (interfaceC5208boh3.d() > this.c.a && build.contains(interfaceC5208boh3.c())) {
arrayList2.add(this.b.b(interfaceC5208boh3.c()));
}
}
}
for (RVV rvv : set) {
boolean contains2 = build.contains(rvv.d);
if (b == 0 && f - f2 > -3.0f && contains2 && XxC.i && this.c.j) {
HTs d2 = XxC.d(this.c, arrayList2, this.b.b(rvv.d));
if (d2 != null) {
LatLng d3 = this.b.d(d2);
LatLng latLng = rvv.d;
sts.b.lock();
XxC<T>.LWm lWm = new LWm(sts.d, rvv, latLng, d3, (byte) 0);
lWm.d = sts.d.g.c;
lWm.a = true;
sts.a.add(lWm);
sts.b.unlock();
} else {
sts.d(true, rvv.a);
}
} else {
sts.d(contains2, rvv.a);
}
}
sts.c();
this.c.s = newSetFromMap;
this.c.n = this.j;
this.c.x = f;
this.d.run();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class Sts extends Handler implements MessageQueue.IdleHandler {
Queue<XxC<T>.LWm> a;
final Lock b;
private Queue<XxC<T>.HBt> c;
final XxC d;
private final Condition e;
private Queue<Marker> f;
private Queue<Marker> g;
private Queue<XxC<T>.HBt> h;
private boolean i;
/* synthetic */ Sts(XxC xxC, byte b) {
this(xxC);
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
private Sts(XxC xxC) {
super(Looper.getMainLooper());
this.d = xxC;
ReentrantLock reentrantLock = new ReentrantLock();
this.b = reentrantLock;
this.e = reentrantLock.newCondition();
this.c = new LinkedList();
this.h = new LinkedList();
this.f = new LinkedList();
this.g = new LinkedList();
this.a = new LinkedList();
}
public final void d(boolean z, XxC<T>.HBt hBt) {
this.b.lock();
sendEmptyMessage(0);
if (z) {
this.h.add(hBt);
} else {
this.c.add(hBt);
}
this.b.unlock();
}
public final void d(boolean z, Marker marker) {
this.b.lock();
sendEmptyMessage(0);
if (z) {
this.g.add(marker);
} else {
this.f.add(marker);
}
this.b.unlock();
}
public final void c(RVV rvv, LatLng latLng, LatLng latLng2) {
this.b.lock();
this.a.add(new LWm(this.d, rvv, latLng, latLng2, (byte) 0));
this.b.unlock();
}
@Override // android.os.Handler
public final void handleMessage(Message message) {
if (!this.i) {
Looper.myQueue().addIdleHandler(this);
this.i = true;
}
removeMessages(0);
this.b.lock();
for (int i = 0; i < 10; i++) {
try {
if (!this.g.isEmpty()) {
b(this.g.poll());
} else if (!this.a.isEmpty()) {
XxC<T>.LWm poll = this.a.poll();
ValueAnimator ofFloat = ValueAnimator.ofFloat(BitmapDescriptorFactory.HUE_RED, 1.0f);
ofFloat.setInterpolator(XxC.f);
ofFloat.addUpdateListener(poll);
ofFloat.addListener(poll);
ofFloat.start();
} else if (!this.h.isEmpty()) {
HBt.d(this.h.poll(), this);
} else if (!this.c.isEmpty()) {
HBt.d(this.c.poll(), this);
} else if (!this.f.isEmpty()) {
b(this.f.poll());
}
} finally {
this.b.unlock();
}
}
if (!b()) {
this.i = false;
Looper.myQueue().removeIdleHandler(this);
this.e.signalAll();
} else {
sendEmptyMessageDelayed(0, 10L);
}
}
private void b(Marker marker) {
this.d.m.remove((InterfaceC5208boh) this.d.p.get(marker));
this.d.t.b(marker);
this.d.p.remove(marker);
this.d.g.c.d(marker);
}
private boolean b() {
boolean z;
try {
this.b.lock();
if (this.c.isEmpty() && this.h.isEmpty() && this.g.isEmpty() && this.f.isEmpty()) {
if (this.a.isEmpty()) {
z = false;
return z;
}
}
z = true;
return z;
} finally {
this.b.unlock();
}
}
public final void c() {
while (b()) {
sendEmptyMessage(0);
this.b.lock();
try {
try {
if (b()) {
this.e.await();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
} finally {
this.b.unlock();
}
}
}
@Override // android.os.MessageQueue.IdleHandler
public final boolean queueIdle() {
sendEmptyMessage(0);
return true;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class IeS<T> {
Map<Marker, T> c;
Map<T, Marker> d;
private IeS() {
this.d = new HashMap();
this.c = new HashMap();
}
/* synthetic */ IeS(byte b) {
this();
}
public final void b(Marker marker) {
T t = this.c.get(marker);
this.c.remove(marker);
this.d.remove(t);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class HBt {
private XxC a;
private final Set<RVV> c;
private final LatLng d;
private final InterfaceC5208boh<T> e;
static /* synthetic */ void d(HBt hBt, Sts sts) {
RVV rvv;
RVV rvv2;
String obj;
byte b = 0;
if (hBt.e.d() > hBt.a.a) {
Marker marker = (Marker) hBt.a.m.get(hBt.e);
if (marker == null) {
MarkerOptions markerOptions = new MarkerOptions();
LatLng latLng = hBt.d;
if (latLng == null) {
latLng = hBt.e.c();
}
MarkerOptions position = markerOptions.position(latLng);
XxC xxC = hBt.a;
int d = hBt.e.d();
if (d > XxC.e[0]) {
int i = 0;
while (true) {
int[] iArr = XxC.e;
if (i < iArr.length - 1) {
int i2 = i + 1;
if (d < iArr[i2]) {
d = iArr[i];
break;
}
i = i2;
} else {
d = iArr[iArr.length - 1];
break;
}
}
}
BitmapDescriptor bitmapDescriptor = xxC.c.get(d);
if (bitmapDescriptor == null) {
Paint paint = xxC.b.getPaint();
float min = 300.0f - Math.min(d, 300.0f);
paint.setColor(Color.HSVToColor(new float[]{((min * min) / 90000.0f) * 220.0f, 1.0f, 0.6f}));
bNC bnc = xxC.d;
if (d < XxC.e[0]) {
obj = String.valueOf(d);
} else {
StringBuilder sb = new StringBuilder();
sb.append(String.valueOf(d));
sb.append("+");
obj = sb.toString();
}
TextView textView = bnc.h;
if (textView != null) {
textView.setText(obj);
}
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
bnc.b.measure(makeMeasureSpec, makeMeasureSpec);
int measuredWidth = bnc.b.getMeasuredWidth();
int measuredHeight = bnc.b.getMeasuredHeight();
bnc.b.layout(0, 0, measuredWidth, measuredHeight);
int i3 = bnc.e;
Bitmap createBitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888);
createBitmap.eraseColor(0);
Canvas canvas = new Canvas(createBitmap);
int i4 = bnc.e;
bnc.b.draw(canvas);
bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(createBitmap);
xxC.c.put(d, bitmapDescriptor);
}
position.icon(bitmapDescriptor);
Marker b2 = hBt.a.g.d.b(position);
hBt.a.p.put(b2, hBt.e);
hBt.a.m.put(hBt.e, b2);
rvv2 = new RVV(b2, b);
LatLng latLng2 = hBt.d;
if (latLng2 != null) {
sts.c(rvv2, latLng2, hBt.e.c());
}
} else {
rvv2 = new RVV(marker, b);
}
XxC xxC2 = hBt.a;
InterfaceC5208boh<T> interfaceC5208boh = hBt.e;
hBt.c.add(rvv2);
return;
}
for (T t : hBt.e.a()) {
Marker marker2 = hBt.a.t.d.get(t);
if (marker2 == null) {
MarkerOptions markerOptions2 = new MarkerOptions();
LatLng latLng3 = hBt.d;
if (latLng3 != null) {
markerOptions2.position(latLng3);
} else {
markerOptions2.position(t.c());
}
t.d();
t.e();
markerOptions2.title(t.d());
markerOptions2.snippet(t.e());
hBt.a.e((XxC) t, markerOptions2);
Marker b3 = hBt.a.g.a.b(markerOptions2);
rvv = new RVV(b3, b);
IeS ieS = hBt.a.t;
ieS.d.put(t, b3);
ieS.c.put(b3, t);
LatLng latLng4 = hBt.d;
if (latLng4 != null) {
sts.c(rvv, latLng4, t.c());
}
} else {
rvv = new RVV(marker2, b);
}
XxC xxC3 = hBt.a;
hBt.c.add(rvv);
}
}
public HBt(XxC xxC, InterfaceC5208boh<T> interfaceC5208boh, Set<RVV> set, LatLng latLng) {
this.a = xxC;
this.e = interfaceC5208boh;
this.c = set;
this.d = latLng;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class RVV {
final Marker a;
LatLng d;
/* synthetic */ RVV(Marker marker, byte b) {
this(marker);
}
private RVV(Marker marker) {
this.a = marker;
this.d = marker.getPosition();
}
public final boolean equals(Object obj) {
if (obj instanceof RVV) {
return this.a.equals(((RVV) obj).a);
}
return false;
}
public final int hashCode() {
return this.a.hashCode();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class LWm extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener {
boolean a;
private final LatLng b;
private final RVV c;
mzN d;
private final Marker e;
private final LatLng i;
private XxC j;
/* synthetic */ LWm(XxC xxC, RVV rvv, LatLng latLng, LatLng latLng2, byte b) {
this(xxC, rvv, latLng, latLng2);
}
private LWm(XxC xxC, RVV rvv, LatLng latLng, LatLng latLng2) {
this.j = xxC;
this.c = rvv;
this.e = rvv.a;
this.b = latLng;
this.i = latLng2;
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public final void onAnimationEnd(Animator animator) {
if (this.a) {
this.j.m.remove((InterfaceC5208boh) this.j.p.get(this.e));
this.j.t.b(this.e);
this.j.p.remove(this.e);
this.d.d(this.e);
}
this.c.d = this.i;
}
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedFraction = valueAnimator.getAnimatedFraction();
double d = this.i.latitude;
double d2 = this.b.latitude;
double d3 = animatedFraction;
double d4 = this.b.latitude;
double d5 = this.i.longitude - this.b.longitude;
if (Math.abs(d5) > 180.0d) {
d5 -= Math.signum(d5) * 360.0d;
}
this.e.setPosition(new LatLng(((d - d2) * d3) + d4, (d5 * d3) + this.b.longitude));
}
}
static /* synthetic */ HTs d(XxC xxC, List list, HTs hTs) {
HTs hTs2 = null;
if (list != null && !list.isEmpty()) {
int c = xxC.g.e.c();
double d = c * c;
Iterator it = list.iterator();
while (it.hasNext()) {
HTs hTs3 = (HTs) it.next();
double d2 = ((hTs3.d - hTs.d) * (hTs3.d - hTs.d)) + ((hTs3.e - hTs.e) * (hTs3.e - hTs.e));
if (d2 < d) {
hTs2 = hTs3;
d = d2;
}
}
}
return hTs2;
}
@Override // o.AHS
public final void c() {
this.g.a.b = new GoogleMap.OnMarkerClickListener(this) { // from class: o.XxC.3
private XxC b;
{
this.b = this;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
public final boolean onMarkerClick(Marker marker) {
if (this.b.k == null) {
return false;
}
this.b.k.a((YPs) this.b.t.c.get(marker));
return false;
}
};
this.g.a.e = new GoogleMap.OnInfoWindowClickListener(this) { // from class: o.XxC.2
private XxC e;
{
this.e = this;
}
@Override // com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener
public final void onInfoWindowClick(Marker marker) {
if (this.e.q != null) {
C8949daW.Sts unused = this.e.q;
}
}
};
this.g.d.b = new GoogleMap.OnMarkerClickListener(this) { // from class: o.XxC.4
private XxC c;
{
this.c = this;
}
@Override // com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
public final boolean onMarkerClick(Marker marker) {
if (this.c.h != null) {
C8949daW.HBt hBt = this.c.h;
if (hBt.a()) {
return true;
}
}
return false;
}
};
this.g.d.e = new GoogleMap.OnInfoWindowClickListener(this) { // from class: o.XxC.5
private XxC a;
{
this.a = this;
}
@Override // com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener
public final void onInfoWindowClick(Marker marker) {
if (this.a.l != null) {
C8949daW.IeS unused = this.a.l;
}
}
};
}
@Override // o.AHS
public final void e(Set<? extends InterfaceC5208boh<T>> set) {
XxC<T>.jbe jbeVar = this.u;
synchronized (jbeVar) {
jbeVar.b = new tOB(jbeVar.d, set, (byte) 0);
}
jbeVar.sendEmptyMessage(0);
}
@Override // o.AHS
public final void d() {
this.g.a.b = null;
this.g.a.e = null;
this.g.d.b = null;
this.g.d.e = null;
}
@Override // o.AHS
public final void b() {
this.q = null;
}
@Override // o.AHS
public final void a(C8949daW.LWm<T> lWm) {
this.k = lWm;
}
@Override // o.AHS
public final void a() {
this.l = null;
}
@Override // o.AHS
public final void e() {
this.h = null;
}
}