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


package com.shizhuang.duapp.modules.live_chat.chat.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.util.ArrayMap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.sensorsdata.analytics.android.sdk.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented;
import com.shizhuang.duapp.R;
import com.shizhuang.duapp.common.bean.RedirectModel;
import com.shizhuang.model.chat.ChatMessage;
import com.shizhuang.model.live.message.LiteUserModel;
import df.n0;
import df.o0;
import fd.f;
import gg0.n;
import java.net.URLDecoder;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import q20.v;

public class ChatItemTextHolder extends ChatItemHolder {
    public static ChangeQuickRedirect changeQuickRedirect;
    public TextView e;

    public class a extends ClickableSpan {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final int b;

        /* renamed from: c  reason: collision with root package name */
        public final String f18931c;
        public final String d;

        /* renamed from: com.shizhuang.duapp.modules.live_chat.chat.adapter.ChatItemTextHolder$a$a  reason: collision with other inner class name */
        public class C0297a implements Function1<ArrayMap<String, Object>, Unit> {
            public static ChangeQuickRedirect changeQuickRedirect;

            public C0297a() {
            }

            /* 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 Unit invoke(ArrayMap<String, Object> arrayMap) {
                ArrayMap<String, Object> arrayMap2 = arrayMap;
                PatchProxyResult proxy = PatchProxy.proxy(new Object[]{arrayMap2}, this, changeQuickRedirect, false, 206109, new Class[]{ArrayMap.class}, Unit.class);
                if (proxy.isSupported) {
                    return (Unit) proxy.result;
                }
                arrayMap2.put("content_url", a.this.d);
                LiteUserModel liteUserModel = ChatItemTextHolder.this.d.userInfo;
                if (liteUserModel != null) {
                    arrayMap2.put("community_user_name", liteUserModel.userName);
                }
                arrayMap2.put("community_user_id", ChatItemTextHolder.this.d.conversationId);
                arrayMap2.put("community_notice_id", ChatItemTextHolder.this.d.msgId);
                arrayMap2.put("community_notice_template_id", ChatItemTextHolder.this.d.code);
                return null;
            }
        }

        public a(int i, String str, String str2) {
            this.b = i;
            this.f18931c = str;
            this.d = str2;
        }

        @SensorsDataInstrumented
        public void onClick(View view) {
            if (!PatchProxy.proxy(new Object[]{view}, this, changeQuickRedirect, false, 206107, new Class[]{View.class}, Void.TYPE).isSupported) {
                RedirectModel redirectModel = new RedirectModel(this.b, this.f18931c, "");
                redirectModel.routerUrl = this.d;
                f.c(ChatItemTextHolder.this.getContext(), redirectModel, "");
                o0.b("common_push_content_click", new v(this, 2));
                n0.f31459a.d("community_notice_click", "567", "1030", new C0297a());
                SensorsDataAutoTrackHelper.trackViewOnClick(view);
            }
        }

        public void updateDrawState(TextPaint textPaint) {
            if (!PatchProxy.proxy(new Object[]{textPaint}, this, changeQuickRedirect, false, 206106, new Class[]{TextPaint.class}, Void.TYPE).isSupported) {
                try {
                    textPaint.setColor(Color.parseColor("#01C2C3"));
                    textPaint.setUnderlineText(false);
                } catch (Exception unused) {
                }
            }
        }
    }

    public ChatItemTextHolder(Context context, ViewGroup viewGroup) {
        super(context, viewGroup);
    }

    @Override // com.shizhuang.duapp.modules.live_chat.chat.adapter.ChatItemHolder
    /* renamed from: b */
    public void a(ChatMessage chatMessage) {
        URLSpan[] uRLSpanArr;
        int i;
        TextView textView;
        int i3;
        Exception e6;
        int parseInt;
        if (!PatchProxy.proxy(new Object[]{chatMessage}, this, changeQuickRedirect, false, 206103, new Class[]{ChatMessage.class}, Void.TYPE).isSupported) {
            super.a(chatMessage);
            this.e.setText(h(Html.fromHtml(chatMessage.content)));
            TextView textView2 = this.e;
            if (!PatchProxy.proxy(new Object[]{textView2, chatMessage}, this, changeQuickRedirect, false, 206105, new Class[]{TextView.class, ChatMessage.class}, Void.TYPE).isSupported) {
                textView2.setMovementMethod(LinkMovementMethod.getInstance());
                CharSequence text = textView2.getText();
                if (text instanceof Spannable) {
                    int length = text.length();
                    Spannable spannable = (Spannable) textView2.getText();
                    URLSpan[] uRLSpanArr2 = (URLSpan[]) spannable.getSpans(0, length, URLSpan.class);
                    if (uRLSpanArr2.length != 0) {
                        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
                        int length2 = uRLSpanArr2.length;
                        int i12 = 0;
                        while (i12 < length2) {
                            URLSpan uRLSpan = uRLSpanArr2[i12];
                            try {
                                String replace = uRLSpan.getURL().replace("{", "").replace("}", "");
                                String[] split = replace.split(",");
                                uRLSpanArr = uRLSpanArr2;
                                i3 = length2;
                                i = i12;
                                String str = "";
                                String str2 = str;
                                textView = textView2;
                                int i13 = 0;
                                int i14 = 0;
                                for (int length3 = split.length; i13 < length3; length3 = length3) {
                                    try {
                                        String str3 = split[i13];
                                        if (!TextUtils.isEmpty(str3)) {
                                            if (str3.contains("jumplink:")) {
                                                str = str3.replace("jumplink:", "");
                                            } else if (str3.contains("routerUrl:")) {
                                                str2 = URLDecoder.decode(str3.replace("routerUrl:", ""), "utf-8");
                                            } else {
                                                if (str3.contains("jumpType:")) {
                                                    parseInt = Integer.parseInt(str3.replace("jumpType:", ""));
                                                } else if (str3.contains("jumptype:")) {
                                                    parseInt = Integer.parseInt(str3.replace("jumptype:", ""));
                                                } else if (replace.startsWith("https://m.poizon.com/router") || replace.startsWith("https://m.dewu.com/router")) {
                                                    str2 = replace;
                                                }
                                                i14 = parseInt;
                                            }
                                        }
                                        i13++;
                                    } catch (Exception e12) {
                                        e6 = e12;
                                        e6.printStackTrace();
                                        i12 = i + 1;
                                        uRLSpanArr2 = uRLSpanArr;
                                        length2 = i3;
                                        textView2 = textView;
                                    }
                                }
                                spannableStringBuilder.setSpan(new a(i14, str, str2), spannable.getSpanStart(uRLSpan), spannable.getSpanEnd(uRLSpan), 17);
                                if (!TextUtils.isEmpty(str) || !TextUtils.isEmpty(str2)) {
                                    spannableStringBuilder.removeSpan(uRLSpan);
                                    i12 = i + 1;
                                    uRLSpanArr2 = uRLSpanArr;
                                    length2 = i3;
                                    textView2 = textView;
                                } else {
                                    i12 = i + 1;
                                    uRLSpanArr2 = uRLSpanArr;
                                    length2 = i3;
                                    textView2 = textView;
                                }
                            } catch (Exception e13) {
                                e6 = e13;
                                uRLSpanArr = uRLSpanArr2;
                                i3 = length2;
                                i = i12;
                                textView = textView2;
                                e6.printStackTrace();
                                i12 = i + 1;
                                uRLSpanArr2 = uRLSpanArr;
                                length2 = i3;
                                textView2 = textView;
                            }
                        }
                        n.o(textView2, spannableStringBuilder);
                    }
                }
            }
        }
    }

    @Override // com.shizhuang.duapp.modules.live_chat.chat.adapter.ChatItemHolder
    public boolean d() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 206104, new Class[0], Boolean.TYPE);
        if (proxy.isSupported) {
            return ((Boolean) proxy.result).booleanValue();
        }
        return false;
    }

    @Override // com.shizhuang.duapp.modules.live_chat.chat.adapter.ChatItemHolder
    public void e() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 206102, new Class[0], Void.TYPE).isSupported) {
            super.e();
            this.f18922c.addView(View.inflate(getContext(), R.layout.prv_chat_item_center_text_layout, null));
            this.e = (TextView) this.itemView.findViewById(R.id.chat_left_text_tv_content);
        }
    }
}