QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 CameraViewNew.java 源代码,内容仅作参考
package com.tencent.mtt.external.explorerone.newcamera.camera;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.SensorEvent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Size;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.mtt.R;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.utils.PlatformStatUtils;
import com.tencent.mtt.base.utils.DeviceUtils;
import com.tencent.mtt.base.utils.permission.PermissionRequest;
import com.tencent.mtt.base.utils.permission.PermissionUtils;
import com.tencent.mtt.common.view.QBTabView;
import com.tencent.mtt.external.ar.facade.ICameraImageFetcherCallback;
import com.tencent.mtt.external.explorerone.camera.ar.inhost.utils.CameraImageFetcher;
import com.tencent.mtt.external.explorerone.camera.base.ICameraStateCallback;
import com.tencent.mtt.external.explorerone.camera.utils.CameraViewUtils;
import com.tencent.mtt.external.explorerone.facade.IExploreCameraService;
import com.tencent.mtt.external.explorerone.newcamera.camera.control.CameraCenterManager;
import com.tencent.mtt.external.explorerone.newcamera.camera.data.CameraFrameFrom;
import com.tencent.mtt.external.explorerone.newcamera.camera.export.ICameraDataCallback;
import com.tencent.mtt.external.explorerone.newcamera.camera.proxy.ICameraProxy;
import com.tencent.mtt.external.explorerone.newcamera.camera.proxy.PreviewHandler;
import com.tencent.mtt.external.explorerone.newcamera.camera.utils.FastBlurUtil;
import com.tencent.mtt.external.explorerone.newcamera.framework.facade.ICameraDeviceListener;
import com.tencent.mtt.external.explorerone.newcamera.framework.tab.menu.CameraPopupScrollTab;
import com.tencent.mtt.external.explorerone.newcamera.framework.tab.menu.bottom.QBCameraScrollerView;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.video.internal.facade.IVideoService;
import com.tencent.mtt.view.common.QBImageView;
import com.tencent.mtt.view.layout.QBFrameLayout;
import com.tencent.mtt.view.toast.MttToaster;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;
import qb.a.e;
import qb.a.f;
import qb.frontierbusiness.BuildConfig;
public class CameraViewNew extends QBFrameLayout implements TextureView.SurfaceTextureListener, CameraCenterManager.ICameraDeviceListener, ICameraProxy, QBCameraScrollerView.OnSelectedChangedListener {
private float A;
private float B;
private float C;
private long D;
private int E;
private int F;
private long G;
private long H;
private long I;
private long J;
private Paint K;
private boolean L;
private boolean M;
private Rect N;
private Size O;
private int P;
private Handler Q;
private AnimatorSet R;
private int S;
private Handler T;
private long U;
private byte V;
private int W;
public CameraCenterManager f52254a;
private int aa;
public TextureView f52255b;
public SurfaceTexture f52256c;
public boolean f52257d;
ICameraDeviceListener e;
ICameraDataCallback f;
int g;
int h;
float i;
float j;
int k;
float l;
float m;
public Bitmap n;
int o;
boolean p;
protected CameraPopupScrollTab q;
Camera.Parameters r;
public int s;
protected ICameraProxy.CameraParams t;
private ImageView u;
private AtomicBoolean v;
private int w;
private PreviewHandler x;
private ArrayList<ICameraDeviceListener> y;
private boolean z;
public CameraViewNew(Context context) {
super(context);
this.v = new AtomicBoolean(false);
this.w = 1;
this.f52257d = false;
this.y = new ArrayList<>();
this.e = null;
this.f = null;
this.z = false;
this.E = -1;
this.g = 0;
this.h = 0;
this.i = 1.0f;
this.j = 1.0f;
this.k = 100;
this.l = 1.0f;
this.m = 2.0f;
this.F = 0;
this.G = 0L;
this.n = null;
this.H = 0L;
this.I = 0L;
this.K = new Paint();
this.o = MttResources.c(e.W);
this.p = false;
this.L = false;
this.M = false;
this.N = new Rect();
this.O = new Size(0, 0);
this.P = 0;
this.Q = new Handler(Looper.getMainLooper());
this.S = -1;
this.T = new Handler(BrowserExecutorSupplier.getLooperForRunLongTime(), new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
int i = message.what;
boolean z = true;
if (i != 1) {
if (i != 2) {
}
} else {
if (CameraViewNew.this.f52256c == null) {
throw new IllegalStateException("No SurfaceHolder provided");
}
if (!CameraViewNew.this.f52254a.c()) {
try {
int numberOfCameras = Camera.getNumberOfCameras();
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
int i2 = 0;
while (true) {
if (i2 >= numberOfCameras) {
i2 = 0;
break;
}
Camera.getCameraInfo(i2, cameraInfo);
if (CameraViewNew.this.w == 1) {
if (cameraInfo.facing == 0) {
break;
}
i2++;
} else {
if (cameraInfo.facing == 1) {
break;
}
i2++;
}
}
CameraViewNew.this.f52254a.a(CameraViewNew.this.f52256c, i2, CameraViewNew.this.w);
CameraViewNew.this.y();
} catch (IOException unused) {
CameraViewNew.this.z();
z = false;
if (z) {
}
return false;
} catch (RuntimeException unused2) {
CameraViewNew cameraViewNew = CameraViewNew.this;
cameraViewNew.b(cameraViewNew.f52256c, CameraViewNew.this.w);
z = false;
if (z) {
}
return false;
}
if (z) {
CameraViewNew.this.y();
}
}
}
return false;
}
});
this.s = 0;
this.U = 0L;
this.t = null;
this.V = (byte) 0;
this.W = -1;
this.aa = -1;
c();
b();
w();
b(context);
}
private void A() {
MttToaster.show(MttResources.l(R.string.b2f), 1);
}
private void B() {
this.T.post(new Runnable() {
@Override
public void run() {
if (CameraViewNew.this.f52254a != null) {
CameraViewNew.this.f52254a.g();
try {
CameraViewNew.this.f52254a.d();
} catch (Exception unused) {
}
}
}
});
setVisibility(8);
CameraViewUtils.a(this.f52255b, 8);
this.r = null;
}
private void C() {
a(false);
}
private void D() {
CameraPopupScrollTab cameraPopupScrollTab;
this.h = 0;
if (this.g == 1 && (cameraPopupScrollTab = this.q) != null) {
if (this.B > 0.0f) {
cameraPopupScrollTab.f();
} else {
cameraPopupScrollTab.g();
}
}
if (this.g != 7 || System.currentTimeMillis() - this.D <= 1000) {
this.L = true;
return;
}
if (this.p) {
this.F = 4;
this.L = false;
this.J = 0L;
this.I = AnimationUtils.currentAnimationTimeMillis() - this.J;
this.H = System.currentTimeMillis();
this.G = this.H;
q();
}
invalidate();
this.D = System.currentTimeMillis();
}
private float a(int i, int i2, float f) {
return ((((float) Math.cos((float) ((f * 3.141592653589793d) * 2.0d))) * (i - i2)) / 2.0f) + ((i + i2) / 2);
}
private float a(long j) {
this.J = AnimationUtils.currentAnimationTimeMillis() - this.I;
return (((float) this.J) / ((float) j)) % 1.0f;
}
private ValueAnimator a(int i, int i2, int i3, ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
ValueAnimator ofInt = ValueAnimator.ofInt(i, i2);
ofInt.setDuration(i3);
ofInt.setInterpolator(new AccelerateDecelerateInterpolator());
ofInt.addUpdateListener(animatorUpdateListener);
return ofInt;
}
private void a(Context context) {
if (this.f52255b == null) {
this.f52255b = new TextureView(context);
this.f52255b.setSurfaceTextureListener(this);
}
if (this.u == null) {
this.u = new QBImageView(getContext());
this.u.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
}
public void a(SurfaceTexture surfaceTexture, int i) {
this.f52256c = surfaceTexture;
if (this.f52256c == null) {
throw new IllegalStateException("No SurfaceHolder provided");
}
if (this.f52254a.c()) {
return;
}
boolean z = false;
try {
int numberOfCameras = Camera.getNumberOfCameras();
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
int i2 = 0;
while (true) {
if (i2 >= numberOfCameras) {
i2 = 0;
break;
}
Camera.getCameraInfo(i2, cameraInfo);
if (i == 1) {
if (cameraInfo.facing == 0) {
break;
} else {
i2++;
}
} else if (cameraInfo.facing == 1) {
break;
} else {
i2++;
}
}
this.f52254a.a(this.f52256c, i2, i);
z = true;
} catch (IOException unused) {
z();
} catch (RuntimeException unused2) {
b(this.f52256c, this.w);
}
if (z) {
y();
}
}
private void a(MotionEvent motionEvent) {
int findPointerIndex = motionEvent.findPointerIndex(this.E);
float x = motionEvent.getX(findPointerIndex);
float y = motionEvent.getY(findPointerIndex);
int i = (int) (x - this.A);
int i2 = (int) (y - this.C);
this.B = i;
if (e(i, i2)) {
this.g = 1;
}
if (this.h >= 2) {
float c2 = c(motionEvent);
float f = this.l;
float f2 = 0.0f;
if (c2 > f + 1.0f) {
this.j += (c2 / f) * this.m;
float f3 = this.j;
int i3 = this.k;
if (f3 > i3) {
f3 = i3;
} else if (f3 < 0.0f) {
f3 = 0.0f;
}
this.i = f3;
d((int) this.i);
this.l = c2;
}
float f4 = this.l;
if (c2 < f4 - 1.0f) {
this.j -= (c2 / f4) * this.m;
float f5 = this.j;
int i4 = this.k;
if (f5 > i4) {
f2 = i4;
} else if (f5 >= 0.0f) {
f2 = f5;
}
this.i = f2;
d((int) this.i);
this.l = c2;
}
}
}
private void a(final TextureView textureView, final int i, final int i2) {
AnimatorSet animatorSet = this.R;
if (animatorSet != null) {
animatorSet.cancel();
}
final FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textureView.getLayoutParams();
final FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) this.u.getLayoutParams();
final Bitmap a2 = FastBlurUtil.a(textureView.getBitmap());
layoutParams.width = -1;
layoutParams.height = -1;
layoutParams2.width = -1;
layoutParams2.height = -1;
ValueAnimator a3 = a(layoutParams.topMargin, i, 400, new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
layoutParams.topMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue();
layoutParams2.topMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue();
textureView.setLayoutParams(layoutParams);
CameraViewNew.this.u.setLayoutParams(layoutParams2);
}
});
ValueAnimator a4 = a(layoutParams.bottomMargin, i2, 400, new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
layoutParams.bottomMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue();
layoutParams2.bottomMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue();
textureView.setLayoutParams(layoutParams);
CameraViewNew.this.u.setLayoutParams(layoutParams2);
}
});
this.R = new AnimatorSet();
this.R.setDuration(400L);
this.R.playTogether(a3, a4);
this.R.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
super.onAnimationEnd(animator);
FrameLayout.LayoutParams layoutParams3 = layoutParams;
layoutParams3.topMargin = i;
layoutParams3.bottomMargin = i2;
textureView.setLayoutParams(layoutParams3);
}
@Override
public void onAnimationStart(Animator animator) {
super.onAnimationStart(animator);
Bitmap bitmap = a2;
if (bitmap == null || bitmap.isRecycled()) {
return;
}
CameraViewNew.this.u.setImageBitmap(a2);
CameraViewNew.this.u.setVisibility(0);
}
});
this.R.start();
}
public void a(IExploreCameraService.SwitchMethod switchMethod, boolean z, ICameraStateCallback iCameraStateCallback, boolean z2) {
if (!z2 && iCameraStateCallback != null) {
this.z = false;
iCameraStateCallback.c();
return;
}
if (!this.z) {
b(getContext());
}
if (switchMethod != IExploreCameraService.SwitchMethod.EXPLORE_TYPE_QRCODE) {
if (switchMethod != IExploreCameraService.SwitchMethod.EXPLORE_TYPE_DEFAULT) {
if (z) {
}
a(this.e);
} else {
if (z) {
k();
}
a(this.e);
}
iCameraStateCallback.b();
if (z) {
}
a(this.e);
}
}
public void a(final boolean z) {
int numberOfCameras;
int i;
Handler handler;
Runnable runnable;
if (this.f52254a == null || System.currentTimeMillis() - this.U <= 1500) {
return;
}
this.U = System.currentTimeMillis();
try {
numberOfCameras = Camera.getNumberOfCameras();
} catch (RuntimeException unused) {
return;
}
for (i = 0; i < numberOfCameras; i++) {
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(i, cameraInfo);
if (!z) {
if (this.w == 1) {
if (cameraInfo.facing == 1) {
l();
handler = new Handler(Looper.getMainLooper());
runnable = new Runnable() {
@Override
public void run() {
if (CameraViewNew.this.f52254a.c()) {
CameraViewNew.this.postDelayed(new Runnable() {
@Override
public void run() {
CameraViewNew.this.U = 0L;
CameraViewNew.this.a(z);
}
}, 100L);
return;
}
CameraViewNew.this.w = 0;
CameraViewNew.this.aa = -1;
CameraViewNew.this.W = -1;
CameraViewNew.this.f52254a.b();
CameraViewNew.this.k();
CameraViewNew.this.e();
CameraViewNew.this.U = 0L;
}
};
}
} else if (cameraInfo.facing == 0) {
l();
handler = new Handler(Looper.getMainLooper());
runnable = new Runnable() {
@Override
public void run() {
if (CameraViewNew.this.f52254a.c()) {
CameraViewNew.this.postDelayed(new Runnable() {
@Override
public void run() {
CameraViewNew.this.U = 0L;
CameraViewNew.this.a(z);
}
}, 100L);
return;
}
CameraViewNew.this.w = 1;
CameraViewNew.this.aa = -1;
CameraViewNew.this.W = -1;
CameraViewNew.this.f52254a.b();
CameraViewNew.this.k();
CameraViewNew.this.e();
CameraViewNew.this.U = 0L;
}
};
}
return;
}
l();
handler = new Handler(Looper.getMainLooper());
runnable = new Runnable() {
@Override
public void run() {
if (CameraViewNew.this.f52254a.c()) {
CameraViewNew.this.postDelayed(new Runnable() {
@Override
public void run() {
CameraViewNew.this.U = 0L;
CameraViewNew.this.a(z);
}
}, 100L);
return;
}
CameraViewNew.this.aa = -1;
CameraViewNew.this.W = -1;
CameraViewNew.this.k();
CameraViewNew.this.e();
}
};
handler.postDelayed(runnable, 300L);
return;
}
}
private void b(Context context) {
this.v.set(false);
TextureView textureView = this.f52255b;
if (textureView != null && (textureView.getParent() instanceof QBFrameLayout)) {
((QBFrameLayout) this.f52255b.getParent()).removeView(this.f52255b);
this.f52255b = null;
}
ImageView imageView = this.u;
if (imageView != null && (imageView.getParent() instanceof QBFrameLayout)) {
((QBFrameLayout) this.u.getParent()).removeView(this.u);
this.u = null;
}
a(context);
if (this.f52255b == null) {
x();
}
if (this.f52254a == null) {
this.f52254a = new CameraCenterManager(getContext());
this.f52254a.a(this);
this.f52254a.a(this.f52255b);
}
try {
IVideoService iVideoService = (IVideoService) QBContext.getInstance().getService(IVideoService.class);
if (iVideoService != null) {
iVideoService.destroyLitePlayers();
}
} catch (NoSuchMethodError unused) {
}
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
addView(this.f52255b, layoutParams);
addView(this.u, layoutParams);
this.z = true;
}
public void b(final SurfaceTexture surfaceTexture, final int i) {
this.s++;
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if (CameraViewNew.this.s < 10) {
CameraViewNew.this.a(surfaceTexture, i);
}
}
}, 50L);
}
private void b(MotionEvent motionEvent) {
int actionIndex = motionEvent.getActionIndex();
this.E = motionEvent.getPointerId(actionIndex);
float x = motionEvent.getX(actionIndex);
float y = motionEvent.getY(actionIndex);
this.A = x;
this.C = y;
this.g = 7;
this.h = 1;
this.j = this.i;
this.p = false;
this.L = true;
if (this.N.contains((int) this.A, (int) this.C)) {
this.F = 4;
this.p = true;
}
}
private void b(final IExploreCameraService.SwitchMethod switchMethod, int i, final boolean z, final ICameraStateCallback iCameraStateCallback) {
this.w = i;
if (DeviceUtils.K() < 23 || PermissionUtils.a("android.permission.CAMERA") || this.M) {
a(switchMethod, z, iCameraStateCallback, true);
} else {
PermissionUtils.a(PermissionUtils.a(16), new PermissionRequest.Callback() {
@Override
public void onPermissionRequestGranted(boolean z2) {
CameraViewNew.this.M = true;
CameraViewNew.this.a(switchMethod, z, iCameraStateCallback, true);
}
@Override
public void onPermissionRevokeCanceled() {
CameraViewNew.this.M = false;
CameraViewNew.this.x();
CameraViewNew.this.a(switchMethod, z, iCameraStateCallback, false);
}
}, true);
}
}
private float c(MotionEvent motionEvent) {
float x = motionEvent.getX(0) - motionEvent.getX(1);
float y = motionEvent.getY(0) - motionEvent.getY(1);
return (float) Math.sqrt((x * x) + (y * y));
}
private void d(int i) {
if (this.f52257d && s()) {
if (this.r == null && getCamera() != null) {
this.r = getCamera().getParameters();
}
Camera.Parameters parameters = this.r;
if (parameters != null) {
this.k = parameters.getMaxZoom();
if (this.r.isZoomSupported()) {
try {
Camera.Parameters parameters2 = this.r;
if (i > this.k) {
i = this.k;
}
parameters2.setZoom(i);
getCamera().setParameters(this.r);
} catch (Exception unused) {
}
}
}
}
}
private boolean e(int i, int i2) {
return Math.abs(i) > 50 || Math.abs(i2) > 50;
}
private void w() {
new CameraImageFetcher("https://res.imtt.qq.com/res_mtt/camera/camera_focus.png", new ICameraImageFetcherCallback() {
@Override
public void a(boolean z, Bitmap bitmap, String str, int i, int i2) {
CameraViewNew.this.n = bitmap;
}
}).a();
}
public void x() {
}
public void y() {
if (this.x == null) {
this.x = new PreviewHandler(this.f52254a);
}
this.x.a(this.f);
}
public void z() {
A();
l();
}
@Override
public Rect a(Rect rect) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.a(rect);
}
return null;
}
public void a() {
TextureView textureView = this.f52255b;
if (textureView != null) {
this.P = 1;
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textureView.getLayoutParams();
if (layoutParams == null) {
layoutParams = new FrameLayout.LayoutParams(-1, -1);
}
layoutParams.topMargin = MttResources.s(80);
layoutParams.bottomMargin = MttResources.s(176);
this.f52255b.setLayoutParams(layoutParams);
}
}
@Override
public void a(byte b2, SensorEvent sensorEvent) {
ArrayList<ICameraDeviceListener> arrayList = this.y;
if (arrayList == null) {
return;
}
synchronized (arrayList) {
Iterator<ICameraDeviceListener> it = this.y.iterator();
while (it.hasNext()) {
it.next().a(b2, sensorEvent);
}
}
}
@Override
public void a(byte b2, boolean z, byte b3) {
ArrayList<ICameraDeviceListener> arrayList = this.y;
if (arrayList == null) {
return;
}
synchronized (arrayList) {
Iterator<ICameraDeviceListener> it = this.y.iterator();
while (it.hasNext()) {
it.next().a(b2, z, b3);
}
}
}
@Override
public void a(final int i) {
if (this.f52254a == null || !s()) {
return;
}
this.f52254a.a(new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] bArr, Camera camera) {
if (camera != null) {
try {
Camera.Parameters parameters = camera.getParameters();
if (parameters != null && parameters.getPictureSize() != null) {
int i2 = parameters.getPictureSize().height;
int i3 = parameters.getPictureSize().width;
int pictureFormat = parameters.getPictureFormat();
if (CameraViewNew.this.f != null) {
CameraViewNew.this.f.a(bArr, i3, i2, pictureFormat, CameraFrameFrom.RecognizeFrom.CAMERA, i);
}
}
camera.startPreview();
} catch (RuntimeException unused) {
}
}
}
});
}
@Override
public void a(int i, int i2) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.b(i, i2);
}
}
@Override
public void a(int i, QBTabView qBTabView) {
this.S = i;
}
public void a(SurfaceTexture surfaceTexture) {
i();
r();
f();
a(surfaceTexture, this.w);
h();
this.Q.postDelayed(new Runnable() {
@Override
public void run() {
CameraViewUtils.a(CameraViewNew.this.u, 8);
CameraViewNew.this.f52255b.getGlobalVisibleRect(CameraViewNew.this.N);
PlatformStatUtils.a("PLATFORM_KEY_NEW_CAMERA_SURFACE_CHANGE_END");
}
}, 600L);
if (FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_CAMERA_SCAN_ERROR_869239905) && CameraPopupScrollTab.a(this.S) == IExploreCameraService.SwitchMethod.EXPLORE_TYPE_DEFAULT) {
this.x.c();
}
}
@Override
public void a(Handler handler, int i) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.a(handler, i);
}
}
@Override
public void a(QBTabView qBTabView) {
}
public void a(IExploreCameraService.SwitchMethod switchMethod) {
int i = (switchMethod == IExploreCameraService.SwitchMethod.EXPLORE_TYPE_TIMU || switchMethod == IExploreCameraService.SwitchMethod.EXPLORE_TYPE_TRANSLATE || switchMethod == IExploreCameraService.SwitchMethod.EXPLORE_TYPE_DEFAULT) ? 0 : 1;
if (i == this.P) {
return;
}
PlatformStatUtils.a("PLATFORM_KEY_NEW_CAMERA_SURFACE_CHANGE_START");
i();
TextureView textureView = this.f52255b;
if (i == 0) {
if (textureView != null && textureView.getParent() == this) {
a(this.f52255b, 0, 0);
}
} else if (textureView != null && textureView.getParent() == this) {
a(this.f52255b, MttResources.s(80), MttResources.s(176));
}
this.P = i;
}
@Override
public void a(IExploreCameraService.SwitchMethod switchMethod, int i, boolean z, ICameraStateCallback iCameraStateCallback) {
b(switchMethod, i, z, iCameraStateCallback);
}
@Override
public void a(ICameraDeviceListener iCameraDeviceListener) {
if (iCameraDeviceListener == null) {
return;
}
synchronized (this.y) {
if (!this.y.contains(iCameraDeviceListener)) {
this.y.add(iCameraDeviceListener);
}
}
}
@Override
public Rect b(Rect rect) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.b(rect);
}
return null;
}
protected void b() {
this.K.setColor(this.o);
this.K.setStyle(Paint.Style.FILL);
}
@Override
public void b(int i) {
if (this.w == i) {
return;
}
if (DeviceUtils.K() < 23 || PermissionUtils.a("android.permission.CAMERA")) {
C();
} else {
this.w = 1 - this.w;
}
}
@Override
public void b(int i, int i2) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.a(i, i2);
}
}
@Override
public void b(ICameraDeviceListener iCameraDeviceListener) {
ArrayList<ICameraDeviceListener> arrayList;
if (iCameraDeviceListener == null || (arrayList = this.y) == null) {
return;
}
synchronized (arrayList) {
if (this.y.contains(iCameraDeviceListener)) {
this.y.remove(iCameraDeviceListener);
}
}
}
@Override
public ICameraProxy.CameraParams c(int i, int i2) {
if (getCamera() != null && this.t == null) {
this.t = new ICameraProxy.CameraParams();
try {
Camera.Parameters parameters = getCamera().getParameters();
if (parameters != null) {
this.t.f52400d = parameters.getPreviewFrameRate();
this.t.f52398b = parameters.getPreviewSize().height;
this.t.f52397a = parameters.getPreviewSize().width;
this.t.f52399c = parameters.getPreviewFormat();
this.t.e = this.w;
}
} catch (RuntimeException unused) {
}
}
ICameraProxy.CameraParams cameraParams = this.t;
if (cameraParams != null && (cameraParams.f52397a != i || this.t.f52398b != i2 || this.t.e != this.w)) {
ICameraProxy.CameraParams cameraParams2 = this.t;
cameraParams2.f52397a = i;
cameraParams2.f52398b = i2;
cameraParams2.e = this.w;
}
return this.t;
}
protected void c() {
this.e = new ICameraDeviceListener() {
@Override
public void a(byte b2, SensorEvent sensorEvent) {
}
@Override
public void a(byte b2, boolean z, byte b3) {
if (b2 != 5 || CameraViewNew.this.V == b3) {
return;
}
CameraViewNew.this.setOrienMode(b3);
}
};
}
@Override
public void c(int i) {
d(i);
}
@Override
public void d() {
B();
this.M = false;
this.f = null;
this.T.removeCallbacksAndMessages(null);
b(this.e);
}
@Override
public void d(int i, int i2) {
this.p = false;
this.L = true;
this.A = i;
this.C = i2;
if (this.N.contains(i, i2)) {
this.p = true;
}
if (this.p && System.currentTimeMillis() - this.D > 1000) {
this.F = 4;
this.L = false;
this.J = 0L;
this.I = AnimationUtils.currentAnimationTimeMillis() - this.J;
this.H = System.currentTimeMillis();
this.G = this.H;
q();
}
invalidate();
this.D = System.currentTimeMillis();
}
@Override
public void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
this.H = System.currentTimeMillis();
if (this.F != 4 || this.L || this.H - this.G > 800) {
return;
}
Bitmap bitmap = this.n;
if (bitmap != null && !bitmap.isRecycled()) {
this.K.setAlpha((int) a(255, 204, a(400L)));
canvas.drawBitmap(this.n, this.A - (r0.getWidth() / 2), this.C - (this.n.getHeight() / 2), this.K);
}
postInvalidateDelayed(10L);
}
@Override
public void e() {
PreviewHandler previewHandler = this.x;
if (previewHandler != null) {
this.x.sendMessage(Message.obtain(previewHandler, 17));
}
}
public void f() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.b();
}
}
@Override
public void g() {
C();
}
@Override
public Camera getCamera() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.m();
}
return null;
}
public int getCameraPosition() {
return this.w;
}
@Override
public Point getCameraResolution() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.a();
}
return null;
}
@Override
public int getDecodeRotateDegree() {
if (this.aa == -1) {
this.aa = CameraViewUtils.a(this.w);
}
return this.aa;
}
@Override
public int getDeviceRotate() {
int i;
if (this.W == -1) {
this.W = CameraViewUtils.a(this.w);
byte b2 = this.V;
if (b2 != 1) {
if (b2 == 2) {
}
}
this.W = i;
}
return this.W;
}
@Override
public Rect getFramingRect() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.l();
}
return null;
}
@Override
public byte getOrienMode() {
return this.V;
}
public Size getSurfaceFrameRect() {
return this.O;
}
@Override
public void h() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
if (cameraCenterManager.c()) {
this.f52254a.f();
} else {
k();
}
}
}
@Override
public void i() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.g();
}
}
@Override
public boolean j() {
return this.w == 0;
}
@Override
public void k() {
TextureView textureView = this.f52255b;
if (textureView != null) {
textureView.setSurfaceTextureListener(this);
}
TextureView textureView2 = this.f52255b;
if (textureView2 == null) {
x();
return;
}
SurfaceTexture surfaceTexture = textureView2.getSurfaceTexture();
if (surfaceTexture == null) {
x();
return;
}
a(surfaceTexture, this.w);
setVisibility(0);
this.f52255b.setVisibility(0);
}
@Override
public void l() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.g();
try {
this.f52254a.d();
} catch (Exception unused) {
}
}
this.r = null;
}
@Override
public void m() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.k();
}
}
@Override
public void n() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.j();
}
}
@Override
public boolean o() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.e();
}
return false;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
}
@Override
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
this.N.set(0, MttResources.g(f.z), getMeasuredWidth(), getMeasuredHeight() - MttResources.g(f.M));
Rect rect = new Rect();
if (this.f52255b.getGlobalVisibleRect(rect)) {
this.N.set(rect);
}
this.f52255b.getGlobalVisibleRect(this.N);
if ((i == i3 && i2 == i4) || i4 == 0 || i3 == 0) {
return;
}
f();
a(true);
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
this.O = new Size(i, i2);
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null && this.O != null) {
cameraCenterManager.a(new Point(i, i2));
}
if (this.v.get()) {
return;
}
this.f52257d = true;
this.v.set(true);
a(surfaceTexture, this.w);
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
this.T.post(new Runnable() {
@Override
public void run() {
if (CameraViewNew.this.x != null) {
CameraViewNew.this.x.a();
CameraViewNew.this.x = null;
}
if (CameraViewNew.this.f52254a.c()) {
CameraViewNew.this.f52254a.g();
CameraViewNew.this.f52254a.d();
}
CameraViewNew.this.v.set(false);
}
});
return true;
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
AnimatorSet animatorSet = this.R;
if (animatorSet == null || !animatorSet.isRunning()) {
this.O = new Size(i, i2);
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null && this.O != null) {
cameraCenterManager.a(new Point(i, i2));
}
a(surfaceTexture);
}
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
int i;
int action = motionEvent.getAction() & 255;
if (action != 0) {
if (action != 1) {
if (action == 2) {
a(motionEvent);
} else if (action != 3) {
if (action == 5) {
this.g = 5;
this.l = c(motionEvent);
this.j = this.i;
i = this.h + 1;
} else if (action == 6) {
this.g = 5;
i = this.h - 1;
}
this.h = i;
}
}
D();
} else {
b(motionEvent);
}
return true;
}
@Override
public void p() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.h();
}
}
@Override
public void q() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.i();
}
}
@Override
public void r() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.d();
}
}
@Override
public boolean s() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
return cameraCenterManager.c();
}
return false;
}
@Override
public void setCameraFocusMode(int i) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.a(i);
}
}
@Override
public void setCameraSensorMode(int i) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.b(i);
}
}
@Override
public void setFetchDataCallback(ICameraDataCallback iCameraDataCallback) {
this.f = iCameraDataCallback;
PreviewHandler previewHandler = this.x;
if (previewHandler != null) {
previewHandler.a(iCameraDataCallback);
}
}
protected void setOrienMode(byte b2) {
if (b2 != this.V) {
this.V = b2;
int a2 = CameraViewUtils.a(this.w);
byte b3 = this.V;
if (b3 == 1) {
a2 -= 90;
} else if (b3 == 2) {
a2 += 90;
}
this.W = a2;
}
}
public void setPopExpandMenu(CameraPopupScrollTab cameraPopupScrollTab) {
this.q = cameraPopupScrollTab;
}
@Override
public void setUseAutoFocus(boolean z) {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.a(z);
}
}
@Override
public void t() {
CameraCenterManager cameraCenterManager = this.f52254a;
if (cameraCenterManager != null) {
cameraCenterManager.n();
}
}
public boolean u() {
return this.v.get();
}
public boolean v() {
return s() && this.P != 0;
}
}