得物.apk(点击下载) / LiveMp4AnimLoader.java


package com.shizhuang.duapp.modules.live.common.pkmic;

import a.f;
import android.annotation.SuppressLint;
import android.widget.FrameLayout;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProviders;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.libs.animation.DuAnimationView;
import com.shizhuang.duapp.modules.live.anchor.detail.LiveAnchorViewModel;
import com.shizhuang.duapp.modules.live.common.interaction.gift.mp4.LiveGiftPreLoader;
import com.shizhuang.duapp.modules.live.common.interaction.gift.mp4.LiveVideoView;
import fo.a;
import java.lang.ref.SoftReference;
import kotlin.text.StringsKt__StringsJVMKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@SuppressLint({"StaticFieldLeak"})
/* compiled from: LiveMp4AnimLoader.kt */
public final class LiveMp4AnimLoader {
    @NotNull

    /* renamed from: a  reason: collision with root package name */
    public static final LiveMp4AnimLoader f18419a = new LiveMp4AnimLoader();
    public static ChangeQuickRedirect changeQuickRedirect;
    private static LiveGiftPreLoader preLoader = new LiveGiftPreLoader("pkanim/");

    public final void a(@Nullable LiveVideoView liveVideoView, @NotNull FrameLayout frameLayout) {
        if (!PatchProxy.proxy(new Object[]{liveVideoView, frameLayout}, this, changeQuickRedirect, false, 199367, new Class[]{LiveVideoView.class, FrameLayout.class}, Void.TYPE).isSupported && liveVideoView != null) {
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
            if (liveVideoView.getParent() != null) {
                a.i("the specified child [" + liveVideoView + "] already has a parent. You must call removeView() on the child's parent first.", new Object[0]);
                return;
            }
            frameLayout.addView(liveVideoView, layoutParams);
        }
    }

    @NotNull
    public final <VH extends VideoViewHolder> VH b(@NotNull FragmentActivity fragmentActivity, @NotNull Class<VH> cls) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{fragmentActivity, cls}, this, changeQuickRedirect, false, 199365, new Class[]{FragmentActivity.class, Class.class}, VideoViewHolder.class);
        if (proxy.isSupported) {
            return (VH) ((VideoViewHolder) proxy.result);
        }
        VH newInstance = cls.newInstance();
        if (!PatchProxy.proxy(new Object[]{fragmentActivity}, newInstance, VideoViewHolder.changeQuickRedirect, false, 199398, new Class[]{FragmentActivity.class}, Void.TYPE).isSupported) {
            LiveAnchorViewModel liveAnchorViewModel = (LiveAnchorViewModel) ViewModelProviders.of(fragmentActivity).get(LiveAnchorViewModel.class);
        }
        return newInstance;
    }

    public final void c(@NotNull LifecycleOwner lifecycleOwner) {
        if (!PatchProxy.proxy(new Object[]{lifecycleOwner}, this, changeQuickRedirect, false, 199364, new Class[]{LifecycleOwner.class}, Void.TYPE).isSupported) {
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 199375, new Class[0], Void.TYPE).isSupported) {
                if (!preLoader.e("https://apk.poizon.com/duApp/Android_Config/live/pk/pkbegin.mp4")) {
                    LiveGiftPreLoader.f(preLoader, "https://apk.poizon.com/duApp/Android_Config/live/pk/pkbegin.mp4", null, null, 6);
                }
                if (!preLoader.e("https://apk.poizon.com/duApp/Android_Config/live/pk/pkwin.mp4")) {
                    LiveGiftPreLoader.f(preLoader, "https://apk.poizon.com/duApp/Android_Config/live/pk/pkwin.mp4", null, null, 6);
                }
                if (!preLoader.e("https://apk.poizon.com/duApp/Android_Config/resource/live/vap/qixiMagpieBridgeLantern1a.mp4")) {
                    LiveGiftPreLoader.f(preLoader, "https://apk.poizon.com/duApp/Android_Config/resource/live/vap/qixiMagpieBridgeLantern1a.mp4", null, null, 6);
                }
                if (!preLoader.e("https://apk.poizon.com/duApp/Android_Config/resource/live/vap/qixiMagpieBridgeLantern2.mp4")) {
                    LiveGiftPreLoader.f(preLoader, "https://apk.poizon.com/duApp/Android_Config/resource/live/vap/qixiMagpieBridgeLantern2.mp4", null, null, 6);
                }
            }
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 199376, new Class[0], Void.TYPE).isSupported && !preLoader.e("https://apk.poizon.com/duApp/Android_Config/resource/live/vap/anchorStickerGuideVideo.mp4")) {
                LiveGiftPreLoader.f(preLoader, "https://apk.poizon.com/duApp/Android_Config/resource/live/vap/anchorStickerGuideVideo.mp4", null, null, 6);
            }
        }
    }

    public final void d(String str, DuAnimationView duAnimationView) {
        if (!PatchProxy.proxy(new Object[]{str, duAnimationView}, this, changeQuickRedirect, false, 199369, new Class[]{String.class, DuAnimationView.class}, Void.TYPE).isSupported) {
            String c5 = preLoader.c(str);
            String b = preLoader.b();
            duAnimationView.f(b + c5);
            duAnimationView.s();
        }
    }

    public final void e(LiveVideoView liveVideoView, String str, int i, int i3) {
        Object[] objArr = {liveVideoView, str, new Integer(i), new Integer(i3)};
        ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
        Class cls = Integer.TYPE;
        if (!PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 199372, new Class[]{LiveVideoView.class, String.class, cls, cls}, Void.TYPE).isSupported) {
            Boolean bool = null;
            if (f(liveVideoView, str, i, i3)) {
                StringBuilder h12 = f.h("七夕动画==> loadMp4FromDiskCache:isPlaying=");
                if (liveVideoView != null) {
                    bool = Boolean.valueOf(liveVideoView.e());
                }
                h12.append(bool);
                h12.append(" effectUrl=");
                h12.append(str);
                h12.append(' ');
                a.h(h12.toString(), new Object[0]);
                return;
            }
            SoftReference softReference = new SoftReference(liveVideoView);
            if (!PatchProxy.proxy(new Object[]{softReference, str, new Integer(i), new Integer(i3)}, this, changeQuickRedirect, false, 199374, new Class[]{SoftReference.class, String.class, cls, cls}, Void.TYPE).isSupported) {
                if (StringsKt__StringsJVMKt.startsWith$default(str, "http", false, 2, null) || StringsKt__StringsJVMKt.startsWith$default(str, "https", false, 2, null)) {
                    LiveGiftPreLoader.f(preLoader, str, new LiveMp4AnimLoader$loadMp4FromNetwork$1(softReference, i, i3, str), null, 4);
                }
            }
        }
    }

    public final boolean f(LiveVideoView liveVideoView, String str, int i, int i3) {
        String c5;
        String b;
        Object[] objArr = {liveVideoView, str, new Integer(i), new Integer(i3)};
        ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
        Class cls = Integer.TYPE;
        PatchProxyResult proxy = PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 199373, new Class[]{LiveVideoView.class, String.class, cls, cls}, Boolean.TYPE);
        if (proxy.isSupported) {
            return ((Boolean) proxy.result).booleanValue();
        }
        if (!preLoader.e(str) || (c5 = preLoader.c(str)) == null || (b = preLoader.b()) == null) {
            return false;
        }
        if (liveVideoView != null) {
            liveVideoView.f(b + c5, 1);
        }
        return true;
    }

    public final void g(@Nullable LiveVideoView liveVideoView, @Nullable String str, int i, int i3) {
        boolean z = false;
        Object[] objArr = {liveVideoView, str, new Integer(i), new Integer(i3)};
        ChangeQuickRedirect changeQuickRedirect2 = changeQuickRedirect;
        Class cls = Integer.TYPE;
        if (!PatchProxy.proxy(objArr, this, changeQuickRedirect2, false, 199370, new Class[]{LiveVideoView.class, String.class, cls, cls}, Void.TYPE).isSupported) {
            if (str.length() == 0) {
                z = true;
            }
            if (!z) {
                if (liveVideoView == null || !liveVideoView.e()) {
                    e(liveVideoView, str, i, i3);
                }
            }
        }
    }

    public final void h(@NotNull String str, @NotNull DuAnimationView duAnimationView) {
        if (PatchProxy.proxy(new Object[]{str, duAnimationView}, this, changeQuickRedirect, false, 199368, new Class[]{String.class, DuAnimationView.class}, Void.TYPE).isSupported || duAnimationView.i()) {
            return;
        }
        if (!StringsKt__StringsJVMKt.startsWith$default(str, "http", false, 2, null) && !StringsKt__StringsJVMKt.startsWith$default(str, "https", false, 2, null)) {
            return;
        }
        if (!preLoader.e(str)) {
            LiveGiftPreLoader.f(preLoader, str, new LiveMp4AnimLoader$playStickerGuide$1(duAnimationView), null, 4);
        } else {
            d(str, duAnimationView);
        }
    }
}