package com.skydoves.balloon.overlay; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import java.util.Iterator; import java.util.List; import kotlin.NoWhenBranchMatchedException; import o.C13396fZU; import o.C14929gcJ; import o.C14957gcv; import o.InterfaceC14984gdp; import o.fMP; import o.fMR; import o.fMS; import o.fMV; import o.fMW; import o.fMX; import o.fMY; import o.fMZ; import o.gcB; /* loaded from: classes5.dex */ public final class BalloonAnchorOverlayView extends View { private static InterfaceC14984gdp[] a = {C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "anchorView", "getAnchorView()Landroid/view/View;")), C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "anchorViewList", "getAnchorViewList()Ljava/util/List;")), C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "overlayColor", "getOverlayColor()I")), C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "overlayPaddingColor", "getOverlayPaddingColor()I")), C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "overlayPadding", "getOverlayPadding()F")), C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "overlayPosition", "getOverlayPosition()Landroid/graphics/Point;")), C14929gcJ.c(new gcB(BalloonAnchorOverlayView.class, "balloonOverlayShape", "getBalloonOverlayShape()Lcom/skydoves/balloon/overlay/BalloonOverlayShape;"))}; private final fMP b; private final fMP c; private Bitmap d; private final fMP e; private final fMP f; private final fMP g; private final fMP h; private boolean i; private final fMP j; private final Paint k; private final Paint l; private /* synthetic */ BalloonAnchorOverlayView(Context context, AttributeSet attributeSet, int i, byte b) { this(context, (i & 2) != 0 ? null : attributeSet, 0); } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public BalloonAnchorOverlayView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); C14957gcv.e(context, ""); BalloonAnchorOverlayView balloonAnchorOverlayView = this; C14957gcv.e(balloonAnchorOverlayView, ""); this.c = new fMP(null, new fMR.Sts(balloonAnchorOverlayView)); C14957gcv.e(balloonAnchorOverlayView, ""); this.e = new fMP(null, new fMR.Sts(balloonAnchorOverlayView)); C14957gcv.e(balloonAnchorOverlayView, ""); this.j = new fMP(0, new fMR.Sts(balloonAnchorOverlayView)); C14957gcv.e(balloonAnchorOverlayView, ""); this.h = new fMP(0, new fMR.Sts(balloonAnchorOverlayView)); Float valueOf = Float.valueOf(BitmapDescriptorFactory.HUE_RED); C14957gcv.e(balloonAnchorOverlayView, ""); this.f = new fMP(valueOf, new fMR.Sts(balloonAnchorOverlayView)); C14957gcv.e(balloonAnchorOverlayView, ""); this.g = new fMP(null, new fMR.Sts(balloonAnchorOverlayView)); fMV fmv = fMV.b; C14957gcv.e(balloonAnchorOverlayView, ""); this.b = new fMP(fmv, new fMR.Sts(balloonAnchorOverlayView)); Paint paint = new Paint(1); this.k = paint; Paint paint2 = new Paint(1); this.l = paint2; paint.setAntiAlias(true); paint.setFilterBitmap(true); paint.setDither(true); paint2.setAntiAlias(true); paint2.setFilterBitmap(true); paint2.setDither(true); } public final void setAnchorView(View view) { this.c.c(a[0], view); } public final void setAnchorViewList(List list) { this.e.c(a[1], list); } public final void setOverlayColor(int i) { this.j.c(a[2], Integer.valueOf(i)); } public final void setOverlayPaddingColor(int i) { this.h.c(a[3], Integer.valueOf(i)); } public final void setOverlayPadding(float f) { this.f.c(a[4], Float.valueOf(f)); } public final void setOverlayPosition(Point point) { this.g.c(a[5], point); } public final void setBalloonOverlayShape(fMW fmw) { C14957gcv.e(fmw, ""); this.b.c(a[6], fmw); } /* JADX WARN: Multi-variable type inference failed */ @Override // android.view.View protected final void dispatchDraw(Canvas canvas) { Bitmap bitmap; if ((this.i || (bitmap = this.d) == null || (bitmap != null && bitmap.isRecycled())) && getWidth() != 0 && getHeight() != 0) { fMP fmp = this.c; C14957gcv.e(a[0], ""); View view = (View) fmp.d; if (view == null || view.getWidth() != 0) { fMP fmp2 = this.c; C14957gcv.e(a[0], ""); View view2 = (View) fmp2.d; if (view2 == null || view2.getHeight() != 0) { Bitmap bitmap2 = this.d; if (bitmap2 != null && !bitmap2.isRecycled()) { bitmap2.recycle(); } Bitmap createBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); this.d = createBitmap; Canvas canvas2 = new Canvas(createBitmap); Paint paint = this.k; paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); fMP fmp3 = this.j; C14957gcv.e(a[2], ""); paint.setColor(((Number) fmp3.d).intValue()); canvas2.drawRect(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, getWidth(), getHeight(), this.k); Paint paint2 = this.k; paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); paint2.setColor(0); Paint paint3 = this.l; fMP fmp4 = this.h; C14957gcv.e(a[3], ""); paint3.setColor(((Number) fmp4.d).intValue()); paint3.setStyle(Paint.Style.STROKE); fMP fmp5 = this.f; C14957gcv.e(a[4], ""); paint3.setStrokeWidth(((Number) fmp5.d).floatValue()); fMP fmp6 = this.e; C14957gcv.e(a[1], ""); List list = (List) fmp6.d; if (list == null || list.isEmpty()) { fMP fmp7 = this.c; C14957gcv.e(a[0], ""); aAZ_((View) fmp7.d, canvas2); } else { fMP fmp8 = this.e; C14957gcv.e(a[1], ""); List list2 = (List) fmp8.d; if (list2 != null) { Iterator it = list2.iterator(); while (it.hasNext()) { aAZ_((View) it.next(), canvas2); } } } this.i = false; } } } Bitmap bitmap3 = this.d; if (bitmap3 == null || bitmap3.isRecycled() || canvas == null) { return; } canvas.drawBitmap(bitmap3, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, (Paint) null); } /* JADX WARN: Multi-variable type inference failed */ private final void aAZ_(View view, Canvas canvas) { RectF rectF; if (view != null) { Rect rect = new Rect(); view.getGlobalVisibleRect(rect); fMP fmp = this.g; C14957gcv.e(a[5], ""); Point point = (Point) fmp.d; if (point != null) { float f = point.x; fMP fmp2 = this.f; C14957gcv.e(a[4], ""); float floatValue = ((Number) fmp2.d).floatValue(); float f2 = point.y; fMP fmp3 = this.f; C14957gcv.e(a[4], ""); float floatValue2 = ((Number) fmp3.d).floatValue(); float d = d(); float width = point.x + view.getWidth(); fMP fmp4 = this.f; C14957gcv.e(a[4], ""); float floatValue3 = ((Number) fmp4.d).floatValue(); float height = point.y + view.getHeight(); fMP fmp5 = this.f; C14957gcv.e(a[4], ""); rectF = new RectF(f - floatValue, (f2 - floatValue2) + d, width + floatValue3, height + ((Number) fmp5.d).floatValue() + d()); } else { float f3 = rect.left; fMP fmp6 = this.f; C14957gcv.e(a[4], ""); float floatValue4 = ((Number) fmp6.d).floatValue(); float f4 = rect.top; fMP fmp7 = this.f; C14957gcv.e(a[4], ""); float floatValue5 = ((Number) fmp7.d).floatValue(); float f5 = rect.right; fMP fmp8 = this.f; C14957gcv.e(a[4], ""); float floatValue6 = ((Number) fmp8.d).floatValue(); float f6 = rect.bottom; fMP fmp9 = this.f; C14957gcv.e(a[4], ""); rectF = new RectF(f3 - floatValue4, f4 - floatValue5, f5 + floatValue6, f6 + ((Number) fmp9.d).floatValue()); } fMP fmp10 = this.f; C14957gcv.e(a[4], ""); float floatValue7 = ((Number) fmp10.d).floatValue() / 2.0f; RectF rectF2 = new RectF(rectF); rectF2.inset(floatValue7, floatValue7); fMP fmp11 = this.b; C14957gcv.e(a[6], ""); fMW fmw = (fMW) fmp11.d; if (fmw instanceof fMZ) { return; } if (fmw instanceof fMX) { canvas.drawRect(rectF, this.k); canvas.drawRect(rectF2, this.l); return; } if (fmw instanceof fMV) { canvas.drawOval(rectF, this.k); canvas.drawOval(rectF2, this.l); return; } if (fmw instanceof fMS) { fMS fms = (fMS) fmw; Float f7 = fms.a; if (f7 != null) { float floatValue8 = f7.floatValue(); canvas.drawCircle(rectF.centerX(), rectF.centerY(), floatValue8, this.k); canvas.drawCircle(rectF2.centerX(), rectF2.centerY(), floatValue8 - floatValue7, this.l); } Integer num = fms.d; return; } if (fmw instanceof fMY) { fMY fmy = (fMY) fmw; C13396fZU c13396fZU = fmy.a; C13396fZU c13396fZU2 = fmy.b; return; } throw new NoWhenBranchMatchedException(); } } private final int d() { Rect rect = new Rect(); Context context = getContext(); if (!(context instanceof Activity)) { return 0; } ((Activity) context).getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); return rect.top; } @Override // android.view.View protected final void onLayout(boolean z, int i, int i2, int i3, int i4) { super.onLayout(z, i, i2, i3, i4); this.i = true; } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public BalloonAnchorOverlayView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 4, (byte) 0); C14957gcv.e(context, ""); } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public BalloonAnchorOverlayView(Context context) { this(context, null, 6, (byte) 0); C14957gcv.e(context, ""); } }