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


package com.shizhuang.duapp.modules.live.audience.commentate.component;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.view.ViewGroupKt;
import androidx.lifecycle.LifecycleOwner;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.R;
import com.shizhuang.duapp.common.extension.ViewExtensionKt;
import com.shizhuang.duapp.common.view.AvatarLayout;
import com.shizhuang.duapp.libs.network.request.DuHttpRequest;
import com.shizhuang.duapp.modules.live.anchor.livecenter.marktagnew.IndicatorSeekBarNew;
import com.shizhuang.duapp.modules.live.audience.commentate.fragment.LiveCommentateNewFragment;
import com.shizhuang.duapp.modules.live.audience.commentate.model.TodayHotRecommendModel;
import com.shizhuang.duapp.modules.live.audience.commentate.view.TodayHotRecommendView;
import com.shizhuang.duapp.modules.live.audience.commentate.viewmodel.CommentateItemViewModel;
import com.shizhuang.duapp.modules.live.audience.commentate.widget.LiveCommentateListViewNew;
import com.shizhuang.duapp.modules.live.audience.commentate.widget.TouchDelegateView;
import com.shizhuang.duapp.modules.live.common.component.BaseLiveComponent;
import com.shizhuang.duapp.modules.live.common.extensions.ExtensionsKt;
import com.shizhuang.duapp.modules.live.common.model.LiveItemModel;
import com.shizhuang.duapp.modules.live.common.model.live.KolModel;
import com.shizhuang.duapp.modules.live.common.model.live.LiveRoom;
import com.shizhuang.duapp.modules.live.common.model.live.LiveRoomUserInfo;
import com.shizhuang.duapp.modules.live.common.model.live.RoomDetailModel;
import com.shizhuang.duapp.modules.live.common.model.product.LiveCameraProductModel;
import com.shizhuang.duapp.modules.live.common.widget.LiveAvatarLayout;
import com.shizhuang.duapp.modules.live.common.widget.LiveViewV3;
import df.o0;
import df.r0;
import ip.c;
import ip.j;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.jvm.internal.Ref;
import ln0.e;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import qk0.a;

@Metadata(bv = {}, d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lcom/shizhuang/duapp/modules/live/audience/commentate/component/CommentateUiComponent;", "Lcom/shizhuang/duapp/modules/live/common/component/BaseLiveComponent;", "du_live_release"}, k = 1, mv = {1, 4, 2})
/* compiled from: CommentateUiComponent.kt */
public final class CommentateUiComponent extends BaseLiveComponent {
    public static ChangeQuickRedirect changeQuickRedirect;

    /* renamed from: g  reason: collision with root package name */
    public final LiveItemModel f17764g;

    /* renamed from: h  reason: collision with root package name */
    public boolean f17765h;
    public final List<Integer> i = CollectionsKt__CollectionsKt.mutableListOf(Integer.valueOf(((ImageView) g(R.id.share)).getId()), Integer.valueOf(((ImageView) g(R.id.quit)).getId()), Integer.valueOf(((TextView) g(R.id.tvTime)).getId()), Integer.valueOf(((ConstraintLayout) g(R.id.seekLayout)).getId()), Integer.valueOf(((RelativeLayout) g(R.id.backLiveLayout)).getId()), Integer.valueOf(((ImageView) g(R.id.fullScreen)).getId()), Integer.valueOf(((TouchDelegateView) g(R.id.touchDelegateView)).getId()), Integer.valueOf(g(R.id.pauseView).getId()));
    public final List<View> j = CollectionsKt__CollectionsKt.mutableListOf((ConstraintLayout) g(R.id.seekLayout), (TextView) g(R.id.tvTime), (TextView) g(R.id.tvCurrentTag), (ImageView) g(R.id.fullScreen), (TouchDelegateView) g(R.id.touchDelegateView), g(R.id.pauseView));
    @Nullable
    public final View k;
    public final CommentateItemViewModel l;
    public final LiveCommentateNewFragment m;
    public final a n;
    public HashMap o;

    public CommentateUiComponent(@Nullable View view, @NotNull CommentateItemViewModel commentateItemViewModel, @NotNull LiveCommentateNewFragment liveCommentateNewFragment, @NotNull a aVar) {
        super(null, 1);
        this.k = view;
        this.l = commentateItemViewModel;
        this.m = liveCommentateNewFragment;
        this.n = aVar;
        this.f17764g = liveCommentateNewFragment.p();
    }

    public View g(int i3) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{new Integer(i3)}, this, changeQuickRedirect, false, 185656, new Class[]{Integer.TYPE}, View.class);
        if (proxy.isSupported) {
            return (View) proxy.result;
        }
        if (this.o == null) {
            this.o = new HashMap();
        }
        View view = (View) this.o.get(Integer.valueOf(i3));
        if (view != null) {
            return view;
        }
        View containerView = getContainerView();
        if (containerView == null) {
            return null;
        }
        View findViewById = containerView.findViewById(i3);
        this.o.put(Integer.valueOf(i3), findViewById);
        return findViewById;
    }

    @Override // kotlinx.android.extensions.LayoutContainer, com.shizhuang.duapp.modules.live.common.component.BaseLiveComponent
    @Nullable
    public View getContainerView() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185655, new Class[0], View.class);
        return proxy.isSupported ? (View) proxy.result : this.k;
    }

    public final void h() {
        LiveRoom liveRoom;
        LiveRoom liveRoom2;
        KolModel kolModel;
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185646, new Class[0], Void.TYPE).isSupported) {
            RoomDetailModel value = this.l.getRoomDetailModel().getValue();
            LiveRoomUserInfo liveRoomUserInfo = (value == null || (liveRoom2 = value.room) == null || (kolModel = liveRoom2.kol) == null) ? null : kolModel.userInfo;
            AvatarLayout avatarLayout = ((LiveAvatarLayout) g(R.id.avatar)).getAvatarLayout();
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) avatarLayout.getLayoutParams();
            int a5 = e.a(Float.valueOf(32.0f));
            marginLayoutParams.width = a5;
            marginLayoutParams.height = a5;
            avatarLayout.setLayoutParams(marginLayoutParams);
            if (liveRoomUserInfo != null) {
                ((TextView) g(R.id.kolName)).setText(liveRoomUserInfo.userName);
                RoomDetailModel value2 = this.l.getRoomDetailModel().getValue();
                if (value2 == null || (liveRoom = value2.room) == null || !liveRoom.isLiving) {
                    LiveAvatarLayout liveAvatarLayout = (LiveAvatarLayout) g(R.id.avatar);
                    liveAvatarLayout.setBorder(true);
                    liveAvatarLayout.setBorderColor((int) 4294967295L);
                    liveAvatarLayout.setBorderWidth(e.a(Float.valueOf(1.5f)));
                    liveAvatarLayout.h(liveRoomUserInfo.icon, liveRoomUserInfo.vIcon, "", liveRoomUserInfo.nIcon);
                    liveAvatarLayout.f(false);
                    liveAvatarLayout.j(false);
                    return;
                }
                ((LiveAvatarLayout) g(R.id.avatar)).getAvatarLayout().setBorder(false);
                ((LiveAvatarLayout) g(R.id.avatar)).h(liveRoomUserInfo.icon, "", "https://apk.poizon.com/duApp/Android_Config/resource/live/img/du_live_animate_avater.webp", "");
                ((LiveAvatarLayout) g(R.id.avatar)).f(true);
                ((LiveAvatarLayout) g(R.id.avatar)).j(true);
            }
        }
    }

    public final void i(View view) {
        if (!PatchProxy.proxy(new Object[]{view}, this, changeQuickRedirect, false, 185654, new Class[]{View.class}, Void.TYPE).isSupported) {
            ExtensionsKt.a(this, 300, new CommentateUiComponent$checkToAutoPopupProductDetailPage$1(this, view));
        }
    }

    public final void j() {
        LiveRoom liveRoom;
        boolean z = false;
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185642, new Class[0], Void.TYPE).isSupported) {
            String obj = ((TextView) g(R.id.desc)).getText().toString();
            if (!PatchProxy.proxy(new Object[]{obj}, this, changeQuickRedirect, false, 185644, new Class[]{String.class}, Void.TYPE).isSupported) {
                if (!(obj == null || obj.length() == 0)) {
                    o0.b("live_common_exposure", new CommentateUiComponent$uploadDescExposure$1(this, obj));
                }
            }
            String obj2 = ((TextView) g(R.id.tvLiveCenterEntrance)).getText().toString();
            if (!PatchProxy.proxy(new Object[]{obj2}, this, changeQuickRedirect, false, 185645, new Class[]{String.class}, Void.TYPE).isSupported) {
                o0.b("live_common_exposure", new CommentateUiComponent$uploadLiveCenterExposure$1(this, obj2));
            }
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185643, new Class[0], Void.TYPE).isSupported) {
                RoomDetailModel roomDetail = this.l.getRoomDetail();
                if (!(roomDetail == null || (liveRoom = roomDetail.room) == null || !liveRoom.isLiving)) {
                    z = true;
                }
                o0.b("live_common_exposure", new CommentateUiComponent$uploadAvatarExposure$1(this, z));
            }
        }
    }

    public final Context k() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185648, new Class[0], Context.class);
        if (proxy.isSupported) {
            return (Context) proxy.result;
        }
        View containerView = getContainerView();
        if (containerView != null) {
            return containerView.getContext();
        }
        return null;
    }

    public final void l() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185638, new Class[0], Void.TYPE).isSupported) {
            CommentateItemViewModel commentateItemViewModel = this.l;
            commentateItemViewModel.setFullScreen(!commentateItemViewModel.isFullScreen());
            if (this.l.isFullScreen()) {
                ((ImageView) g(R.id.fullScreen)).setImageResource(R.drawable.icon_commentate_full_screen_quit);
                for (View view : ViewGroupKt.getChildren((ConstraintLayout) g(R.id.commentateContainerLayout))) {
                    if (!this.i.contains(Integer.valueOf(view.getId())) && view.getVisibility() == 0) {
                        view.setVisibility(4);
                    }
                }
                return;
            }
            ((ImageView) g(R.id.fullScreen)).setImageResource(R.drawable.icon_commentate_full_screen);
            for (View view2 : ViewGroupKt.getChildren((ConstraintLayout) g(R.id.commentateContainerLayout))) {
                if (!this.i.contains(Integer.valueOf(view2.getId())) && view2.getVisibility() == 4) {
                    view2.setVisibility(0);
                }
            }
        }
    }

    @Override // com.shizhuang.duapp.modules.live.common.component.IComponent, com.shizhuang.duapp.modules.live.common.component.BaseLiveComponent
    public void onAttach(@NotNull LifecycleOwner lifecycleOwner) {
        if (!PatchProxy.proxy(new Object[]{lifecycleOwner}, this, changeQuickRedirect, false, 185629, new Class[]{LifecycleOwner.class}, Void.TYPE).isSupported) {
            super.onAttach(lifecycleOwner);
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185630, new Class[0], Void.TYPE).isSupported) {
                ConstraintLayout constraintLayout = (ConstraintLayout) g(R.id.commentateContainerLayout);
                constraintLayout.setPadding(constraintLayout.getPaddingLeft(), r0.i(k()), constraintLayout.getPaddingRight(), constraintLayout.getPaddingBottom());
                ((LiveViewV3) g(R.id.liveViewV3)).setScaleX(1.2f);
                ((LiveViewV3) g(R.id.liveViewV3)).setScaleY(1.2f);
                ViewExtensionKt.j((ImageView) g(R.id.quit), 0, new CommentateUiComponent$initView$1(this), 1);
                ((TodayHotRecommendView) g(R.id.recommendProductView)).setSensorEventHelper(this.n);
                if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185649, new Class[0], Void.TYPE).isSupported) {
                    ((LiveCommentateListViewNew) g(R.id.liveCommentateProductList)).setOnItemClickListener(new ok0.e(this));
                }
                ViewExtensionKt.j((LiveAvatarLayout) g(R.id.avatar), 0, new CommentateUiComponent$initView$2(this), 1);
                ViewExtensionKt.j((ImageView) g(R.id.fullScreen), 0, new CommentateUiComponent$initView$3(this), 1);
                ViewExtensionKt.j((ImageView) g(R.id.share), 0, new CommentateUiComponent$initView$4(this), 1);
                ViewExtensionKt.j((RelativeLayout) g(R.id.backLiveLayout), 0, new CommentateUiComponent$initView$5(this), 1);
                ((TouchDelegateView) g(R.id.touchDelegateView)).setDelegateView((IndicatorSeekBarNew) g(R.id.playSeekView));
            }
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185640, new Class[0], Void.TYPE).isSupported) {
                DuHttpRequest<RoomDetailModel> fetchCommentateDetailRequest = this.l.getFetchCommentateDetailRequest();
                Ref.BooleanRef booleanRef = new Ref.BooleanRef();
                booleanRef.element = fetchCommentateDetailRequest.getMutableAllStateLiveData().getValue() instanceof c.a;
                fetchCommentateDetailRequest.getMutableAllStateLiveData().observe(j.a(this), new CommentateUiComponent$registerObserver$$inlined$observe$1(fetchCommentateDetailRequest, booleanRef, this));
                DuHttpRequest<TodayHotRecommendModel> fetchRecommendProductRequest = this.l.getFetchRecommendProductRequest();
                Ref.BooleanRef booleanRef2 = new Ref.BooleanRef();
                booleanRef2.element = fetchRecommendProductRequest.getMutableAllStateLiveData().getValue() instanceof c.a;
                fetchRecommendProductRequest.getMutableAllStateLiveData().observe(j.a(this), new CommentateUiComponent$registerObserver$$inlined$observe$2(fetchRecommendProductRequest, booleanRef2, this));
                DuHttpRequest<TodayHotRecommendModel> fetchTradeSlideRecommendProductRequest = this.l.getFetchTradeSlideRecommendProductRequest();
                Ref.BooleanRef booleanRef3 = new Ref.BooleanRef();
                booleanRef3.element = fetchTradeSlideRecommendProductRequest.getMutableAllStateLiveData().getValue() instanceof c.a;
                fetchTradeSlideRecommendProductRequest.getMutableAllStateLiveData().observe(j.a(this), new CommentateUiComponent$registerObserver$$inlined$observe$3(fetchTradeSlideRecommendProductRequest, booleanRef3, this));
                this.l.isSeeking().observe(this, new CommentateUiComponent$registerObserver$4(this));
            }
        }
    }

    @Override // androidx.lifecycle.DefaultLifecycleObserver, androidx.lifecycle.FullLifecycleObserver, com.shizhuang.duapp.modules.live.common.component.BaseComponent
    public void onResume(@NotNull LifecycleOwner lifecycleOwner) {
        if (!PatchProxy.proxy(new Object[]{lifecycleOwner}, this, changeQuickRedirect, false, 185641, new Class[]{LifecycleOwner.class}, Void.TYPE).isSupported) {
            super.onResume(lifecycleOwner);
            if (this.f17765h) {
                j();
            }
        }
    }

    @Override // com.shizhuang.duapp.modules.live.common.base.ILiveLifecycle, com.shizhuang.duapp.modules.live.common.component.BaseLiveComponent
    public void unSelected() {
        LiveCommentateListViewNew liveCommentateListViewNew;
        List<LiveCameraProductModel> preloadedUrls;
        Context k6;
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185650, new Class[0], Void.TYPE).isSupported) {
            super.unSelected();
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 185651, new Class[0], Void.TYPE).isSupported && (liveCommentateListViewNew = (LiveCommentateListViewNew) g(R.id.liveCommentateProductList)) != null && (preloadedUrls = liveCommentateListViewNew.getPreloadedUrls()) != null && !preloadedUrls.isEmpty() && (k6 = k()) != null) {
                Iterator<T> it2 = preloadedUrls.iterator();
                while (it2.hasNext()) {
                    nk0.a aVar = nk0.a.f36140a;
                    String commentatePlayUrlByAB = it2.next().getCommentatePlayUrlByAB();
                    if (!PatchProxy.proxy(new Object[]{k6, commentatePlayUrlByAB}, aVar, nk0.a.changeQuickRedirect, false, 185540, new Class[]{Context.class, String.class}, Void.TYPE).isSupported) {
                        tcking.poizon.com.dupoizonplayer.cache.a.b(k6).removePreloadTask(commentatePlayUrlByAB);
                    }
                }
            }
        }
    }
}