package com.ifpdos.videopresenter.view.gestureview;

import android.content.Context;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.view.TextureView;
import b.b.a.c;

/* JADX INFO: compiled from: PresenterCameraView.java */
/* JADX INFO: loaded from: classes.dex */
public class a extends TextureView {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private Matrix f2422c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private Matrix f2423d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private int f2424e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private int f2425f;

    /* JADX INFO: renamed from: com.ifpdos.videopresenter.view.gestureview.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: PresenterCameraView.java */
    static /* synthetic */ class C0082a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f2426a;

        static {
            int[] iArr = new int[b.values().length];
            f2426a = iArr;
            try {
                iArr[b.CENTER_CROP.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f2426a[b.CENTER_INSIDE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

    /* JADX INFO: compiled from: PresenterCameraView.java */
    public enum b {
        CENTER_CROP,
        CENTER_INSIDE
    }

    public a(Context context) {
        super(context);
    }

    private void a() {
        if (this.f2423d == null) {
            return;
        }
        setTransform(this.f2422c);
        invalidate();
    }

    private boolean b(b bVar) {
        if (c.g().f() != null && c.g().f().f1184d != null && c.g().f().f1185e != null && c.g().f().f1185e.f1168a != null) {
            this.f2422c = new Matrix();
            this.f2423d = new Matrix();
            RectF rectF = new RectF(0.0f, 0.0f, this.f2424e, this.f2425f);
            try {
                RectF rectF2 = new RectF(0.0f, 0.0f, c.g().f().f1185e.f1168a.f1174a, c.g().f().f1185e.f1168a.f1175b);
                float fWidth = rectF.width() / rectF.height();
                float fWidth2 = rectF2.width() / rectF2.height();
                int i = C0082a.f2426a[bVar.ordinal()];
                if (i != 1) {
                    if (i == 2) {
                        if (fWidth > fWidth2) {
                            this.f2422c.postScale(fWidth2 / fWidth, 1.0f, this.f2424e / 2.0f, this.f2425f / 2.0f);
                            this.f2423d.postScale(fWidth / fWidth2, 1.0f, this.f2424e / 2.0f, this.f2425f / 2.0f);
                        } else {
                            this.f2422c.postScale(1.0f, fWidth / fWidth2, this.f2424e / 2.0f, this.f2425f / 2.0f);
                            this.f2423d.postScale(1.0f, fWidth2 / fWidth, this.f2424e / 2.0f, this.f2425f / 2.0f);
                        }
                    }
                } else if (fWidth > fWidth2) {
                    this.f2422c.postScale(1.0f, fWidth / fWidth2, this.f2424e / 2.0f, this.f2425f / 2.0f);
                    this.f2423d.postScale(1.0f, fWidth2 / fWidth, this.f2424e / 2.0f, this.f2425f / 2.0f);
                } else {
                    this.f2422c.postScale(fWidth2 / fWidth, 1.0f, this.f2424e / 2.0f, this.f2425f / 2.0f);
                    this.f2423d.postScale(fWidth / fWidth2, 1.0f, this.f2424e / 2.0f, this.f2425f / 2.0f);
                }
                if (b.c.d.d.b.g()) {
                    this.f2422c.postScale(-1.0f, 1.0f, this.f2424e / 2.0f, this.f2425f / 2.0f);
                } else {
                    this.f2422c.postScale(1.0f, 1.0f, this.f2424e / 2.0f, this.f2425f / 2.0f);
                }
                return true;
            } catch (NullPointerException e2) {
                b.c.d.d.c.d("PresenterCameraView", e2);
            }
        }
        return false;
    }

    public void c(b bVar) {
        try {
            if (b(bVar)) {
                a();
            }
        } catch (NullPointerException e2) {
            b.c.d.d.c.b("PresenterCameraView", e2.getMessage());
        }
    }

    public void d(int i, int i2) {
        this.f2424e = i;
        this.f2425f = i2;
    }
}
