得物.apk(点击下载) / ArShoeBytedanceDriver.java
package com.shizhuang.duapp.modules.mall_ar.utils.arshoe.bytedance;
import a.f;
import android.content.Context;
import android.util.Size;
import android.view.ViewGroup;
import androidx.activity.ComponentActivity;
import androidx.lifecycle.LifecycleOwner;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.modules.du_mall_common.extension.LifecycleExtensionKt;
import com.shizhuang.duapp.modules.du_mall_common.extension.ViewExtensionKt;
import com.shizhuang.duapp.modules.mall_ar.utils.arshoe.ArShoeOperationListener;
import com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver;
import com.shizhuang.duapp.modules.mall_ar.utils.arshoe.OnArShoeOperationListener;
import com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadCallback;
import com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadUtils$isAlreadyDownloaded$1;
import com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadUtils$startDownload$1;
import com.shizhuang.duapp.stream.impl.DuRecorder;
import com.shizhuang.duapp.stream.interfaces.IRecorder;
import com.shizhuang.duapp.stream.interfaces.IRecorderListener;
import com.shizhuang.duapp.stream.interfaces.IVideoRenderListener;
import com.shizhuang.duapp.stream.model.StreamModel;
import com.shizhuang.duapp.stream.opengl.BaseEffectHelper;
import com.shizhuang.media.view.PreviewSurfaceView;
import com.vk.duapp.utils.FileUtil;
import dr0.e;
import dr0.g;
import fd.n;
import java.io.File;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import kotlin.Lazy;
import kotlin.LazyKt__LazyJVMKt;
import kotlin.LazyThreadSafetyMode;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;
import kotlin.text.StringsKt__StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import s9.c;
/* compiled from: ArShoeBytedanceDriver.kt */
public final class ArShoeBytedanceDriver implements IArShoeDriver {
public static ChangeQuickRedirect changeQuickRedirect;
public final Lazy b;
/* renamed from: c reason: collision with root package name */
public final Lazy f19173c;
public OnArShoeOperationListener d;
public AtomicBoolean e = new AtomicBoolean(false);
public final AtomicLong f = new AtomicLong(0);
/* renamed from: g reason: collision with root package name */
public final AtomicBoolean f19174g = new AtomicBoolean(false);
/* renamed from: h reason: collision with root package name */
public String f19175h;
public String i;
public String j;
public volatile c k;
public c l;
public c m;
public final b n = new b(this);
public final ComponentActivity o;
public final ArShoeOperationListener p;
/* compiled from: ArShoeBytedanceDriver.kt */
public static final class a implements IVideoRenderListener {
public static ChangeQuickRedirect changeQuickRedirect;
/* renamed from: a reason: collision with root package name */
public final /* synthetic */ ArShoeBytedanceDriver f19176a;
/* renamed from: com.shizhuang.duapp.modules.mall_ar.utils.arshoe.bytedance.ArShoeBytedanceDriver$a$a reason: collision with other inner class name */
/* compiled from: ArShoeBytedanceDriver.kt */
public static final class C0299a implements IRecorderListener {
public static ChangeQuickRedirect changeQuickRedirect;
/* renamed from: a reason: collision with root package name */
public final /* synthetic */ a f19177a;
/* JADX WARN: Incorrect args count in method signature: ()V */
public C0299a(a aVar) {
this.f19177a = aVar;
}
@Override // com.shizhuang.duapp.stream.interfaces.IRecorderListener
public void onFail() {
boolean z = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208984, new Class[0], Void.TYPE).isSupported;
}
@Override // com.shizhuang.duapp.stream.interfaces.IRecorderListener
public void onSuccess(@NotNull StreamModel streamModel) {
if (!PatchProxy.proxy(new Object[]{streamModel}, this, changeQuickRedirect, false, 208983, new Class[]{StreamModel.class}, Void.TYPE).isSupported) {
List<String> videoPath = streamModel.getVideoPath();
String str = videoPath != null ? videoPath.get(0) : null;
if (str == null) {
str = "";
}
this.f19177a.f19176a.p.videoCaptureSuccess(str);
this.f19177a.f19176a.b().deleteLastFrag(null);
}
}
}
/* JADX WARN: Incorrect args count in method signature: ()V */
public a(ArShoeBytedanceDriver arShoeBytedanceDriver) {
this.f19176a = arShoeBytedanceDriver;
}
@Override // com.shizhuang.duapp.stream.interfaces.IVideoRenderListener
public void complete() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208982, new Class[0], Void.TYPE).isSupported && this.f19176a.f19174g.get()) {
this.f19176a.b().asyncVideo(new C0299a(this));
}
}
}
/* compiled from: ArShoeBytedanceDriver.kt */
public static final class b implements ArShoeDownloadCallback {
public static ChangeQuickRedirect changeQuickRedirect;
/* renamed from: a reason: collision with root package name */
public final /* synthetic */ ArShoeBytedanceDriver f19178a;
/* JADX WARN: Incorrect args count in method signature: ()V */
public b(ArShoeBytedanceDriver arShoeBytedanceDriver) {
this.f19178a = arShoeBytedanceDriver;
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadCallback
public void onDownloadError() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208987, new Class[0], Void.TYPE).isSupported) {
this.f19178a.f19175h = null;
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadCallback
public void onDownloadProgress(float f, long j, long j12) {
Object[] objArr = {new Float(f), new Long(j), new Long(j12)};
ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
Class cls = Long.TYPE;
boolean z = PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 208985, new Class[]{Float.TYPE, cls, cls}, Void.TYPE).isSupported;
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadCallback
public void onDownloadSuccess() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208986, new Class[0], Void.TYPE).isSupported) {
this.f19178a.f19175h = null;
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadCallback
public void onUnZipError() {
boolean z = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208989, new Class[0], Void.TYPE).isSupported;
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.download.ArShoeDownloadCallback
public void onUnZipSuccess(@Nullable String str) {
if (!PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 208988, new Class[]{String.class}, Void.TYPE).isSupported && str != null) {
this.f19178a.b().setSticker(str);
}
}
}
public ArShoeBytedanceDriver(@NotNull ComponentActivity componentActivity, @NotNull ArShoeOperationListener arShoeOperationListener) {
this.o = componentActivity;
this.p = arShoeOperationListener;
ArShoeBytedanceDriver$mRecorder$2 arShoeBytedanceDriver$mRecorder$2 = ArShoeBytedanceDriver$mRecorder$2.INSTANCE;
LazyThreadSafetyMode lazyThreadSafetyMode = LazyThreadSafetyMode.NONE;
this.b = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, (Function0) arShoeBytedanceDriver$mRecorder$2);
this.f19173c = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, (Function0) new ArShoeBytedanceDriver$preview$2(this));
}
public final void a(c cVar) {
if (!PatchProxy.proxy(new Object[]{cVar}, this, changeQuickRedirect, false, 208980, new Class[]{c.class}, Void.TYPE).isSupported && cVar != null && !cVar.o) {
cVar.g();
}
}
public final IRecorder b() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208967, new Class[0], IRecorder.class);
return (IRecorder) (proxy.isSupported ? proxy.result : this.b.getValue());
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void buildView(@NotNull ViewGroup viewGroup, @Nullable vi1.a aVar) {
if (!PatchProxy.proxy(new Object[]{viewGroup, aVar}, this, changeQuickRedirect, false, 208970, new Class[]{ViewGroup.class, vi1.a.class}, Void.TYPE).isSupported && !this.e.get() && this.i != null && this.j != null) {
Context context = viewGroup.getContext();
ViewExtensionKt.a(viewGroup, c(), 0, true, true, 0, 0, 48);
if (b() instanceof DuRecorder) {
DuRecorder duRecorder = (DuRecorder) b();
String str = this.i;
if (!PatchProxy.proxy(new Object[]{str}, duRecorder, DuRecorder.changeQuickRedirect, false, 334588, new Class[]{String.class}, Void.TYPE).isSupported) {
duRecorder.r = str;
}
DuRecorder duRecorder2 = (DuRecorder) b();
if (!PatchProxy.proxy(new Object[]{new Byte((byte) 0)}, duRecorder2, DuRecorder.changeQuickRedirect, false, 334592, new Class[]{Boolean.TYPE}, Void.TYPE).isSupported) {
duRecorder2.s = false;
}
BaseEffectHelper b2 = ((DuRecorder) b()).b();
if (b2 != null) {
b2.b(context, this.i, this.j, false);
}
DuRecorder duRecorder3 = (DuRecorder) b();
ArShoeBytedanceDriver$buildView$1 arShoeBytedanceDriver$buildView$1 = new ArShoeBytedanceDriver$buildView$1(this);
if (!PatchProxy.proxy(new Object[]{arShoeBytedanceDriver$buildView$1}, duRecorder3, DuRecorder.changeQuickRedirect, false, 334594, new Class[]{Function1.class}, Void.TYPE).isSupported) {
duRecorder3.t = arShoeBytedanceDriver$buildView$1;
}
}
b().initRecorder(context, c());
IRecorder b5 = b();
cf1.b bVar = new cf1.b();
bVar.c(0.5625f);
bVar.a(1);
Unit unit = Unit.INSTANCE;
b5.startPreview(bVar);
b().setVideoRenderListener(new a(this));
if (aVar != null) {
downloadArModel(aVar);
}
if (LifecycleExtensionKt.k(this.o)) {
b().onRecorderResume();
}
this.e.set(true);
}
}
public final PreviewSurfaceView c() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208968, new Class[0], PreviewSurfaceView.class);
return (PreviewSurfaceView) (proxy.isSupported ? proxy.result : this.f19173c.getValue());
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void cancelVideoCapture() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208974, new Class[0], Void.TYPE).isSupported) {
this.f19174g.set(false);
b().stopRecord();
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void downloadArModel(@NotNull vi1.a aVar) {
c cVar;
File[] listFiles;
File file;
boolean z = false;
if (!PatchProxy.proxy(new Object[]{aVar}, this, changeQuickRedirect, false, 208976, new Class[]{vi1.a.class}, Void.TYPE).isSupported) {
String str = this.f19175h;
if (str == null || !Intrinsics.areEqual(str, aVar.f39293a)) {
g gVar = g.f31596a;
ComponentActivity componentActivity = this.o;
String str2 = aVar.f39293a;
b bVar = this.n;
PatchProxyResult proxy = PatchProxy.proxy(new Object[]{componentActivity, str2, bVar}, gVar, g.changeQuickRedirect, false, 209012, new Class[]{Context.class, String.class, ArShoeDownloadCallback.class}, c.class);
if (proxy.isSupported) {
cVar = (c) proxy.result;
} else {
if (!StringsKt__StringsJVMKt.isBlank(str2)) {
File e6 = FileUtil.e(componentActivity);
if (e6 == null || !e6.exists() || !e6.isDirectory()) {
bVar.onDownloadError();
} else {
String q8 = FileUtil.q(str2);
if (!(q8 == null || q8.length() == 0)) {
StringBuilder sb2 = new StringBuilder();
sb2.append(e6.getAbsolutePath());
File file2 = new File(f.g(sb2, File.separator, q8));
if (file2.exists() || file2.mkdir()) {
ArShoeDownloadUtils$startDownload$1 arShoeDownloadUtils$startDownload$1 = ArShoeDownloadUtils$startDownload$1.INSTANCE;
PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{componentActivity, q8}, gVar, g.changeQuickRedirect, false, 209013, new Class[]{Context.class, String.class}, Boolean.TYPE);
if (proxy2.isSupported) {
z = ((Boolean) proxy2.result).booleanValue();
} else {
File e12 = FileUtil.e(componentActivity);
if (!(e12 == null || (listFiles = e12.listFiles(new e(StringsKt__StringsKt.trim((CharSequence) q8).toString()))) == null)) {
if ((!(listFiles.length == 0)) && !(z = ArShoeDownloadUtils$isAlreadyDownloaded$1.INSTANCE.invoke((file = listFiles[0])))) {
FileUtil.n(file);
}
}
}
if (z) {
bVar.onDownloadProgress(1.0f, 0, 0);
bVar.onDownloadSuccess();
bVar.onUnZipSuccess(arShoeDownloadUtils$startDownload$1.invoke(file2.getAbsolutePath()));
} else {
cVar = tl.a.o(str2, file2, new dr0.f(bVar));
}
} else {
bVar.onDownloadError();
}
}
}
}
cVar = null;
}
this.k = cVar;
this.f19175h = aVar.f39293a;
}
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void onDestroy() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208979, new Class[0], Void.TYPE).isSupported) {
b().onRecorderDestroy();
a(this.k);
a(this.m);
a(this.l);
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void onPause() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208978, new Class[0], Void.TYPE).isSupported) {
b().onRecorderPause();
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void onResume() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208977, new Class[0], Void.TYPE).isSupported) {
b().onRecorderResume();
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void prepareSo(@NotNull ComponentActivity componentActivity) {
if (!PatchProxy.proxy(new Object[]{componentActivity}, this, changeQuickRedirect, false, 208971, new Class[]{ComponentActivity.class}, Void.TYPE).isSupported) {
br0.a.f1838a.i();
g gVar = g.f31596a;
ArShoeBytedanceDriver$prepareSo$1 arShoeBytedanceDriver$prepareSo$1 = new ArShoeBytedanceDriver$prepareSo$1(this, componentActivity);
c cVar = null;
PatchProxyResult proxy = PatchProxy.proxy(new Object[]{componentActivity, arShoeBytedanceDriver$prepareSo$1, null}, gVar, g.changeQuickRedirect, false, 209010, new Class[]{LifecycleOwner.class, Function1.class, Function1.class}, c.class);
if (proxy.isSupported) {
cVar = (c) proxy.result;
} else {
String str = (String) n.c("community_module", "community_cv_license_v2", String.class, "https://apk.poizon.com/duApp/Android_Config/license/cv/duapp_20210309_20210608_com.shizhuang.duapp_v1.0.2.licbag");
File t = tl.a.t(str);
if (t == null || !t.exists()) {
cVar = tl.a.n(str, new dr0.a(arShoeBytedanceDriver$prepareSo$1, null, componentActivity, componentActivity, true));
} else {
Unit unit = (Unit) arShoeBytedanceDriver$prepareSo$1.invoke((Object) t.getAbsolutePath());
}
}
this.l = cVar;
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void setOnOperationListener(@NotNull OnArShoeOperationListener onArShoeOperationListener) {
if (!PatchProxy.proxy(new Object[]{onArShoeOperationListener}, this, changeQuickRedirect, false, 208969, new Class[]{OnArShoeOperationListener.class}, Void.TYPE).isSupported) {
this.d = onArShoeOperationListener;
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void startVideoCapture(boolean z) {
if (!PatchProxy.proxy(new Object[]{new Byte(z ? (byte) 1 : 0)}, this, changeQuickRedirect, false, 208972, new Class[]{Boolean.TYPE}, Void.TYPE).isSupported) {
b().startRecord(new Size(720, 1242));
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void stopVideoCapture() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 208973, new Class[0], Void.TYPE).isSupported) {
this.f19174g.set(true);
b().stopRecord();
}
}
@Override // com.shizhuang.duapp.modules.mall_ar.utils.arshoe.IArShoeDriver
public void takePhoto(int i3, int i12) {
Object[] objArr = {new Integer(i3), new Integer(i12)};
ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
Class cls = Integer.TYPE;
if (!PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 208975, new Class[]{cls, cls}, Void.TYPE).isSupported) {
IRecorder b2 = b();
cf1.a aVar = new cf1.a();
aVar.d(c().getWidth());
aVar.b((c().getWidth() * 4) / 3);
aVar.c(true);
Unit unit = Unit.INSTANCE;
b2.takePic(aVar, new ArShoeBytedanceDriver$takePhoto$2(this));
}
}
}