package com.ss.android.ugc.aweme.ecommerce.pdp.vh.desc;

import X.0CB;
import X.0CG;
import X.0CH;
import X.1hK;
import X.2ha;
import X.3EX;
import X.3SB;
import X.3SM;
import X.4r1;
import X.6Is;
import X.7df;
import X.8Yn;
import X.C6348CYe;
import X.C6372CZc;
import X.C6373CZd;
import X.C6376CZg;
import X.C6519Cbz;
import X.CBZ;
import X.COU;
import X.CP0;
import X.CYC;
import X.CYE;
import X.CYF;
import X.CZW;
import X.CZZ;
import X.Crj;
import X.DV0;
import X.F1s;
import X.Lea;
import X.M12;
import X.QHW;
import X.QJt;
import X.T5W;
import X.T6A;
import X.Tlt;
import android.app.Dialog;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.ecommerce.api.model.Video;
import com.ss.android.ugc.aweme.ecommerce.api.model.VideoInfo;
import com.ss.android.ugc.aweme.ecommerce.pdp.PdpFullFragment;
import com.ss.android.ugc.aweme.ecommerce.pdp.PdpViewModel;
import com.ss.android.ugc.aweme.ecommerce.pdp.vh.AbsBrickFullSpanVH;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class ProductDescVideoViewHolder extends AbsBrickFullSpanVH<COU> implements 6Is {
    public static final C6376CZg LJIIL = new C6376CZg((byte) 0);
    public final Tlt LJFF;
    public Aweme LJI;
    public T5W LJIIIZ;
    public final 0CG LJIIJ = new ProductDescVideoViewHolder$observer$1(this);
    public final Fragment LJIIJJI;
    public final Crj LJIILIIL;
    public boolean LJIILJJIL;
    public CZW LJIILL = new CZW(this);

    static {
        Covode.recordClassIndex(71707);
    }

    public final PdpViewModel LJIILIIL() {
        return (PdpViewModel) this.LJIILIIL.getValue();
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final void LJIIIZ() {
        ProductDescVideoViewHolder.super.LJIIIZ();
        this.LJIIJJI.getLifecycle().LIZIZ(this.LJIIJ);
    }

    public final void LJ() {
        super.LJ();
        DV0.LIZ(this, LJIILIIL(), CP0.LIZ, new CZZ(this));
        this.LJIIJJI.getLifecycle().LIZ(this.LJIIJ);
    }

    public final boolean LIZ(View view) {
        M12.LIZ(view);
        Rect rect = new Rect();
        view.getLocalVisibleRect(rect);
        int i = (rect.bottom - rect.top) * (rect.right - rect.left);
        Rect LIZLLL = C6519Cbz.LIZLLL(view);
        if (((float) LIZLLL.top) + (((float) LIZLLL.height()) / 2.0f) < ((float) 3SM.LIZIZ) / 2.0f) {
            i -= LIZLLL.width() * 2ha.LIZ(44.0d);
        }
        if (i >= (view.getMeasuredHeight() * view.getMeasuredWidth()) / 2) {
            return false;
        }
        return true;
    }

    /* access modifiers changed from: private */
    public void LIZ(COU cou) {
        String str;
        int i;
        int i2;
        int i3;
        int i4;
        Window window;
        ViewGroup viewGroup;
        Window window2;
        ViewGroup viewGroup2;
        VideoInfo videoInfo;
        Integer num;
        VideoInfo videoInfo2;
        Integer num2;
        VideoInfo videoInfo3;
        Integer num3;
        VideoInfo videoInfo4;
        M12.LIZ(cou);
        super.LIZ(cou);
        Video video = cou.LIZIZ;
        Aweme aweme = new Aweme();
        com.ss.android.ugc.aweme.feed.model.Video video2 = new com.ss.android.ugc.aweme.feed.model.Video();
        8Yn r2 = new 8Yn();
        r2.setSourceId(video.LIZ);
        List<VideoInfo> list = video.LJ;
        if (list == null || (videoInfo4 = (VideoInfo) Lea.LIZIZ(list, 0)) == null) {
            str = null;
        } else {
            str = videoInfo4.LIZ;
        }
        r2.setUri(str);
        r2.setUrlList(new ArrayList());
        r2.getUrlList().add(r2.getUri());
        r2.setUrlKey(video.LIZ);
        video2.setPlayAddr(r2);
        UrlModel urlModel = new UrlModel();
        urlModel.setUri(video.LIZJ);
        urlModel.setUrlList(new ArrayList());
        urlModel.getUrlList().add(urlModel.getUri());
        video2.setCover(urlModel);
        List<VideoInfo> list2 = video.LJ;
        if (list2 == null || (videoInfo3 = (VideoInfo) Lea.LIZIZ(list2, 0)) == null || (num3 = videoInfo3.LIZLLL) == null) {
            i = 0;
        } else {
            i = num3.intValue();
        }
        video2.setWidth(i);
        List<VideoInfo> list3 = video.LJ;
        if (list3 == null || (videoInfo2 = (VideoInfo) Lea.LIZIZ(list3, 0)) == null || (num2 = videoInfo2.LJ) == null) {
            i2 = 0;
        } else {
            i2 = num2.intValue();
        }
        video2.setHeight(i2);
        Double d = video.LIZIZ;
        if (d != null) {
            i3 = (int) d.doubleValue();
        } else {
            i3 = 0;
        }
        video2.setVideoLength(i3);
        video2.setPlayAddrBytevc1(video2.getPlayAddr());
        aweme.setVideo(video2);
        aweme.setAid(video.LIZ);
        this.LJI = aweme;
        com.ss.android.ugc.aweme.feed.model.Video video3 = aweme.getVideo();
        if (video3 != null) {
            Tlt tlt = this.LJFF;
            List<VideoInfo> list4 = cou.LIZIZ.LJ;
            if (list4 == null || (videoInfo = (VideoInfo) Lea.LIZIZ(list4, 0)) == null || (num = videoInfo.LJIIIIZZ) == null) {
                i4 = 0;
            } else {
                i4 = num.intValue();
            }
            M12.LIZ(video3);
            tlt.LIZLLL = video3;
            tlt.LJ = i4;
            Tlt tlt2 = this.LJFF;
            Aweme aweme2 = this.LJI;
            7df r0 = tlt2.LJI;
            if (r0 != null) {
                r0.LIZ(aweme2);
            }
            new C6373CZd();
            C6373CZd cZd = new C6373CZd();
            cZd.LIZ = this.LJFF;
            cZd.LIZLLL = new T6A(video3.getWidth(), video3.getHeight());
            cZd.LJ = Integer.valueOf(video3.getVideoLength());
            cZd.LJI = this.LJIILL;
            Fragment fragment = this.LJIIJJI;
            if (fragment instanceof PdpFullFragment) {
                1hK activity = fragment.getActivity();
                if (activity != null) {
                    window2 = activity.getWindow();
                } else {
                    window2 = null;
                }
                cZd.LIZJ = window2;
                1hK activity2 = this.LJIIJJI.getActivity();
                if (activity2 != null) {
                    viewGroup2 = (ViewGroup) activity2.findViewById(16908290);
                } else {
                    viewGroup2 = null;
                }
                cZd.LIZIZ = viewGroup2;
            } else if (fragment instanceof DialogFragment) {
                if (!(fragment instanceof DialogFragment)) {
                    fragment = null;
                }
                DialogFragment dialogFragment = (DialogFragment) fragment;
                if (dialogFragment != null) {
                    Dialog dialog = dialogFragment.getDialog();
                    if (dialog != null) {
                        window = dialog.getWindow();
                    } else {
                        window = null;
                    }
                    cZd.LIZJ = window;
                    Dialog dialog2 = dialogFragment.getDialog();
                    if (dialog2 != null) {
                        viewGroup = (ViewGroup) dialog2.findViewById(16908290);
                    } else {
                        viewGroup = null;
                    }
                    cZd.LIZIZ = viewGroup;
                }
            }
            QJt LIZ = QHW.LIZ(3EX.LIZ(video3.getCover()));
            View view = this.itemView;
            n.LIZIZ(view, "");
            LIZ.LIZIZ = view.getContext();
            LIZ.LJIJJ = Bitmap.Config.ARGB_8888;
            LIZ.LIZ(new C6372CZc(cZd, this, cou));
            T5W t5w = this.LJIIIZ;
            if (t5w != null) {
                t5w.setParams(cZd);
            }
        }
        if (cou.LIZJ) {
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            F1s.LIZIZ(view2.findViewById(2131372933));
            if (!this.LJIILJJIL) {
                this.LJIILJJIL = true;
                View view3 = this.itemView;
                n.LIZIZ(view3, "");
                FrameLayout frameLayout = (FrameLayout) view3.findViewById(2131372933);
                n.LIZIZ(frameLayout, "");
                CBZ.LIZ(frameLayout, new C6348CYe(), CYF.LIZ, CYE.LIZ);
            }
            View view4 = this.itemView;
            n.LIZIZ(view4, "");
            FrameLayout frameLayout2 = (FrameLayout) view4.findViewById(2131372933);
            n.LIZIZ(frameLayout2, "");
            3SB.LIZ(frameLayout2, (0CH) null, 0, new CYC(this, (4r1) null), 3);
            return;
        }
        View view5 = this.itemView;
        n.LIZIZ(view5, "");
        F1s.LIZ(view5.findViewById(2131372933));
    }

    /* JADX WARNING: Illegal instructions before constructor call */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public ProductDescVideoViewHolder(android.view.ViewGroup r4, androidx.fragment.app.Fragment r5) {
        /*
            r3 = this;
            X.M12.LIZ(r4, r5)
            android.content.Context r2 = r4.getContext()
            r1 = 2131559128(0x7f0d02d8, float:1.8743591E38)
            r0 = 0
            android.view.View r0 = X.C6489CbV.LIZ(r2, r1, r4, r0)
            java.lang.String r2 = ""
            kotlin.h.b.n.LIZIZ(r0, r2)
            r3.<init>(r0)
            r3.LJIIJJI = r5
            java.lang.Class<com.ss.android.ugc.aweme.ecommerce.pdp.PdpViewModel> r1 = com.ss.android.ugc.aweme.ecommerce.pdp.PdpViewModel.class
            X.KEN r0 = X.KEM.LIZ
            X.D1G r1 = r0.LIZ(r1)
            X.BHn r0 = new X.BHn
            r0.<init>(r3, r1, r1)
            X.Crj r0 = X.7he.LIZ(r0)
            r3.LJIILIIL = r0
            android.view.View r1 = r3.itemView
            kotlin.h.b.n.LIZIZ(r1, r2)
            r0 = 2131371704(0x7f0a26b8, float:1.836345E38)
            android.view.View r1 = r1.findViewById(r0)
            X.T5W r1 = (X.T5W) r1
            X.Tlt r0 = new X.Tlt
            kotlin.h.b.n.LIZIZ(r1, r2)
            r0.<init>(r1)
            r3.LJFF = r0
            r3.LJIIIZ = r1
            com.ss.android.ugc.aweme.ecommerce.pdp.vh.desc.ProductDescVideoViewHolder$observer$1 r0 = new com.ss.android.ugc.aweme.ecommerce.pdp.vh.desc.ProductDescVideoViewHolder$observer$1
            r0.<init>(r3)
            r3.LJIIJ = r0
            X.CZW r0 = new X.CZW
            r0.<init>(r3)
            r3.LJIILL = r0
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ecommerce.pdp.vh.desc.ProductDescVideoViewHolder.<init>(android.view.ViewGroup, androidx.fragment.app.Fragment):void");
    }
}
