得物.apk(点击下载) / EffectTextStickerTask.java
package com.shizhuang.duapp.media.sticker.helper;
import a30.h;
import android.graphics.Color;
import androidx.core.view.MotionEventCompat;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import bj1.e;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.media.cover.input.EffectTextViewModel;
import com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper;
import com.shizhuang.duapp.modules.du_community_common.bean.BackgroundConfig;
import com.shizhuang.duapp.modules.du_community_common.bean.Fonts;
import com.shizhuang.duapp.modules.du_community_common.bean.NameSticker;
import com.shizhuang.duapp.modules.du_community_common.bean.PoiSticker;
import com.shizhuang.duapp.modules.du_community_common.bean.TextStickerStyle;
import com.shizhuang.duapp.modules.du_community_common.bean.TimeSticker;
import com.shizhuang.duapp.modules.du_community_common.dialog.PublishLoadDialogFragment;
import com.shizhuang.duapp.modules.du_community_common.facade.request.DuHttpRequest;
import com.shizhuang.duapp.modules.du_community_common.facade.request.WrappersKt;
import com.shizhuang.duapp.modules.du_community_common.model.publish.EffectTextArtFont;
import com.shizhuang.duapp.modules.du_community_common.model.publish.EffectTextDetail;
import com.shizhuang.duapp.modules.du_community_common.model.publish.EffectTextTitle;
import com.shizhuang.duapp.modules.du_community_common.view.sticker.bean.EffectTextBean;
import com.shizhuang.duapp.modules.du_community_common.view.sticker.bean.StickerBean;
import com.shizhuang.duapp.modules.du_community_common.view.sticker.bean.StickerTimeBean;
import com.shizhuang.duapp.modules.du_community_common.view.sticker.view.LocationStickerView;
import com.shizhuang.duapp.modules.du_community_common.view.sticker.view.NicknameStickerView;
import com.shizhuang.duapp.modules.du_community_common.view.sticker.view.TimeStickerView;
import com.shizhuang.duapp.modules.router.ServiceManager;
import com.shizhuang.media.text.TextEffect;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableSource;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
import kotlin.Lazy;
import kotlin.LazyKt__LazyJVMKt;
import kotlin.Unit;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Ref;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.c;
import t20.g;
import v20.i;
import v20.j;
/* compiled from: EffectTextStickerTask.kt */
public final class EffectTextStickerTask implements PublishStickerHelper.IStickerTask {
public static ChangeQuickRedirect changeQuickRedirect;
@Nullable
/* renamed from: a reason: collision with root package name */
public Function1<? super String, Unit> f10472a;
public final Lazy b = LazyKt__LazyJVMKt.lazy(EffectTextStickerTask$textEffect$2.INSTANCE);
/* renamed from: c reason: collision with root package name */
public final Lazy f10473c = LazyKt__LazyJVMKt.lazy(EffectTextStickerTask$textDetailRequest$2.INSTANCE);
public final int d = h.b(80, g.f38329a.b(null));
public final int e = 13;
public final EffectTextBean f = new EffectTextBean(new ArrayList());
/* compiled from: EffectTextStickerTask.kt */
public static final class a extends DuHttpRequest<EffectTextDetail> {
public static ChangeQuickRedirect changeQuickRedirect;
@Nullable
/* renamed from: a reason: collision with root package name */
public StickerBean f10475a;
@Nullable
public ObservableEmitter<StickerBean> b;
public a() {
super(null, EffectTextDetail.class, null, false, 4, null);
}
@Nullable
public final ObservableEmitter<StickerBean> k() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 51589, new Class[0], ObservableEmitter.class);
return proxy.isSupported ? (ObservableEmitter) proxy.result : this.b;
}
@Nullable
public final StickerBean l() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 51587, new Class[0], StickerBean.class);
return proxy.isSupported ? (StickerBean) proxy.result : this.f10475a;
}
public final void m(@Nullable ObservableEmitter<StickerBean> observableEmitter) {
if (!PatchProxy.proxy(new Object[]{observableEmitter}, this, changeQuickRedirect, false, 51590, new Class[]{ObservableEmitter.class}, Void.TYPE).isSupported) {
this.b = observableEmitter;
}
}
}
/* compiled from: EffectTextStickerTask.kt */
public static final class b<T, R> implements Function<StickerBean, ObservableSource<? extends StickerBean>> {
public static ChangeQuickRedirect changeQuickRedirect;
public final /* synthetic */ EffectTextStickerTask b;
public b(EffectTextStickerTask effectTextStickerTask) {
this.b = effectTextStickerTask;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
/* JADX WARNING: Removed duplicated region for block: B:31:0x008f */
/* JADX WARNING: Removed duplicated region for block: B:41:0x00c2 */
@Override // io.reactivex.functions.Function
public ObservableSource<? extends StickerBean> apply(StickerBean stickerBean) {
String str;
String str2;
String str3;
String textTexture;
String fontUrl;
StickerBean stickerBean2 = stickerBean;
PatchProxyResult proxy = PatchProxy.proxy(new Object[]{stickerBean2}, this, changeQuickRedirect, false, 51599, new Class[]{StickerBean.class}, ObservableSource.class);
if (proxy.isSupported) {
return (ObservableSource) proxy.result;
}
EffectTextStickerTask effectTextStickerTask = this.b;
PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{stickerBean2}, effectTextStickerTask, EffectTextStickerTask.changeQuickRedirect, false, 51574, new Class[]{StickerBean.class}, e.class);
if (proxy2.isSupported) {
return (e) proxy2.result;
}
TextStickerStyle config = stickerBean2.getConfig();
if (config == null) {
return e.just(stickerBean2);
}
String fontUrl2 = config.getFontUrl();
if (fontUrl2 == null || fontUrl2.length() == 0) {
fontUrl = "https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf";
} else {
fontUrl = config.getFontUrl();
if (fontUrl == null) {
str = "";
if (config.getColorType() == 2 || config.getTextTexture() == null || (textTexture = config.getTextTexture()) == null) {
str2 = "";
} else {
str2 = textTexture;
}
if (config.getBackgroundConfig() != null) {
BackgroundConfig backgroundConfig = config.getBackgroundConfig();
String backgroundUrl = backgroundConfig != null ? backgroundConfig.getBackgroundUrl() : null;
if (backgroundUrl != null) {
str3 = backgroundUrl;
ArrayList arrayListOf = CollectionsKt__CollectionsKt.arrayListOf("https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf", "https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf", str, str2, str3);
ArrayList arrayList = new ArrayList();
for (T t : arrayListOf) {
if (t.length() > 0) {
arrayList.add(t);
}
}
return ku.a.f34913a.a(arrayList).flatMap(new c(effectTextStickerTask, "https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf", "https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf", str, str2, str3, stickerBean2));
}
}
str3 = "";
ArrayList arrayListOf2 = CollectionsKt__CollectionsKt.arrayListOf("https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf", "https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf", str, str2, str3);
ArrayList arrayList2 = new ArrayList();
while (r0.hasNext()) {
}
return ku.a.f34913a.a(arrayList2).flatMap(new c(effectTextStickerTask, "https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf", "https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf", str, str2, str3, stickerBean2));
}
}
str = fontUrl;
if (config.getColorType() == 2) {
}
str2 = "";
if (config.getBackgroundConfig() != null) {
}
str3 = "";
ArrayList arrayListOf22 = CollectionsKt__CollectionsKt.arrayListOf("https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf", "https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf", str, str2, str3);
ArrayList arrayList22 = new ArrayList();
while (r0.hasNext()) {
}
return ku.a.f34913a.a(arrayList22).flatMap(new c(effectTextStickerTask, "https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf", "https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf", str, str2, str3, stickerBean2));
}
}
public EffectTextStickerTask() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 51571, new Class[0], Void.TYPE).isSupported) {
a a5 = a();
LifecycleOwner a12 = WrappersKt.a();
j jVar = new j(a12, a5.isShowErrorToast(), null);
Ref.BooleanRef booleanRef = new Ref.BooleanRef();
booleanRef.element = a5.getMutableAllStateLiveData().getValue() instanceof DuHttpRequest.b.a;
a5.getMutableAllStateLiveData().observe(i.f39125a.a(a12), new EffectTextStickerTask$initEffectText$$inlined$observeForever$1(a5, jVar, booleanRef, this));
}
}
public final a a() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 51570, new Class[0], a.class);
return (a) (proxy.isSupported ? proxy.result : this.f10473c.getValue());
}
public final TextEffect b() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 51569, new Class[0], TextEffect.class);
return (TextEffect) (proxy.isSupported ? proxy.result : this.b.getValue());
}
@Override // com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper.IStickerTask
@NotNull
public e<StickerBean> buildObservable(@NotNull StickerBean stickerBean) {
e eVar;
PoiSticker poiSticker;
List<Fonts> fonts;
NameSticker nameSticker;
List<Fonts> fonts2;
TextStickerStyle config;
TimeSticker timeSticker;
List<Fonts> fonts3;
PatchProxyResult proxy = PatchProxy.proxy(new Object[]{stickerBean}, this, changeQuickRedirect, false, 51575, new Class[]{StickerBean.class}, e.class);
if (proxy.isSupported) {
return (e) proxy.result;
}
PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{stickerBean}, this, changeQuickRedirect, false, 51572, new Class[]{StickerBean.class}, e.class);
if (proxy2.isSupported) {
eVar = (e) proxy2.result;
} else {
TextStickerStyle config2 = stickerBean.getConfig();
Fonts fonts4 = null;
List<EffectTextTitle> titles = config2 != null ? config2.getTitles() : null;
if (titles == null) {
titles = CollectionsKt__CollectionsKt.emptyList();
}
TextStickerStyle config3 = stickerBean.getConfig();
List<EffectTextArtFont> artFonts = config3 != null ? config3.getArtFonts() : null;
if (artFonts == null) {
artFonts = CollectionsKt__CollectionsKt.emptyList();
}
if ((!titles.isEmpty()) || (true ^ artFonts.isEmpty())) {
EffectTextTitle effectTextTitle = (EffectTextTitle) CollectionsKt___CollectionsKt.firstOrNull((List) titles);
if (effectTextTitle != null) {
EffectTextViewModel.m.c(effectTextTitle, stickerBean);
}
EffectTextArtFont effectTextArtFont = (EffectTextArtFont) CollectionsKt___CollectionsKt.firstOrNull((List) artFonts);
if (effectTextArtFont != null) {
EffectTextViewModel.m.b(effectTextArtFont, stickerBean);
}
e(stickerBean);
eVar = e.just(stickerBean);
} else {
int type = stickerBean.getType();
if (type == 3) {
TextStickerStyle config4 = stickerBean.getConfig();
if (!(config4 == null || (poiSticker = config4.getPoiSticker()) == null || (fonts = poiSticker.getFonts()) == null)) {
fonts4 = (Fonts) CollectionsKt___CollectionsKt.firstOrNull((List) fonts);
}
} else if (type == 4) {
TextStickerStyle config5 = stickerBean.getConfig();
if (!(config5 == null || (nameSticker = config5.getNameSticker()) == null || (fonts2 = nameSticker.getFonts()) == null)) {
fonts4 = (Fonts) CollectionsKt___CollectionsKt.firstOrNull((List) fonts2);
}
} else if (!(type != 11 || (config = stickerBean.getConfig()) == null || (timeSticker = config.getTimeSticker()) == null || (fonts3 = timeSticker.getFonts()) == null)) {
fonts4 = (Fonts) CollectionsKt___CollectionsKt.firstOrNull((List) fonts3);
}
if (fonts4 != null) {
eVar = e.create(new EffectTextStickerTask$buildRequestTextDetailObservable$3(this, fonts4, stickerBean));
} else {
eVar = e.just(stickerBean);
}
}
}
return eVar.flatMap(new b(this));
}
public final float c(float f12) {
Object[] objArr = {new Float(f12)};
ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
Class cls = Float.TYPE;
PatchProxyResult proxy = PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 51579, new Class[]{cls}, cls);
if (proxy.isSupported) {
return ((Float) proxy.result).floatValue();
}
if (f12 >= o5.i.f36333a && f12 <= 1.0f) {
return f12;
}
if (f12 <= 1.0f || f12 > 100.0f) {
return 1.0f;
}
return f12 / 100.0f;
}
public final List<Integer> d(String str) {
PatchProxyResult proxy = PatchProxy.proxy(new Object[]{str}, this, changeQuickRedirect, false, 51578, new Class[]{String.class}, List.class);
if (proxy.isSupported) {
return (List) proxy.result;
}
if (str != null) {
try {
if (str.length() > 0) {
int parseColor = Color.parseColor(str);
return CollectionsKt__CollectionsKt.listOf((Object[]) new Integer[]{Integer.valueOf((16711680 & parseColor) >> 16), Integer.valueOf((65280 & parseColor) >> 8), Integer.valueOf(parseColor & MotionEventCompat.ACTION_MASK)});
}
} catch (Exception e6) {
e6.printStackTrace();
}
}
return null;
}
public final void e(StickerBean stickerBean) {
String str;
String str2;
String str3;
TimeSticker timeSticker;
if (!PatchProxy.proxy(new Object[]{stickerBean}, this, changeQuickRedirect, false, 51573, new Class[]{StickerBean.class}, Void.TYPE).isSupported) {
int type = stickerBean.getType();
if (type == 3) {
stickerBean.setTextBean("", LocationStickerView.G.a(stickerBean));
} else if (type == 4) {
PatchProxyResult proxy = PatchProxy.proxy(new Object[]{stickerBean}, NicknameStickerView.G, NicknameStickerView.a.changeQuickRedirect, false, 111391, new Class[]{StickerBean.class}, String.class);
if (proxy.isSupported) {
str = (String) proxy.result;
} else {
str = ServiceManager.d().getName();
}
stickerBean.setTextBean("", str);
} else if (type == 11) {
if (stickerBean.getTime() == null) {
TimeStickerView.a aVar = TimeStickerView.G;
PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{stickerBean}, aVar, TimeStickerView.a.changeQuickRedirect, false, 111418, new Class[]{StickerBean.class}, String.class);
if (proxy2.isSupported) {
str2 = (String) proxy2.result;
} else {
try {
TextStickerStyle config = stickerBean.getConfig();
if (config == null || (timeSticker = config.getTimeSticker()) == null || (str3 = timeSticker.getTimeFormat()) == null) {
str3 = "yyyy年MM月dd日 HH时mm分ss秒 EEEE";
}
str2 = aVar.a(str3, new SimpleDateFormat(aVar.b(str3)).format(new GregorianCalendar().getTime()));
} catch (Exception e6) {
e6.printStackTrace();
str2 = "";
}
}
stickerBean.setTextBean("", str2);
return;
}
StickerTimeBean time = stickerBean.getTime();
String timeStr = time != null ? time.getTimeStr() : null;
if (timeStr == null) {
timeStr = "";
}
stickerBean.setTextBean("", timeStr);
}
}
}
@Override // com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper.IStickerTask
public void hideLoadingDialog(@Nullable FragmentManager fragmentManager) {
if (!PatchProxy.proxy(new Object[]{fragmentManager}, this, changeQuickRedirect, false, 51583, new Class[]{FragmentManager.class}, Void.TYPE).isSupported) {
PublishStickerHelper.IStickerTask.a.a(this, fragmentManager);
PublishLoadDialogFragment.F.a(fragmentManager);
}
}
@Override // com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper.IStickerTask
public void onDestroy() {
if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 51584, new Class[0], Void.TYPE).isSupported) {
PublishStickerHelper.IStickerTask.a.b(this);
this.f10472a = null;
a().clearForeverObservers();
TextEffect b2 = b();
if (b2 != null) {
b2.destroy();
}
}
}
@Override // com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper.IStickerTask
public void onFinish(@NotNull StickerBean stickerBean) {
if (!PatchProxy.proxy(new Object[]{stickerBean}, this, changeQuickRedirect, false, 51586, new Class[]{StickerBean.class}, Void.TYPE).isSupported) {
PublishStickerHelper.IStickerTask.a.c(this, stickerBean);
}
}
@Override // com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper.IStickerTask
public void onStart(@NotNull StickerBean stickerBean) {
if (!PatchProxy.proxy(new Object[]{stickerBean}, this, changeQuickRedirect, false, 51585, new Class[]{StickerBean.class}, Void.TYPE).isSupported) {
PublishStickerHelper.IStickerTask.a.d(this, stickerBean);
}
}
@Override // com.shizhuang.duapp.media.sticker.helper.PublishStickerHelper.IStickerTask
public void showLoadingDialog(@NotNull StickerBean stickerBean, @Nullable FragmentManager fragmentManager, @NotNull Disposable disposable) {
String str;
PublishLoadDialogFragment b2;
if (!PatchProxy.proxy(new Object[]{stickerBean, fragmentManager, disposable}, this, changeQuickRedirect, false, 51582, new Class[]{StickerBean.class, FragmentManager.class, Disposable.class}, Void.TYPE).isSupported) {
PublishStickerHelper.IStickerTask.a.e(this, stickerBean, fragmentManager, disposable);
TextStickerStyle config = stickerBean.getConfig();
if (config != null) {
TextStickerStyle config2 = stickerBean.getConfig();
String str2 = null;
List<EffectTextTitle> titles = config2 != null ? config2.getTitles() : null;
if (titles == null) {
titles = CollectionsKt__CollectionsKt.emptyList();
}
TextStickerStyle config3 = stickerBean.getConfig();
List<EffectTextArtFont> artFonts = config3 != null ? config3.getArtFonts() : null;
if (artFonts == null) {
artFonts = CollectionsKt__CollectionsKt.emptyList();
}
boolean z = (titles.isEmpty() ^ true) || (artFonts.isEmpty() ^ true);
String fontUrl = config.getFontUrl();
String str3 = "";
if (fontUrl == null) {
fontUrl = str3;
}
if (fontUrl.length() == 0) {
fontUrl = "https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf";
}
if (config.getColorType() != 2 || config.getTextTexture() == null || (str = config.getTextTexture()) == null) {
str = str3;
}
if (config.getBackgroundConfig() != null) {
BackgroundConfig backgroundConfig = config.getBackgroundConfig();
if (backgroundConfig != null) {
str2 = backgroundConfig.getBackgroundUrl();
}
if (str2 != null) {
str3 = str2;
}
}
boolean x = tl.a.x("https://cdn.poizon.com/node-common/b7de77d19e74232e84e26c816c56af18.ttf");
boolean x4 = tl.a.x("https://cdn.poizon.com/node-common/ef524a633553b91eaa2094647903c447.ttf");
boolean x12 = tl.a.x(fontUrl);
boolean x13 = str.length() > 0 ? tl.a.x(str) : true;
boolean x14 = str3.length() > 0 ? tl.a.x(str3) : true;
if ((!z || !x || !x4 || !x12 || !x13 || !x14) && (b2 = PublishLoadDialogFragment.F.b(fragmentManager, "字体下载中...", true)) != null) {
EffectTextStickerTask$showLoadingDialog$1 effectTextStickerTask$showLoadingDialog$1 = new EffectTextStickerTask$showLoadingDialog$1(disposable);
if (!PatchProxy.proxy(new Object[]{effectTextStickerTask$showLoadingDialog$1}, b2, PublishLoadDialogFragment.changeQuickRedirect, false, 99466, new Class[]{Function0.class}, Void.TYPE).isSupported) {
b2.D = effectTextStickerTask$showLoadingDialog$1;
}
}
}
}
}
}