discord-jadx/app/src/main/java/c/o/a/r/f.java

142 lines
5.0 KiB
Java

package c.o.a.r;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.Looper;
import android.view.OrientationEventListener;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import c.o.a.j;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.otaliastudios.cameraview.CameraView;
/* compiled from: OrientationHelper */
public class f {
public final Handler a = new Handler(Looper.getMainLooper());
public final Context b;
/* renamed from: c reason: collision with root package name */
public final c f1538c;
@VisibleForTesting
public final OrientationEventListener d;
public int e = -1;
@VisibleForTesting
public final DisplayManager.DisplayListener f;
public int g = -1;
public boolean h;
/* compiled from: OrientationHelper */
public class a extends OrientationEventListener {
public a(Context context, int i) {
super(context, i);
}
/* JADX WARNING: Code restructure failed: missing block: B:3:0x0008, code lost:
if (r6 != -1) goto L_0x002e;
*/
/* JADX WARNING: Removed duplicated region for block: B:22:0x0034 */
/* JADX WARNING: Removed duplicated region for block: B:28:? A[RETURN, SYNTHETIC] */
@Override // android.view.OrientationEventListener
public void onOrientationChanged(int i) {
int i2;
f fVar;
if (i == -1) {
i2 = f.this.e;
} else if (i < 315 && i >= 45) {
if (i >= 45 && i < 135) {
i2 = 90;
fVar = f.this;
if (i2 == fVar.e) {
}
} else if (i >= 135 && i < 225) {
i2 = BaseTransientBottomBar.ANIMATION_FADE_DURATION;
fVar = f.this;
if (i2 == fVar.e) {
}
} else if (i >= 225 && i < 315) {
i2 = 270;
fVar = f.this;
if (i2 == fVar.e) {
fVar.e = i2;
CameraView.b bVar = (CameraView.b) fVar.f1538c;
bVar.b.a(1, "onDeviceOrientationChanged", Integer.valueOf(i2));
CameraView cameraView = CameraView.this;
int i3 = cameraView.w.g;
if (!cameraView.l) {
int i4 = (360 - i3) % 360;
c.o.a.n.t.a e = cameraView.f2506x.e();
e.e(i4);
e.e = i4;
e.d();
} else {
c.o.a.n.t.a e2 = cameraView.f2506x.e();
e2.e(i2);
e2.e = i2;
e2.d();
}
CameraView.this.f2505s.post(new j(bVar, (i2 + i3) % 360));
return;
}
return;
}
}
i2 = 0;
fVar = f.this;
if (i2 == fVar.e) {
}
}
}
/* compiled from: OrientationHelper */
public class b implements DisplayManager.DisplayListener {
public b() {
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public void onDisplayAdded(int i) {
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public void onDisplayChanged(int i) {
f fVar = f.this;
int i2 = fVar.g;
int a = fVar.a();
if (a != i2) {
f.this.g = a;
boolean z2 = Math.abs(a - i2) != 180;
CameraView.b bVar = (CameraView.b) f.this.f1538c;
bVar.b.a(1, "onDisplayOffsetChanged", Integer.valueOf(a), "recreate:", Boolean.valueOf(z2));
if (CameraView.this.d() && !z2) {
bVar.b.a(2, "onDisplayOffsetChanged", "restarting the camera.");
CameraView.this.close();
CameraView.this.open();
}
}
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public void onDisplayRemoved(int i) {
}
}
/* compiled from: OrientationHelper */
public interface c {
}
public f(@NonNull Context context, @NonNull c cVar) {
this.b = context;
this.f1538c = cVar;
this.d = new a(context.getApplicationContext(), 3);
this.f = new b();
}
public final int a() {
int rotation = ((WindowManager) this.b.getSystemService("window")).getDefaultDisplay().getRotation();
if (rotation != 1) {
return rotation != 2 ? rotation != 3 ? 0 : 270 : BaseTransientBottomBar.ANIMATION_FADE_DURATION;
}
return 90;
}
}