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


package com.shizhuang.duapp.modules.mall_seller.merchant.center.view;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import bu0.n;
import cd.h;
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.libs.duimageloaderview.options.DuRequestOptions;
import com.shizhuang.duapp.modules.mall_seller.merchant.center.model.Notice;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.functions.Function1;
import o5.i;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import u91.e;

@Metadata(bv = {}, d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u00012\u00020\u0003B'\b\u0007\u0012\u0006\u0010\u000f\u001a\u00020\u000e\u0012\n\b\u0002\u0010\u0011\u001a\u0004\u0018\u00010\u0010\u0012\b\b\u0002\u0010\u0012\u001a\u00020\u0004¢\u0006\u0004\b\u0013\u0010\u0014J\b\u0010\u0005\u001a\u00020\u0004H\u0016J\b\u0010\u0007\u001a\u00020\u0006H\u0007J\b\u0010\b\u001a\u00020\u0006H\u0007R\u0014\u0010\u000b\u001a\u00020\u00048BX‚\u0004¢\u0006\u0006\u001a\u0004\b\t\u0010\nR\u0014\u0010\r\u001a\u00020\u00048BX‚\u0004¢\u0006\u0006\u001a\u0004\b\f\u0010\n¨\u0006\u0015"}, d2 = {"Lcom/shizhuang/duapp/modules/mall_seller/merchant/center/view/MCNoticeView;", "Lcom/shizhuang/duapp/modules/mall_seller/merchant/center/view/MCBaseView;", "Lbu0/n;", "Landroidx/lifecycle/LifecycleObserver;", "", "getLayoutId", "", "onResume", "onPause", "getNextShowIndex", "()I", "nextShowIndex", "getTranslationHeight", "translationHeight", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "defStyleAttr", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "du_mall_seller_release"}, k = 1, mv = {1, 4, 2})
/* compiled from: MCNoticeView.kt */
public final class MCNoticeView extends MCBaseView<n> implements LifecycleObserver {
    public static ChangeQuickRedirect changeQuickRedirect;

    /* renamed from: c  reason: collision with root package name */
    public final List<View> f20284c;
    public ValueAnimator d;
    public int e;
    public boolean f;

    /* renamed from: g  reason: collision with root package name */
    public HashMap f20285g;

    /* compiled from: MCNoticeView.kt */
    public static final class a implements ValueAnimator.AnimatorUpdateListener {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ MCNoticeView b;

        public a(MCNoticeView mCNoticeView) {
            this.b = mCNoticeView;
        }

        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
            if (!PatchProxy.proxy(new Object[]{valueAnimator}, this, changeQuickRedirect, false, 225579, new Class[]{ValueAnimator.class}, Void.TYPE).isSupported) {
                float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
                MCNoticeView mCNoticeView = this.b;
                mCNoticeView.f20284c.get(mCNoticeView.e).setTranslationY(floatValue - ((float) this.b.getTranslationHeight()));
                MCNoticeView mCNoticeView2 = this.b;
                mCNoticeView2.f20284c.get(mCNoticeView2.getNextShowIndex()).setTranslationY(floatValue);
            }
        }
    }

    /* compiled from: MCNoticeView.kt */
    public static final class b extends AnimatorListenerAdapter {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ ValueAnimator b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ MCNoticeView f20286c;

        public b(ValueAnimator valueAnimator, MCNoticeView mCNoticeView) {
            this.b = valueAnimator;
            this.f20286c = mCNoticeView;
        }

        public void onAnimationEnd(@Nullable Animator animator) {
            if (!PatchProxy.proxy(new Object[]{animator}, this, changeQuickRedirect, false, 225580, new Class[]{Animator.class}, Void.TYPE).isSupported) {
                MCNoticeView mCNoticeView = this.f20286c;
                mCNoticeView.e = mCNoticeView.getNextShowIndex();
                this.b.start();
            }
        }
    }

    @JvmOverloads
    public MCNoticeView(@NotNull Context context) {
        this(context, null, 0, 6);
    }

    @JvmOverloads
    public MCNoticeView(@NotNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0, 4);
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public /* synthetic */ MCNoticeView(Context context, AttributeSet attributeSet, int i, int i3) {
        this(context, (i3 & 2) != 0 ? null : attributeSet, (i3 & 4) != 0 ? 0 : i);
    }

    public View _$_findCachedViewById(int i) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{new Integer(i)}, this, changeQuickRedirect, false, 225575, new Class[]{Integer.TYPE}, View.class);
        if (proxy.isSupported) {
            return (View) proxy.result;
        }
        if (this.f20285g == null) {
            this.f20285g = new HashMap();
        }
        View view = (View) this.f20285g.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i);
        this.f20285g.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final void a() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225571, new Class[0], Void.TYPE).isSupported) {
            if (this.f20284c.size() > 1 && this.d == null) {
                this.f20284c.get(this.e).setTranslationY(i.f36333a);
                ValueAnimator ofFloat = ValueAnimator.ofFloat((float) getTranslationHeight(), 0.0f);
                ofFloat.addUpdateListener(new a(this));
                ofFloat.addListener(new b(ofFloat, this));
                ofFloat.setDuration(300L);
                ofFloat.setStartDelay(1700);
                ofFloat.start();
                Unit unit = Unit.INSTANCE;
                this.d = ofFloat;
            } else if (this.f20284c.size() == 1) {
                this.f20284c.get(0).setTranslationY(i.f36333a);
            }
        }
    }

    public final void b() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225572, new Class[0], Void.TYPE).isSupported) {
            ValueAnimator valueAnimator = this.d;
            if (valueAnimator != null) {
                valueAnimator.removeAllUpdateListeners();
            }
            ValueAnimator valueAnimator2 = this.d;
            if (valueAnimator2 != null) {
                valueAnimator2.removeAllListeners();
            }
            ValueAnimator valueAnimator3 = this.d;
            if (valueAnimator3 != null) {
                valueAnimator3.cancel();
            }
            this.d = null;
        }
    }

    @Override // com.shizhuang.duapp.common.component.module.AbsModuleView
    public int getLayoutId() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225568, new Class[0], Integer.TYPE);
        return proxy.isSupported ? ((Integer) proxy.result).intValue() : R.layout.mc_view_notice;
    }

    public final int getNextShowIndex() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225566, new Class[0], Integer.TYPE);
        return proxy.isSupported ? ((Integer) proxy.result).intValue() : (this.e + 1) % this.f20284c.size();
    }

    public final int getTranslationHeight() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225567, new Class[0], Integer.TYPE);
        if (proxy.isSupported) {
            return ((Integer) proxy.result).intValue();
        }
        if (((FrameLayout) _$_findCachedViewById(R.id.layBulletinDetail)).getHeight() > 0) {
            return ((FrameLayout) _$_findCachedViewById(R.id.layBulletinDetail)).getHeight();
        }
        return fi.b.b((float) 12);
    }

    /* JADX DEBUG: Failed to insert an additional move for type inference into block B:43:0x0125 */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX DEBUG: Type inference failed for r1v10. Raw type applied. Possible types: java.util.List<android.view.View>, java.util.List */
    /* JADX WARN: Type inference failed for: r0v29, types: [android.view.View, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r1v12, types: [android.widget.FrameLayout] */
    /* JADX WARN: Type inference failed for: r0v30, types: [android.widget.TextView] */
    /* JADX WARN: Type inference failed for: r0v32, types: [android.view.View] */
    /* JADX WARNING: Unknown variable types count: 2 */
    @Override // com.shizhuang.duapp.common.component.module.AbsModuleView
    public void onChanged(Object obj) {
        Boolean bool;
        ?? r0;
        n nVar = (n) obj;
        if (!PatchProxy.proxy(new Object[]{nVar}, this, changeQuickRedirect, false, 225573, new Class[]{n.class}, Void.TYPE).isSupported) {
            super.onChanged(nVar);
            b();
            ((FrameLayout) _$_findCachedViewById(R.id.layBulletinDetail)).removeAllViews();
            this.f20284c.clear();
            View _$_findCachedViewById = _$_findCachedViewById(R.id.sellerNoticeRedPoint);
            PatchProxyResult proxy = PatchProxy.proxy(new Object[0], nVar, n.changeQuickRedirect, false, 225559, new Class[0], Boolean.class);
            if (proxy.isSupported) {
                bool = (Boolean) proxy.result;
            } else {
                bool = nVar.b;
            }
            _$_findCachedViewById.setVisibility(bool != null ? bool.booleanValue() : false ? 0 : 8);
            FrameLayout frameLayout = (FrameLayout) _$_findCachedViewById(R.id.mcNoticeBg);
            List<Notice> a5 = nVar.a();
            frameLayout.setVisibility(a5 == null || a5.isEmpty() ? 4 : 0);
            List<Notice> a12 = nVar.a();
            if (!(a12 == null || a12.isEmpty())) {
                Iterator<T> it2 = nVar.a().iterator();
                while (it2.hasNext()) {
                    Context context = getContext();
                    String title = it2.next().getTitle();
                    if (title == null) {
                        title = "";
                    }
                    PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{context, title}, this, changeQuickRedirect, false, 225574, new Class[]{Context.class, String.class}, View.class);
                    if (proxy2.isSupported) {
                        r0 = (View) proxy2.result;
                    } else {
                        r0 = new TextView(context);
                        r0.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
                        r0.setSingleLine();
                        r0.setTranslationY((float) getTranslationHeight());
                        r0.setEllipsize(TextUtils.TruncateAt.valueOf("END"));
                        r0.setTextColor(Color.parseColor("#7F7F8E"));
                        r0.setTextSize(0, (float) fi.b.b((float) 11));
                        r0.setText(title);
                    }
                    this.f20284c.add(r0);
                    ((FrameLayout) _$_findCachedViewById(R.id.layBulletinDetail)).addView(r0);
                }
                this.e = 0;
                if (this.f) {
                    a();
                }
            }
        }
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    public final void onPause() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225570, new Class[0], Void.TYPE).isSupported) {
            this.f = false;
            b();
        }
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    public final void onResume() {
        int i = 0;
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 225569, new Class[0], Void.TYPE).isSupported) {
            this.f = true;
            for (T t : this.f20284c) {
                int i3 = i + 1;
                if (i < 0) {
                    CollectionsKt__CollectionsKt.throwIndexOverflow();
                }
                T t4 = t;
                if (i == this.e) {
                    t4.setTranslationY(i.f36333a);
                } else {
                    t4.setTranslationY((float) getTranslationHeight());
                }
                i = i3;
            }
            a();
        }
    }

    @JvmOverloads
    public MCNoticeView(@NotNull final Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f20284c = new ArrayList();
        h.a(this);
        ViewExtensionKt.h(this, new Function1<View, Unit>() {
            /* class com.shizhuang.duapp.modules.mall_seller.merchant.center.view.MCNoticeView.AnonymousClass1 */
            public static ChangeQuickRedirect changeQuickRedirect;

            /* 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] */
            @Override // kotlin.jvm.functions.Function1
            public /* bridge */ /* synthetic */ Unit invoke(View view) {
                invoke(view);
                return Unit.INSTANCE;
            }

            public final void invoke(@NotNull View view) {
                if (!PatchProxy.proxy(new Object[]{view}, this, changeQuickRedirect, false, 225577, new Class[]{View.class}, Void.TYPE).isSupported) {
                    qf1.a.B("500200", "1", null);
                    Context context = context;
                    if (context instanceof Activity) {
                        e.g1((Activity) context);
                    }
                    a1.a.j(8, i60.b.f33293a, "trade_seller_central_block_click", "309", "632");
                }
            }
        });
        ((DuRequestOptions) mn.a.f35714a.g("https://apk.poizon.com/duApp/Android_Config/resource/mall/app/merchant/bg_merchant_center_notice.png").u(new Function1<Bitmap, Unit>(this) {
            /* class com.shizhuang.duapp.modules.mall_seller.merchant.center.view.MCNoticeView.AnonymousClass2 */
            public static ChangeQuickRedirect changeQuickRedirect;
            public final /* synthetic */ MCNoticeView this$0;

            {
                this.this$0 = r1;
            }

            /* 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] */
            @Override // kotlin.jvm.functions.Function1
            public /* bridge */ /* synthetic */ Unit invoke(Bitmap bitmap) {
                invoke(bitmap);
                return Unit.INSTANCE;
            }

            public final void invoke(@NotNull Bitmap bitmap) {
                if (!PatchProxy.proxy(new Object[]{bitmap}, this, changeQuickRedirect, false, 225578, new Class[]{Bitmap.class}, Void.TYPE).isSupported) {
                    ((LinearLayout) this.this$0._$_findCachedViewById(R.id.llNotice)).setBackground(new BitmapDrawable(this.this$0.getResources(), bitmap));
                }
            }
        })).G(h.f(this)).y();
    }
}