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


package com.shizhuang.duapp.modules.product_detail.detailv3.callbacks;

import android.os.Bundle;
import android.util.ArrayMap;
import android.view.View;
import android.view.ViewStub;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.shizhuang.duapp.R;
import com.shizhuang.duapp.common.helper.LoginHelper;
import com.shizhuang.duapp.modules.du_mall_common.constant.MallABTest;
import com.shizhuang.duapp.modules.du_mall_common.extension.LiveDataExtensionKt;
import com.shizhuang.duapp.modules.du_mall_common.extension.ViewExtensionKt;
import com.shizhuang.duapp.modules.du_mall_common.utils.exposure.IMallExposureHelper;
import com.shizhuang.duapp.modules.du_mall_common.utils.page.ActivityViewCallback;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmBrandItemModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmDetailInfoModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmLastSoldModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmProductPriceModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmSizeDetailModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmSizeInfoItemModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.model.PmSizeInfoModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.vm.PmViewModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.vm.customize.PmMasterSlaveSpuViewModel;
import com.shizhuang.duapp.modules.product_detail.detailv3.vm.switcher.PmLiveDataSwitcher;
import com.shizhuang.duapp.modules.product_detail.detailv3.widget.PmBottomFavAndOwnItemView;
import com.shizhuang.duapp.modules.router.ServiceManager;
import com.shizhuang.duapp.modules.router.model.KfChatOption;
import com.shizhuang.duapp.modules.router.model.KfProductInfo;
import com.shizhuang.duapp.modules.router.model.KfSourceInfo;
import i60.b;
import j50.i;
import java.util.HashMap;
import java.util.List;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.jvm.internal.Reflection;
import kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1;
import m60.k;
import mk1.d;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import q01.t;

@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/product_detail/detailv3/callbacks/PmCustomServiceButtonCallback;", "Lcom/shizhuang/duapp/modules/du_mall_common/utils/page/ActivityViewCallback;", "du_product_detail_release"}, k = 1, mv = {1, 4, 2})
/* compiled from: PmCustomServiceButtonCallback.kt */
public final class PmCustomServiceButtonCallback extends ActivityViewCallback {
    public static ChangeQuickRedirect changeQuickRedirect;
    public final Lazy d;
    public final Lazy e;
    public final Lazy f;

    /* renamed from: g  reason: collision with root package name */
    public final k f21979g;

    /* renamed from: h  reason: collision with root package name */
    public HashMap f21980h;

    /* compiled from: PmCustomServiceButtonCallback.kt */
    public static final class a implements Runnable {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ PmCustomServiceButtonCallback b;

        public a(PmCustomServiceButtonCallback pmCustomServiceButtonCallback) {
            this.b = pmCustomServiceButtonCallback;
        }

        public final void run() {
            PmModel value;
            PmDetailInfoModel detail;
            KfSourceInfo kfSourceInfo;
            PmSizeInfoItemModel sizeTemplate;
            PmSizeInfoItemModel sizeReport;
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262499, new Class[0], Void.TYPE).isSupported && (value = this.b.c().getModel().getValue()) != null && (detail = value.getDetail()) != null) {
                PmProductPriceModel value2 = this.b.b().a().getValue();
                PmModel value3 = this.b.c().getModel().getValue();
                String str = null;
                PmBrandItemModel brand = value3 != null ? value3.getBrand() : null;
                PmModel value4 = this.b.c().getModel().getValue();
                PmLastSoldModel lastSold = value4 != null ? value4.getLastSold() : null;
                PmModel value5 = this.b.c().getModel().getValue();
                PmSizeInfoModel sizeInfo = value5 != null ? value5.getSizeInfo() : null;
                List<PmSizeDetailModel> list = (sizeInfo == null || (sizeReport = sizeInfo.getSizeReport()) == null) ? null : sizeReport.getList();
                boolean z = true;
                if (list == null || list.isEmpty()) {
                    List<PmSizeDetailModel> list2 = (sizeInfo == null || (sizeTemplate = sizeInfo.getSizeTemplate()) == null) ? null : sizeTemplate.getList();
                    if (list2 == null || list2.isEmpty()) {
                        z = false;
                    }
                }
                KfProductInfo kfProductInfo = new KfProductInfo();
                kfProductInfo.setSpuId(detail.getSpuId());
                kfProductInfo.setUrl("https://m.poizon.com/router/product/ProductDetail?spuId=" + this.b.c().getSpuId());
                kfProductInfo.setSkuName(detail.getTitle());
                kfProductInfo.setLogoUrl(detail.getLogoUrl());
                kfProductInfo.setBrandId(brand != null ? brand.getBrandId() : 0);
                kfProductInfo.setBrandLogo(brand != null ? brand.getBrandLogo() : null);
                kfProductInfo.setBrandName(brand != null ? brand.getBrandName() : null);
                kfProductInfo.setSoldNum(lastSold != null ? lastSold.getCount() : 0);
                kfProductInfo.setProductSizeFlag(Boolean.valueOf(z));
                if (value2 != null) {
                    str = value2.getShowPriceLow();
                }
                kfProductInfo.setPrice(str);
                KfChatOption kfChatOption = new KfChatOption();
                kfChatOption.sourceId = "10002";
                kfChatOption.productInfo = kfProductInfo;
                kfChatOption.productCategory = Integer.valueOf(detail.getLevel1CategoryId());
                kfChatOption.spuId = Long.valueOf(detail.getSpuId());
                PmViewModel c5 = this.b.c();
                PatchProxyResult proxy = PatchProxy.proxy(new Object[0], c5, PmViewModel.changeQuickRedirect, false, 271948, new Class[0], KfSourceInfo.class);
                if (proxy.isSupported) {
                    kfSourceInfo = (KfSourceInfo) proxy.result;
                } else {
                    kfSourceInfo = c5.f22392q;
                }
                kfChatOption.sourceInfo = kfSourceInfo;
                ServiceManager.F().startChattingActivity(this.b.f13641c, kfChatOption);
            }
        }
    }

    public PmCustomServiceButtonCallback(@NotNull AppCompatActivity appCompatActivity) {
        super(appCompatActivity);
        this.d = new ViewModelLazy(Reflection.getOrCreateKotlinClass(PmViewModel.class), new PmCustomServiceButtonCallback$$special$$inlined$viewModels$2(appCompatActivity), new PmCustomServiceButtonCallback$$special$$inlined$viewModels$1(appCompatActivity));
        ViewModelLazy viewModelLazy = new ViewModelLazy(Reflection.getOrCreateKotlinClass(PmMasterSlaveSpuViewModel.class), new PmCustomServiceButtonCallback$$special$$inlined$viewModels$4(appCompatActivity), new PmCustomServiceButtonCallback$$special$$inlined$viewModels$3(appCompatActivity));
        this.e = viewModelLazy;
        PmLiveDataSwitcher.Companion companion = PmLiveDataSwitcher.b;
        PmViewModel c5 = c();
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262487, new Class[0], PmMasterSlaveSpuViewModel.class);
        this.f = companion.a(appCompatActivity, c5, (PmMasterSlaveSpuViewModel) (proxy.isSupported ? proxy.result : viewModelLazy.getValue()));
        this.f21979g = new k(appCompatActivity, (ImageView) a(R.id.customServiceButton), null, 4);
    }

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

    public final PmLiveDataSwitcher b() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262488, new Class[0], PmLiveDataSwitcher.class);
        return (PmLiveDataSwitcher) (proxy.isSupported ? proxy.result : this.f.getValue());
    }

    public final PmViewModel c() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262486, new Class[0], PmViewModel.class);
        return (PmViewModel) (proxy.isSupported ? proxy.result : this.d.getValue());
    }

    public final void d() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262492, new Class[0], Void.TYPE).isSupported) {
            LoginHelper.f(this.f13641c, LoginHelper.LoginTipsType.TYPE_CS_DIALOG, new a(this));
            u21.a aVar = u21.a.f38776a;
            Long valueOf = Long.valueOf(c().getSpuId());
            MallABTest mallABTest = MallABTest.f13351a;
            Object b = i.b(mallABTest.l(), i.b(mallABTest.m(), "1", PushConstants.PUSH_TYPE_UPLOAD_LOG), "0");
            Integer valueOf2 = Integer.valueOf(c().k().O());
            if (!PatchProxy.proxy(new Object[]{valueOf, b, valueOf2}, aVar, u21.a.changeQuickRedirect, false, 282447, new Class[]{Object.class, Object.class, Object.class}, Void.TYPE).isSupported) {
                b bVar = b.f33293a;
                ArrayMap arrayMap = new ArrayMap(8);
                arrayMap.put("spu_id", valueOf);
                arrayMap.put("appear_type", b);
                arrayMap.put(MallABTest.Keys.PRODUCT_DETAIL_TYPE, valueOf2);
                bVar.b("trade_product_detail_block_click", "400000", "628", arrayMap);
            }
        }
    }

    @Override // com.shizhuang.duapp.modules.du_mall_common.utils.page.PageViewCallback, com.shizhuang.duapp.modules.du_mall_common.utils.page.IPageViewCallback
    public void initView(@Nullable Bundle bundle) {
        if (!PatchProxy.proxy(new Object[]{bundle}, this, changeQuickRedirect, false, 262489, new Class[]{Bundle.class}, Void.TYPE).isSupported) {
            super.initView(bundle);
            MallABTest mallABTest = MallABTest.f13351a;
            if (!mallABTest.l()) {
                if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262490, new Class[0], Void.TYPE).isSupported) {
                    ((ImageView) a(R.id.customServiceButton)).setVisibility(8);
                    c().getModel().observe(this.f13641c, new PmCustomServiceButtonCallback$initTopServiceView$1(this));
                    d.m(new FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1(c().getBus().of(t.class), new PmCustomServiceButtonCallback$initTopServiceView$2(this, null)), LifecycleOwnerKt.getLifecycleScope(this.f13641c));
                    this.f21979g.setExposureCallback(new PmCustomServiceButtonCallback$initTopServiceView$3(this));
                    IMallExposureHelper.a.d(this.f21979g, false, 1, null);
                    ViewExtensionKt.e((ImageView) a(R.id.customServiceButton), 0, new PmCustomServiceButtonCallback$initTopServiceView$4(this), 1);
                }
            } else if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 262491, new Class[0], Void.TYPE).isSupported) {
                ViewStub viewStub = (ViewStub) i.b(mallABTest.m(), (ViewStub) getContainerView().findViewById(R.id.firstCustomer), (ViewStub) getContainerView().findViewById(R.id.secondCustomer));
                viewStub.setLayoutResource(R.layout.layout_pm_bottom_customer_view);
                View inflate = viewStub.inflate();
                if (inflate instanceof PmBottomFavAndOwnItemView) {
                    ((PmBottomFavAndOwnItemView) inflate).a(R.drawable.ic_pm_customer, "客服");
                }
                ViewExtensionKt.e(inflate, 0, new PmCustomServiceButtonCallback$initBottomServiceView$1(this), 1);
            }
            LiveDataExtensionKt.b(b().a(), this.f13641c, PmCustomServiceButtonCallback$initView$1.INSTANCE);
        }
    }
}