package com.facetec.sdk; import android.content.Context; import android.content.res.Resources; import android.graphics.BitmapFactory; import android.graphics.drawable.GradientDrawable; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; import android.view.ViewOutlineProvider; import android.widget.FrameLayout; import android.widget.ImageView; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import java.util.Random; import o.Etv; import o.OSd; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public class cw extends FrameLayout { int[] a; private ImageView b; boolean c; private ImageView d; int e; private Handler f; private Etv[] i; private boolean j; public cw(Context context, AttributeSet attributeSet) { super(context, attributeSet); int i = 0; this.i = new Etv[0]; this.a = new int[0]; this.e = 0; this.c = true; if (db.aO().length == 0) { return; } this.f = new Handler(Looper.getMainLooper()); this.d = new ImageView(context); this.b = new ImageView(context); this.d.setAlpha(1.0f); this.b.setAlpha(BitmapDescriptorFactory.HUE_RED); this.d.setScaleType(ImageView.ScaleType.CENTER_CROP); this.d.setAdjustViewBounds(true); this.b.setScaleType(ImageView.ScaleType.CENTER_CROP); this.b.setAdjustViewBounds(true); this.j = true; addView(this.d); addView(this.b); GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setCornerRadius(av.b((int) (db.A() * db.d()))); gradientDrawable.setStroke((int) av.b(Math.max(db.l() == 0 ? 0 : 1, (int) (db.l() * db.d()))), db.q(context)); gradientDrawable.setColor(0); setBackground(gradientDrawable); setClipToOutline(true); setOutlineProvider(ViewOutlineProvider.BACKGROUND); if (FaceTecSDK.c.f.enableRetryScreenSlideshowShuffle) { int[] aO = db.aO(); Random random = new Random(); for (int i2 = 0; i2 < aO.length; i2++) { int nextInt = random.nextInt(aO.length); int i3 = aO[nextInt]; aO[nextInt] = aO[i2]; aO[i2] = i3; } this.a = aO; } else { this.a = db.aO(); } Resources resources = getResources(); this.i = new Etv[this.a.length]; while (true) { int[] iArr = this.a; if (i < iArr.length) { this.i[i] = OSd.ql_(resources, BitmapFactory.decodeResource(resources, iArr[i])); i++; } else { this.d.setImageDrawable(this.i[this.e]); return; } } } /* JADX INFO: Access modifiers changed from: package-private */ public final void e() { Handler handler = this.f; if (handler != null) { handler.removeCallbacksAndMessages(null); this.f = null; } } private int c() { int i = this.e; if (i == this.i.length - 1) { return 0; } return i + 1; } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: b, reason: merged with bridge method [inline-methods] */ public final void h() { int c = c(); this.e = c; Etv etv = this.i[c]; if (this.j) { this.b.setImageDrawable(etv); } else { this.d.setImageDrawable(etv); } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: d, reason: merged with bridge method [inline-methods] */ public final void a() { Handler handler; if (!this.c) { if (this.j) { this.b.animate().alpha(1.0f).setDuration(800L).setListener(null).start(); this.d.animate().alpha(BitmapDescriptorFactory.HUE_RED).setDuration(800L).setListener(null).start(); } else { this.b.animate().alpha(BitmapDescriptorFactory.HUE_RED).setDuration(800L).setListener(null).start(); this.d.animate().alpha(1.0f).setDuration(800L).setListener(null).start(); } this.j = !this.j; Handler handler2 = this.f; if (handler2 != null) { handler2.postDelayed(new Runnable(this) { // from class: com.facetec.sdk.cw$$ExternalSyntheticLambda0 public final cw f$0; @Override // java.lang.Runnable public final void run() { this.f$0.h(); } { this.f$0 = this; } }, 800L); } } int i = FaceTecSDK.c.f.retryScreenSlideshowInterval; if (this.c) { i /= 2; this.c = false; } int max = Math.max(500, i); if (this.a.length <= 1 || (handler = this.f) == null) { return; } handler.postDelayed(new Runnable(this) { // from class: com.facetec.sdk.cw$$ExternalSyntheticLambda1 public final cw f$0; @Override // java.lang.Runnable public final void run() { this.f$0.a(); } { this.f$0 = this; } }, max); } }