QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 PartyContent.java 源代码,内容仅作参考


package com.tencent.mtt.browser.homepage.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import com.tencent.mtt.R;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.browser.feeds.res.HomeResourceAdapter;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.setting.PublicSettingManager;
import com.tencent.mtt.view.common.SimpleImageTextView;
import com.tencent.mtt.view.layout.QBLinearLayout;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import org.json.JSONArray;
import org.json.JSONObject;

public class PartyContent extends QBLinearLayout {

    public static final int f40556a = HomeResourceAdapter.d(24);

    public static final int f40557b = HomeResourceAdapter.d(16);

    private Paint f40558c;

    public static class PartySiteItemView extends SimpleImageTextView implements View.OnClickListener {

        private String f40559a;

        private String f40560b;

        private int f40561c;

        public PartySiteItemView(Context context) {
            super(context);
            f(R.color.theme_home_feeds_qb_color_a2, R.color.theme_home_feeds_qb_color_b1);
            setTextSize(HomeResourceAdapter.d(11));
            setGravity(17);
            setOnClickListener(this);
        }

        public void a(String str, String str2, int i) {
            this.f40560b = str;
            this.f40559a = str2;
            this.f40561c = i;
            setText(this.f40560b);
        }

        @Override
        public void onClick(View view) {
            EventCollector.getInstance().onViewClickedBefore(view);
            if (!TextUtils.isEmpty(this.f40559a)) {
                UrlParams c2 = new UrlParams(this.f40559a).b(1).c(90);
                c2.f(65);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(c2);
                StatManager.b().c(String.format("ADHK3_%s", Integer.valueOf(this.f40561c + 1)));
            }
            EventCollector.getInstance().onViewClicked(view);
        }
    }

    public PartyContent(Context context) {
        super(context);
        setBackgroundNormalIds(0, R.color.theme_home_party_content_bg);
        this.f40558c = new Paint(1);
        this.f40558c.setColor(MttResources.c(R.color.theme_home_content_split_line_color));
        int i = f40557b;
        setPadding(i, 0, i, 0);
        b();
    }

    private void b() {
        String string = PublicSettingManager.a().getString("key_home_party_site_config", "");
        if (TextUtils.isEmpty(string)) {
            string = "[{\"name\":\"人民网\", \"url\":\"http://m.people.cn/\"},{\"name\":\"新华网\", \"url\":\"http://m.news.cn/\"},{\"name\":\"央视网\", \"url\":\"http://m.cctv.com/index.shtml?k_f=cbsjysw_1\"},{\"name\":\"网信网\", \"url\":\"http://www.cac.gov.cn/\"},{\"name\":\"中国网\", \"url\":\"http://m.china.com.cn/index.shtml\"},{\"name\":\"光明网\", \"url\":\"http://m.gmw.cn/\"}]";
        }
        try {
            JSONArray jSONArray = new JSONArray(string);
            if (jSONArray.length() > 0) {
                for (int i = 0; i < jSONArray.length(); i++) {
                    JSONObject jSONObject = jSONArray.getJSONObject(i);
                    String optString = jSONObject.optString("name");
                    String optString2 = jSONObject.optString("url");
                    PartySiteItemView partySiteItemView = new PartySiteItemView(getContext());
                    partySiteItemView.a(optString, optString2, i);
                    addView(partySiteItemView, new LinearLayout.LayoutParams(-2, -1));
                }
            }
            if (getChildCount() == 0) {
                setVisibility(8);
            }
        } catch (Exception unused) {
        }
    }

    public void a() {
        setBackgroundNormalIds(0, R.color.theme_home_party_content_bg);
        this.f40558c.setColor(MttResources.c(R.color.theme_home_content_split_line_color));
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = getChildAt(i);
            if (childAt instanceof PartySiteItemView) {
                ((PartySiteItemView) childAt).f(R.color.theme_home_feeds_qb_color_a2, R.color.theme_home_feeds_qb_color_b1);
            }
        }
    }

    public void a(int i, int i2, int i3) {
        setBackgroundColor(i);
        this.f40558c.setColor(i3);
        int childCount = getChildCount();
        for (int i4 = 0; i4 < childCount; i4++) {
            View childAt = getChildAt(i4);
            if (childAt instanceof PartySiteItemView) {
                ((PartySiteItemView) childAt).setTextColor(i2);
            }
        }
    }

    @Override
    public void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (this.f40558c != null) {
            canvas.drawLine(0.0f, getHeight(), getWidth(), getHeight(), this.f40558c);
        }
    }

    @Override
    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int i5;
        int i6 = i3 - i;
        int i7 = i4 - i2;
        int childCount = getChildCount();
        if (i6 <= 0 || i7 <= 0 || childCount <= 0) {
            return;
        }
        int paddingLeft = getPaddingLeft();
        int width = (getWidth() - getPaddingLeft()) - getPaddingRight();
        int i8 = 0;
        for (int i9 = 0; i9 < childCount; i9++) {
            i8 += getChildAt(i9).getMeasuredWidth();
        }
        if (childCount <= 1 || (i5 = (width - i8) / (childCount - 1)) < 0) {
            i5 = 0;
        }
        int i10 = paddingLeft;
        for (int i11 = 0; i11 < childCount; i11++) {
            View childAt = getChildAt(i11);
            childAt.layout(i10, 0, childAt.getMeasuredWidth() + i10, childAt.getMeasuredHeight());
            i10 += childAt.getMeasuredWidth() + i5;
        }
    }

    @Override
    public void switchSkin() {
        this.f40558c.setColor(MttResources.c(R.color.theme_home_content_split_line_color));
        super.switchSkin();
    }
}