package com.applovin.exoplayer2.ui; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.accessibility.CaptioningManager; import android.widget.FrameLayout; import androidx.annotation.Nullable; import com.applovin.impl.b5; import com.applovin.impl.qh; import com.applovin.impl.x2; import com.applovin.impl.xp; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* loaded from: classes.dex */ public final class SubtitleView extends FrameLayout implements qh.e { private List a; private x2 b; private int c; private float d; private float f; private boolean g; private boolean h; private int i; private a j; private View k; public interface a { void a(List list, x2 x2Var, float f, int i, float f2); } public SubtitleView(Context context) { this(context, null); } private float getUserCaptionFontScale() { CaptioningManager captioningManager; if (xp.a < 19 || isInEditMode() || (captioningManager = (CaptioningManager) getContext().getSystemService("captioning")) == null || !captioningManager.isEnabled()) { return 1.0f; } return captioningManager.getFontScale(); } private x2 getUserCaptionStyle() { if (xp.a < 19 || isInEditMode()) { return x2.g; } CaptioningManager captioningManager = (CaptioningManager) getContext().getSystemService("captioning"); return (captioningManager == null || !captioningManager.isEnabled()) ? x2.g : x2.a(captioningManager.getUserStyle()); } private void setView(T t) { removeView(this.k); View view = this.k; if (view instanceof j) { ((j) view).a(); } this.k = t; this.j = t; addView(t); } public void c() { setStyle(getUserCaptionStyle()); } public void d() { setFractionalTextSize(getUserCaptionFontScale() * 0.0533f); } public void setCues(@Nullable List list) { if (list == null) { list = Collections.emptyList(); } this.a = list; e(); } public void setFractionalTextSize(float f) { a(f, false); } public SubtitleView(Context context, @Nullable AttributeSet attributeSet) { super(context, attributeSet); this.a = Collections.emptyList(); this.b = x2.g; this.c = 0; this.d = 0.0533f; this.f = 0.08f; this.g = true; this.h = true; com.applovin.exoplayer2.ui.a aVar = new com.applovin.exoplayer2.ui.a(context); this.j = aVar; this.k = aVar; addView(aVar); this.i = 1; } private void e() { this.j.a(getCuesWithStylingPreferencesApplied(), this.b, this.d, this.c, this.f); } public void setApplyEmbeddedFontSizes(boolean z) { this.h = z; e(); } public void setApplyEmbeddedStyles(boolean z) { this.g = z; e(); } public void setBottomPaddingFraction(float f) { this.f = f; e(); } private List getCuesWithStylingPreferencesApplied() { if (this.g && this.h) { return this.a; } ArrayList arrayList = new ArrayList(this.a.size()); for (int i = 0; i < this.a.size(); i++) { arrayList.add(a((b5) this.a.get(i))); } return arrayList; } public void setViewType(int i) { if (this.i == i) { return; } if (i == 1) { setView(new com.applovin.exoplayer2.ui.a(getContext())); } else if (i == 2) { setView(new j(getContext())); } else { throw new IllegalArgumentException(); } this.i = i; } public void setStyle(x2 x2Var) { this.b = x2Var; e(); } private b5 a(b5 b5Var) { b5.b a2 = b5Var.a(); if (!this.g) { h.a(a2); } else if (!this.h) { h.b(a2); } return a2.a(); } @Override // com.applovin.impl.qh.e public void a(List list) { setCues(list); } public void a(float f, boolean z) { a(z ? 1 : 0, f); } private void a(int i, float f) { this.c = i; this.d = f; e(); } }