西瓜看球 v2.9.13版本的 MD5 值为:755288f3c36852638c41cf20ae0d004e

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


package io.dcloud.feature.nativeObj;

import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.NinePatch;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.NinePatchDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Base64;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.view.GravityCompat;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.dcloud.android.widget.CapsuleLayout;
import com.dcloud.android.widget.DCProgressView;
import com.taobao.weex.common.Constants;
import com.taobao.weex.el.parse.Operators;
import io.dcloud.base.R;
import io.dcloud.common.DHInterface.AbsMgr;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IEventCallback;
import io.dcloud.common.DHInterface.IFrameView;
import io.dcloud.common.DHInterface.IMgr;
import io.dcloud.common.DHInterface.ISysEventListener;
import io.dcloud.common.DHInterface.ITitleNView;
import io.dcloud.common.DHInterface.IWebAppRootView;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.DHInterface.IWebviewStateListener;
import io.dcloud.common.DHInterface.IX5WebView;
import io.dcloud.common.adapter.ui.AdaFrameItem;
import io.dcloud.common.adapter.ui.AdaFrameView;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.UniMPConfig;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.ui.blur.DCBlurDraweeView;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.Deprecated_JSUtil;
import io.dcloud.common.util.JSUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.StringUtil;
import io.dcloud.common.util.TitleNViewUtil;
import io.dcloud.feature.internal.sdk.SDK;
import io.dcloud.feature.nativeObj.NativeView;
import io.dcloud.feature.nativeObj.data.ButtonDataItem;
import io.dcloud.feature.ui.nativeui.a;
import java.io.File;
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import pl.droidsonroids.gif.GifDrawable;
public class TitleNView extends NativeView implements ITitleNView {
    private final String CLOSE;
    private final String MENU;
    private LinearLayout centerSearchLayout;
    private TextView closeBt;
    private AtomicBoolean isSetText;
    private BadgeLinearLayout mBackButton;
    private BackGroundDrawable mBackGroundDrawable;
    private View mBackgroudView;
    private DCBlurDraweeView mBlurDraweeView;
    public String mBlurEffect;
    private ArrayList<Object> mButtons;
    private CapsuleLayout mCapsuleLayout;
    private TextView mHomeButton;
    protected IWebviewStateListenerImpl mIWebviewStateListenerImpl;
    private LinearLayout mLeftButtonLayout;
    private String mMenuButtonFontSize;
    private String mMenuButtonFontWeight;
    private int mMenuButtonTextColor;
    private ArrayList<ButtonDataItem> mMenuButtons;
    private Progress mProgress;
    private LinearLayout mRightButtonLayout;
    private View mSplitLine;
    private RelativeLayout mTitleNViewLayout;
    private TextView mTitleView;
    private RelativeLayout mTitlelayout;
    public int maxButton;
    private TextView menuBt;
    private int redDotColor;
    private EditText searchInput;

    class BackGroundDrawable extends Drawable {
        private Rect bound;
        private Paint colorPaint;
        private Paint mPaint;
        private int shadow5PX;
        private Paint shadowPaint;
        private Shader mBackgroundBitmap = null;
        private String bitmapPath = null;
        private String repeatType = "no-repeat";
        private int mBackgroundColor = 0;
        private String shadowColor = "";
        private int shadowColorInt = 0;
        private int height = 0;
        private int offset = 0;

        public BackGroundDrawable() {
            this.shadow5PX = PdrUtil.convertToScreenInt("10px", TitleNView.this.mInnerWidth, 0, TitleNView.this.mCreateScale);
        }

        private Shader getShader(List<String> list, float f, float f2) {
            float[] parseGradientDirection = parseGradientDirection(list.get(0).trim(), f, f2);
            if (parseGradientDirection == null) {
                return null;
            }
            return new LinearGradient(parseGradientDirection[0], parseGradientDirection[1], parseGradientDirection[2], parseGradientDirection[3], PdrUtil.stringToColor(list.get(1).trim()), PdrUtil.stringToColor(list.get(2).trim()), Shader.TileMode.CLAMP);
        }

        private Paint getShadowPaint() {
            if (this.shadowPaint == null) {
                this.shadowPaint = new Paint();
            }
            return this.shadowPaint;
        }

        private float[] parseGradientDirection(String str, float f, float f2) {
            char c = 4;
            float[] fArr = {0.0f, 0.0f, 0.0f, 0.0f};
            if (!TextUtils.isEmpty(str)) {
                str = str.replaceAll("\\s*", "").toLowerCase(Locale.ENGLISH);
            }
            str.hashCode();
            str.hashCode();
            switch (str.hashCode()) {
                case -1352032154:
                    if (str.equals("tobottom")) {
                        c = 0;
                        break;
                    }
                    c = 65535;
                    break;
                case -1137407871:
                    if (str.equals("toright")) {
                        c = 1;
                        break;
                    }
                    c = 65535;
                    break;
                case -868157182:
                    if (str.equals("toleft")) {
                        c = 2;
                        break;
                    }
                    c = 65535;
                    break;
                case -172068863:
                    if (str.equals("totopleft")) {
                        c = 3;
                        break;
                    }
                    c = 65535;
                    break;
                case 110550266:
                    break;
                case 1176531318:
                    if (str.equals("tobottomright")) {
                        c = 5;
                        break;
                    }
                    c = 65535;
                    break;
                default:
                    c = 65535;
                    break;
            }
            switch (c) {
                case 0:
                    fArr[3] = f2;
                    break;
                case 1:
                    fArr[2] = f;
                    break;
                case 2:
                    fArr[0] = f;
                    break;
                case 3:
                    fArr[0] = f;
                    fArr[1] = f2;
                    break;
                case 4:
                    fArr[1] = f2;
                    break;
                case 5:
                    fArr[2] = f;
                    fArr[3] = f2;
                    break;
                default:
                    return null;
            }
            return fArr;
        }

        private List<String> parseGradientValues(String str) {
            String nextToken;
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            str.trim();
            try {
                if (str.startsWith("linear-gradient")) {
                    StringTokenizer stringTokenizer = new StringTokenizer(str.substring(str.indexOf(Operators.BRACKET_START_STR) + 1, str.lastIndexOf(Operators.BRACKET_END_STR)), ",");
                    ArrayList arrayList = new ArrayList();
                    while (true) {
                        String str2 = null;
                        while (stringTokenizer.hasMoreTokens()) {
                            nextToken = stringTokenizer.nextToken();
                            if (nextToken.contains(Operators.BRACKET_START_STR)) {
                                str2 = nextToken + ",";
                            } else if (nextToken.contains(Operators.BRACKET_END_STR)) {
                                break;
                            } else if (str2 != null) {
                                str2 = str2 + nextToken + ",";
                            } else {
                                arrayList.add(nextToken);
                            }
                        }
                        return arrayList;
                        arrayList.add(str2 + nextToken);
                    }
                }
            } catch (Exception unused) {
            }
            return null;
        }

        private Bitmap scaleBitmap(Bitmap bitmap, int i, int i2) {
            if (bitmap == null) {
                return null;
            }
            if (this.repeatType.equals("repeat")) {
                return bitmap;
            }
            int height = bitmap.getHeight();
            int width = bitmap.getWidth();
            float f = i / width;
            float f2 = i2 / height;
            Matrix matrix = new Matrix();
            if (this.repeatType.equals("repeat-x")) {
                matrix.preScale(1.0f, f2);
            } else if (this.repeatType.equals("repeat-y")) {
                matrix.preScale(f, 1.0f);
            } else {
                matrix.preScale(f, f2);
            }
            Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
            if (!bitmap.isRecycled()) {
                bitmap.recycle();
            }
            return createBitmap;
        }

        @Override
        public void draw(Canvas canvas) {
            updatebound();
            if (this.mBackgroundBitmap != null) {
                getPaint().setShader(this.mBackgroundBitmap);
                getBackgroundColorPaint().setColor(Color.argb(getBackgroundColorPaint().getAlpha(), 255, 255, 255));
                canvas.drawRect(this.bound, getBackgroundColorPaint());
            } else {
                String str = this.bitmapPath;
                if (str != null) {
                    setBackgroundImage(str);
                    this.bitmapPath = null;
                    getPaint().setShader(this.mBackgroundBitmap);
                    getBackgroundColorPaint().setColor(Color.argb(getBackgroundColorPaint().getAlpha(), 255, 255, 255));
                    canvas.drawRect(this.bound, getBackgroundColorPaint());
                } else {
                    getPaint().setColor(this.mBackgroundColor);
                }
            }
            canvas.drawRect(this.bound, getPaint());
            if (!PdrUtil.isEmpty(this.shadowColor)) {
                Rect rect = this.bound;
                int i = rect.left;
                int i2 = rect.bottom;
                int i3 = rect.right;
                int i4 = this.height;
                if (i4 == 0) {
                    i4 = this.shadow5PX;
                }
                Rect rect2 = new Rect(i, i2, i3, i4 + i2 + this.offset);
                Paint shadowPaint = getShadowPaint();
                int i5 = rect2.top;
                int i6 = this.offset;
                shadowPaint.setShader(new LinearGradient(0.0f, i5 - i6, 0.0f, rect2.bottom - i6, this.shadowColorInt, 0, Shader.TileMode.CLAMP));
                canvas.drawRect(rect2, getShadowPaint());
            }
            if (this.mBackgroundBitmap != null) {
                getPaint().setShader(null);
            }
        }

        public Paint getBackgroundColorPaint() {
            if (this.colorPaint == null) {
                this.colorPaint = new Paint();
            }
            return this.colorPaint;
        }

        @Override
        public int getOpacity() {
            return 0;
        }

        public Paint getPaint() {
            if (this.mPaint == null) {
                this.mPaint = new Paint(1);
            }
            return this.mPaint;
        }

        @Override
        public void setAlpha(int i) {
            if (this.mBackgroundBitmap == null && this.bitmapPath == null) {
                return;
            }
            getPaint().setAlpha(i);
            getBackgroundColorPaint().setAlpha(i);
        }

        public void setBackgroundColor(int i) {
            if (this.mBackgroundBitmap != null) {
                setAlpha(Color.alpha(i));
            }
            this.mBackgroundColor = i;
            getShadowPaint().setAlpha(Color.alpha(i));
            invalidateSelf();
        }

        public void setBackgroundImage(String str) {
            Bitmap bitmap;
            Bitmap scaleBitmap;
            Rect rect = this.bound;
            if (rect == null || rect.width() == 0) {
                this.bitmapPath = str;
            } else if (str == null) {
            } else {
                List<String> parseGradientValues = parseGradientValues(str);
                if (parseGradientValues != null && parseGradientValues.size() == 3) {
                    this.mBackgroundBitmap = getShader(parseGradientValues, this.bound.width(), this.bound.height());
                } else {
                    String convert2AbsFullPath = TitleNView.this.mWebView.obtainApp().convert2AbsFullPath(TitleNView.this.mWebView.obtainFullUrl(), str);
                    if (!PdrUtil.isDeviceRootDir(convert2AbsFullPath)) {
                        try {
                            bitmap = BitmapFactory.decodeStream(TitleNView.this.mWebView.getContext().getAssets().open(convert2AbsFullPath));
                        } catch (Exception unused) {
                            bitmap = null;
                        }
                    } else {
                        bitmap = BitmapFactory.decodeFile(convert2AbsFullPath);
                    }
                    if (bitmap == null) {
                        this.mBackgroundBitmap = null;
                        this.bitmapPath = null;
                        invalidateSelf();
                        return;
                    }
                    byte[] ninePatchChunk = bitmap.getNinePatchChunk();
                    if (ninePatchChunk != null && NinePatch.isNinePatchChunk(ninePatchChunk)) {
                        NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(bitmap, ninePatchChunk, new Rect(), null);
                        scaleBitmap = Bitmap.createBitmap(this.bound.width(), this.bound.height(), Bitmap.Config.ARGB_8888);
                        Canvas canvas = new Canvas(scaleBitmap);
                        ninePatchDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
                        ninePatchDrawable.draw(canvas);
                    } else {
                        scaleBitmap = scaleBitmap(bitmap, this.bound.width(), this.bound.height());
                    }
                    if (scaleBitmap == null) {
                        this.mBackgroundBitmap = null;
                    } else {
                        Shader.TileMode tileMode = Shader.TileMode.REPEAT;
                        this.mBackgroundBitmap = new BitmapShader(scaleBitmap, tileMode, tileMode);
                    }
                }
                invalidateSelf();
            }
        }

        @Override
        public void setColorFilter(ColorFilter colorFilter) {
        }

        public void setRepeatType(String str, String str2) {
            if (PdrUtil.isEmpty(str) || this.repeatType.equals(str)) {
                return;
            }
            this.repeatType = str;
            this.mBackgroundBitmap = null;
            updatebound();
            setBackgroundImage(str2);
        }

        public void setShadowColor(JSONObject jSONObject) {
            String optString = jSONObject.has("color") ? jSONObject.optString("color") : "";
            String optString2 = jSONObject.has("height") ? jSONObject.optString("height") : "10px";
            String optString3 = jSONObject.has("offset") ? jSONObject.optString("offset") : "0px";
            TitleNView titleNView = TitleNView.this;
            this.height = PdrUtil.convertToScreenInt(optString2, titleNView.mInnerWidth, 0, titleNView.mCreateScale);
            TitleNView titleNView2 = TitleNView.this;
            this.offset = PdrUtil.convertToScreenInt(optString3, titleNView2.mInnerWidth, 0, titleNView2.mCreateScale);
            if (optString.equals(this.shadowColor)) {
                return;
            }
            this.shadowColor = optString;
            this.shadowColorInt = PdrUtil.stringToColor(optString);
            invalidateSelf();
        }

        public void updatebound() {
            View view;
            if (this.bound == null) {
                this.bound = new Rect();
            }
            TitleNView titleNView = TitleNView.this;
            if (titleNView.isImmersed && titleNView.isStatusBarHas()) {
                this.bound.top = DeviceInfo.sStatusBarHeight;
            } else {
                this.bound.top = 0;
            }
            TitleNView titleNView2 = TitleNView.this;
            if (titleNView2.isStatusBar && (view = titleNView2.mStatusbarView) != null && view.getVisibility() == 0) {
                this.bound.top = DeviceInfo.sStatusBarHeight;
            }
            Rect rect = this.bound;
            TitleNView titleNView3 = TitleNView.this;
            int i = titleNView3.mInnerHeight;
            rect.bottom = rect.top + i;
            if (titleNView3.isStatusBar && titleNView3.isImmersed) {
                rect.bottom = i + DeviceInfo.sStatusBarHeight;
            }
            rect.left = 0;
            rect.right = getBounds().right;
        }
    }

    static class IWebviewStateListenerImpl implements IWebviewStateListener {
        private SoftReference<Progress> mProgress;

        public IWebviewStateListenerImpl(Progress progress) {
            this.mProgress = new SoftReference<>(progress);
        }

        @Override
        public Object onCallBack(int i, Object obj) {
            if (this.mProgress.get() == null || this.mProgress.get().getParent() == null || this.mProgress.get().getVisibility() != 0) {
                return null;
            }
            if (i == 3) {
                this.mProgress.get().updateProgress(((Integer) obj).intValue());
                return null;
            } else if ((i != 1 && i != 5) || this.mProgress.get() == null || this.mProgress.get().isFinish()) {
                return null;
            } else {
                this.mProgress.get().finishProgress();
                return null;
            }
        }
    }

    static class Progress extends DCProgressView {
        Progress(Context context) {
            super(context);
        }
    }

    private class SearchInputDrawable extends Drawable {
        private Paint mPaint;
        private int radius;

        public SearchInputDrawable(int i, int i2) {
            Paint paint = new Paint();
            this.mPaint = paint;
            paint.setAntiAlias(true);
            this.mPaint.setColor(i);
            this.radius = i2;
        }

        @Override
        public void draw(Canvas canvas) {
            RectF rectF = new RectF(getBounds());
            float f = this.radius;
            canvas.drawRoundRect(rectF, f, f, this.mPaint);
        }

        @Override
        public int getAlpha() {
            return this.mPaint.getAlpha();
        }

        public int getDrawableColor() {
            Paint paint = this.mPaint;
            if (paint != null) {
                return paint.getColor();
            }
            return 0;
        }

        @Override
        public int getOpacity() {
            return -3;
        }

        @Override
        public void setAlpha(int i) {
            this.mPaint.setAlpha(i);
            invalidateSelf();
        }

        @Override
        public void setColorFilter(ColorFilter colorFilter) {
            this.mPaint.setColorFilter(colorFilter);
            invalidateSelf();
        }

        public void setDrawableColor(int i) {
            Paint paint = this.mPaint;
            if (paint != null) {
                paint.setColor(i);
            }
            invalidateSelf();
        }
    }

    public TitleNView(Context context, IWebview iWebview, String str, String str2, JSONObject jSONObject) {
        super(context, iWebview, str, str2, jSONObject);
        this.mTitleView = null;
        this.mBackButton = null;
        this.mHomeButton = null;
        this.mTitleNViewLayout = null;
        this.mLeftButtonLayout = null;
        this.mRightButtonLayout = null;
        this.centerSearchLayout = null;
        this.mButtons = new ArrayList<>();
        this.mMenuButtonTextColor = -16777216;
        this.mMenuButtonFontSize = "22px";
        this.mMenuButtonFontWeight = "normal";
        this.maxButton = 2;
        this.mBlurEffect = "none";
        this.isSetText = new AtomicBoolean(false);
        this.menuBt = null;
        this.closeBt = null;
        this.CLOSE = "close";
        this.MENU = AbsoluteConst.EVENTS_MENU;
        setTag("titleNView");
        if (SDK.isUniMPSDK()) {
            initCapsuleLayout();
        }
    }

    private void addButtonOnClickListener(final String str, final IWebview iWebview, View view) {
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                TitleNView.this.buttonOnclick(str, iWebview);
            }
        });
    }

    private TextView addSelect(ViewGroup viewGroup, TextView textView, int i) {
        TextView textView2 = new TextView(getContext());
        textView2.setText("\ue661");
        textView2.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/dcloud_iconfont.ttf"));
        textView2.setSingleLine();
        textView2.setLines(1);
        textView2.setGravity(17);
        textView2.setIncludeFontPadding(false);
        textView2.getPaint().setTextSize(PdrUtil.convertToScreenInt("15px", this.mInnerWidth, i, this.mCreateScale));
        viewGroup.addView(textView2, new LinearLayout.LayoutParams(-2, -1));
        return textView2;
    }

    public void buttonOnclick(String str, IWebview iWebview) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        if (str.toLowerCase(Locale.ENGLISH).startsWith(AbsoluteConst.PROTOCOL_JAVASCRIPT)) {
            IFrameView iFrameView = this.mFrameViewParent;
            if (iFrameView != null && iFrameView.obtainWindowMgr() != null && this.mFrameViewParent.obtainApp() != null) {
                Object processEvent = this.mFrameViewParent.obtainWindowMgr().processEvent(IMgr.MgrType.WindowMgr, 47, this.mFrameViewParent.obtainApp().obtainAppId());
                if (processEvent instanceof IFrameView) {
                    IFrameView iFrameView2 = (IFrameView) processEvent;
                    if (iFrameView2.obtainWebView() != null && iFrameView2.obtainWebView().obtainWindowView() != null) {
                        iFrameView2.obtainWebView().loadUrl(str);
                        return;
                    }
                }
            }
            IWebview iWebview2 = this.mWebView;
            if (iWebview2 != null && iWebview2.obtainWindowView() != null) {
                this.mWebView.loadUrl(str);
                return;
            } else if (iWebview != null && iWebview.obtainWindowView() != null) {
                iWebview.loadUrl(str);
                return;
            }
        }
        if (iWebview != null) {
            Deprecated_JSUtil.execCallback(iWebview, str, "", JSUtil.OK, false, true);
            if (iWebview.getOpener() != null) {
                Deprecated_JSUtil.execCallback(iWebview.getOpener(), str, "", JSUtil.OK, false, true);
            }
        }
    }

    private void caculateTitleMargin() {
        RelativeLayout relativeLayout = this.mTitlelayout;
        if (relativeLayout != null && relativeLayout.getVisibility() == 0) {
            int convertToScreenInt = PdrUtil.convertToScreenInt("10px", this.mInnerWidth, 0, this.mCreateScale);
            initLeftButtonLayout();
            initRightButtonLayout();
            int width = this.mLeftButtonLayout.getWidth();
            int width2 = this.mRightButtonLayout.getWidth();
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.mTitlelayout.getLayoutParams();
            int i = convertToScreenInt / 2;
            int i2 = this.mInnerHeight - i;
            TextView textView = this.mTitleView;
            float measureText = textView != null ? textView.getPaint().measureText("张磊 ") : 0.0f;
            int i3 = layoutParams.rightMargin;
            int min = ((int) Math.min(((this.mTitleNViewLayout.getWidth() - i2) - measureText) / 2.0f, Math.max(width, width2))) + i;
            if (i3 == min) {
                return;
            }
            int[] rules = layoutParams.getRules();
            if (rules != null && rules.length > 0 && rules[1] > 0) {
                layoutParams.rightMargin = min;
            } else {
                layoutParams.rightMargin = min;
                layoutParams.leftMargin = min;
            }
            this.mTitlelayout.setLayoutParams(layoutParams);
            this.mTitlelayout.bringToFront();
        }
    }

    public void capsuleButtonClick(String str) {
        IWebview iWebview = this.mWebView;
        if (iWebview == null || iWebview.obtainFrameView() == null) {
            return;
        }
        str.hashCode();
        if (str.equals(AbsoluteConst.EVENTS_MENU)) {
            Bundle bundle = new Bundle();
            bundle.putString("appid", this.mWebView.obtainApp().obtainAppId());
            bundle.putString("type", AbsoluteConst.EVENTS_MENU);
            IWebview iWebview2 = this.mWebView;
            iWebview2.obtainFrameView().obtainWindowMgr().processEvent(IMgr.MgrType.WindowMgr, 80, new Object[]{iWebview2, bundle});
            if (UniMPConfig.isCapsuleMenuIntercept) {
                return;
            }
            showCapsuleMenu(getMenuArray());
        } else if (!str.equals("close")) {
            throw new IllegalStateException("Unexpected value: " + str);
        } else {
            Bundle bundle2 = new Bundle();
            bundle2.putString("appid", this.mWebView.obtainApp().obtainAppId());
            bundle2.putString("type", "close");
            IWebview iWebview3 = this.mWebView;
            Object[] objArr = {iWebview3, bundle2};
            AbsMgr obtainWindowMgr = iWebview3.obtainFrameView().obtainWindowMgr();
            IMgr.MgrType mgrType = IMgr.MgrType.WindowMgr;
            obtainWindowMgr.processEvent(mgrType, 80, objArr);
            if (UniMPConfig.isCapsuleCloseIntercept) {
                return;
            }
            this.mWebView.obtainFrameView().obtainWindowMgr().processEvent(mgrType, 20, this.mWebView.obtainApp().obtainAppId());
        }
    }

    private View createButton(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, IWebview iWebview, String str9, String str10, boolean z, String str11, boolean z2, String str12, String str13) {
        int stringToColor;
        int stringToColor2;
        String str14;
        int stringToColor3;
        int convertToScreenInt;
        BadgeRelateiveLayout badgeRelateiveLayout = new BadgeRelateiveLayout(this, getContext(), this.mCreateScale, this.redDotColor);
        badgeRelateiveLayout.setOrientation(0);
        badgeRelateiveLayout.setGravity(17);
        badgeRelateiveLayout.setPadding(0, 0, 0, 0);
        TextView textView = new TextView(getContext());
        textView.setGravity(17);
        StringBuilder sb = new StringBuilder();
        sb.append("TitleNView.Button.");
        sb.append(str == null ? "" : str);
        textView.setTag(sb.toString());
        textView.setId(View.generateViewId());
        textView.setSingleLine();
        textView.setLines(1);
        textView.setIncludeFontPadding(false);
        if (!PdrUtil.isEmpty(str12) && (convertToScreenInt = PdrUtil.convertToScreenInt(str12, this.mAppScreenWidth, 0, this.mCreateScale)) > 0) {
            textView.setEllipsize(TextUtils.TruncateAt.END);
            textView.setMaxWidth(convertToScreenInt);
        }
        try {
            stringToColor = Color.parseColor(str2);
        } catch (Exception unused) {
            stringToColor = PdrUtil.stringToColor(str2);
        }
        int i = stringToColor;
        try {
            stringToColor2 = Color.parseColor(str3);
        } catch (Exception unused2) {
            stringToColor2 = PdrUtil.stringToColor(str3);
        }
        int i2 = stringToColor2;
        textView.setTextColor(createColorStateList(i, i2));
        if (Constants.Value.BOLD.equals(str4)) {
            textView.getPaint().setFakeBoldText(true);
        }
        setTextAndFont(str, str6, str7, textView, TextUtils.isEmpty(str7));
        if (TextUtils.isEmpty(str5)) {
            str14 = "transparent".equals(str9) ? "22px" : "27px";
        } else {
            str14 = "17px";
        }
        int convertToScreenInt2 = PdrUtil.convertToScreenInt(str14, this.mInnerWidth, 0, this.mCreateScale);
        textView.getPaint().setTextSize(PdrUtil.convertToScreenInt(str5, this.mInnerWidth, convertToScreenInt2, this.mCreateScale));
        try {
            stringToColor3 = Color.parseColor(str10);
        } catch (Exception unused3) {
            stringToColor3 = PdrUtil.stringToColor(str10);
        }
        NativeViewBackButtonDrawable nativeViewBackButtonDrawable = new NativeViewBackButtonDrawable("transparent".equals(str9) ? stringToColor3 : 0);
        nativeViewBackButtonDrawable.setWidth(str13);
        badgeRelateiveLayout.addView(textView, new LinearLayout.LayoutParams(-2, -1, 1.0f));
        if (z2) {
            addSelect(badgeRelateiveLayout, textView, convertToScreenInt2).setTextColor(createColorStateList(i, i2));
            textView.setEllipsize(TextUtils.TruncateAt.END);
        }
        badgeRelateiveLayout.setBackground(nativeViewBackButtonDrawable);
        addButtonOnClickListener(str8, iWebview, badgeRelateiveLayout);
        badgeRelateiveLayout.setBadgeStr(str11);
        badgeRelateiveLayout.setDrawRedDot(z);
        this.mButtons.add(badgeRelateiveLayout);
        return badgeRelateiveLayout;
    }

    private TextView getCapsuleButton(String str) {
        TextView textView = new TextView(getContext());
        textView.setGravity(17);
        textView.setId(View.generateViewId());
        textView.setSingleLine();
        textView.setLines(1);
        textView.setIncludeFontPadding(false);
        textView.getPaint().setFakeBoldText(true);
        textView.getPaint().setTextSize(PdrUtil.convertToScreenInt("19px", this.mInnerWidth, 0, this.mCreateScale));
        Typeface createFromAsset = Typeface.createFromAsset(getContext().getAssets(), "fonts/dcloud_iconfont.ttf");
        if (createFromAsset != null) {
            textView.setTypeface(createFromAsset);
        }
        return textView;
    }

    private String getIconPath(String str) {
        if (PdrUtil.isNetPath(str)) {
            return str;
        }
        String convert2AbsFullPath = this.mApp.convert2AbsFullPath(this.mWebView.obtainFullUrl(), str);
        if (convert2AbsFullPath != null && PdrUtil.isDeviceRootDir(convert2AbsFullPath)) {
            return DeviceInfo.FILE_PROTOCOL + convert2AbsFullPath;
        }
        if (convert2AbsFullPath != null && convert2AbsFullPath.startsWith("/") && convert2AbsFullPath.length() > 1) {
            convert2AbsFullPath = convert2AbsFullPath.substring(1);
        }
        return SDK.ANDROID_ASSET + convert2AbsFullPath;
    }

    private JSONArray getMenuArray() {
        JSONObject jSONObject;
        JSONArray jSONArray = new JSONArray();
        for (int i = 0; i < this.mMenuButtons.size(); i++) {
            ButtonDataItem buttonDataItem = this.mMenuButtons.get(i);
            JSONObject jSONObject2 = new JSONObject();
            try {
                jSONObject2.put("title", TextUtils.isEmpty(buttonDataItem.getTitle()) ? buttonDataItem.getText() : buttonDataItem.getTitle());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            jSONArray.put(jSONObject2);
        }
        if (this.mMenuButtons.size() > 0) {
            JSONObject jSONObject3 = new JSONObject();
            try {
                jSONObject3.put("title", "");
                jSONObject3.put("type", "interval");
                jSONArray.put(jSONObject3);
            } catch (JSONException e2) {
                e2.printStackTrace();
            }
        }
        if (SDK.sDefaultMenuButton != null) {
            try {
                JSONObject jSONObject4 = new JSONObject(SDK.sDefaultMenuButton);
                if (jSONObject4.has(AbsoluteConst.EVENTS_MENU) && (jSONObject = jSONObject4.getJSONObject(AbsoluteConst.EVENTS_MENU)) != null && jSONObject.has("buttons")) {
                    JSONArray jSONArray2 = jSONObject.getJSONArray("buttons");
                    for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
                        jSONArray.put(jSONArray2.getJSONObject(i2));
                    }
                }
            } catch (JSONException e3) {
                e3.printStackTrace();
            }
        }
        return jSONArray;
    }

    private void initCapsuleLayout() {
        JSONObject jSONObject;
        if (this.mCapsuleLayout == null && SDK.isCapsule) {
            this.mMenuButtons = new ArrayList<>();
            int convertToScreenInt = this.mInnerHeight - PdrUtil.convertToScreenInt("12px", this.mAppScreenWidth, 0, this.mCreateScale);
            CapsuleLayout capsuleLayout = new CapsuleLayout(getContext(), convertToScreenInt / 2);
            this.mCapsuleLayout = capsuleLayout;
            capsuleLayout.setId(View.generateViewId());
            this.mCapsuleLayout.setGravity(16);
            this.mCapsuleLayout.setOrientation(0);
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, convertToScreenInt);
            layoutParams.addRule(15);
            layoutParams.addRule(11);
            float f = this.mCreateScale;
            int i = (int) (13.0f * f);
            int i2 = (int) (f * 10.0f);
            layoutParams.rightMargin = i;
            initTitleNViewLayout();
            this.mTitleNViewLayout.addView(this.mCapsuleLayout, layoutParams);
            if (this.menuBt == null) {
                TextView capsuleButton = getCapsuleButton(AbsoluteConst.EVENTS_MENU);
                this.menuBt = capsuleButton;
                capsuleButton.setText("\ue606");
            }
            this.menuBt.setTextColor(-16777216);
            LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-2, -2);
            layoutParams2.leftMargin = i;
            layoutParams2.gravity = 17;
            layoutParams2.rightMargin = i2;
            this.mCapsuleLayout.addButtonView(this.menuBt, layoutParams2, CapsuleLayout.ButtonType.LIFT, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    TitleNView.this.capsuleButtonClick(AbsoluteConst.EVENTS_MENU);
                }
            });
            this.mCapsuleLayout.addIntervalView(this.mCreateScale);
            if (this.closeBt == null) {
                TextView capsuleButton2 = getCapsuleButton("close");
                this.closeBt = capsuleButton2;
                capsuleButton2.setText("\ue650");
            }
            this.closeBt.setTextColor(-16777216);
            LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(-2, -2);
            layoutParams3.rightMargin = i;
            layoutParams3.gravity = 17;
            layoutParams3.leftMargin = i2;
            this.mCapsuleLayout.addButtonView(this.closeBt, layoutParams3, CapsuleLayout.ButtonType.RIGHT, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    TitleNView.this.capsuleButtonClick("close");
                }
            });
            if (TextUtils.isEmpty(SDK.sDefaultMenuButton)) {
                return;
            }
            try {
                JSONObject jSONObject2 = new JSONObject(SDK.sDefaultMenuButton);
                if (jSONObject2.has(AbsoluteConst.EVENTS_MENU) && (jSONObject = jSONObject2.getJSONObject(AbsoluteConst.EVENTS_MENU)) != null) {
                    if (jSONObject.has("textColor")) {
                        this.mMenuButtonTextColor = PdrUtil.stringToColor(jSONObject.getString("textColor"));
                    }
                    if (jSONObject.has(Constants.Name.FONT_SIZE) && !TextUtils.isEmpty(jSONObject.getString(Constants.Name.FONT_SIZE))) {
                        this.mMenuButtonFontSize = jSONObject.getString(Constants.Name.FONT_SIZE);
                    }
                    if (jSONObject.has(Constants.Name.FONT_WEIGHT)) {
                        if (Constants.Value.BOLD.equals(jSONObject.getString(Constants.Name.FONT_WEIGHT))) {
                            this.mMenuButtonFontWeight = Constants.Value.BOLD;
                        } else {
                            this.mMenuButtonFontWeight = "normal";
                        }
                    }
                }
                if (jSONObject2.has("capsuleButtonStyle")) {
                    setCapsuleButtonStyle(jSONObject2.getJSONObject("capsuleButtonStyle"));
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    private void initCenterSearchLayout() {
        if (this.centerSearchLayout == null) {
            LinearLayout linearLayout = new LinearLayout(getContext());
            this.centerSearchLayout = linearLayout;
            linearLayout.setId(View.generateViewId());
            this.centerSearchLayout.setGravity(16);
            this.centerSearchLayout.setOrientation(0);
            this.centerSearchLayout.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, this.mInnerHeight - PdrUtil.convertToScreenInt("12px", this.mAppScreenWidth, 0, this.mCreateScale));
            LinearLayout linearLayout2 = this.mRightButtonLayout;
            if (linearLayout2 != null) {
                layoutParams.addRule(0, linearLayout2.getId());
            } else {
                layoutParams.addRule(11);
            }
            LinearLayout linearLayout3 = this.mLeftButtonLayout;
            if (linearLayout3 != null) {
                layoutParams.addRule(1, linearLayout3.getId());
            } else {
                layoutParams.addRule(9);
            }
            layoutParams.addRule(15);
            layoutParams.rightMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
            layoutParams.leftMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
            this.mTitleNViewLayout.addView(this.centerSearchLayout, layoutParams);
        }
    }

    private void initLeftButtonLayout() {
        if (this.mLeftButtonLayout == null) {
            LinearLayout linearLayout = new LinearLayout(getContext());
            this.mLeftButtonLayout = linearLayout;
            linearLayout.setId(View.generateViewId());
            this.mLeftButtonLayout.setGravity(16);
            this.mLeftButtonLayout.setOrientation(0);
            this.mLeftButtonLayout.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -1);
            layoutParams.addRule(15);
            layoutParams.addRule(9);
            this.mTitleNViewLayout.addView(this.mLeftButtonLayout, layoutParams);
        }
    }

    private void initRightButtonLayout() {
        if (this.mRightButtonLayout == null) {
            LinearLayout linearLayout = new LinearLayout(getContext());
            this.mRightButtonLayout = linearLayout;
            linearLayout.setId(View.generateViewId());
            this.mRightButtonLayout.setGravity(16);
            this.mRightButtonLayout.setOrientation(0);
            this.mRightButtonLayout.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -1);
            layoutParams.addRule(15);
            CapsuleLayout capsuleLayout = this.mCapsuleLayout;
            if (capsuleLayout != null) {
                layoutParams.addRule(0, capsuleLayout.getId());
            } else {
                layoutParams.addRule(11);
            }
            this.mTitleNViewLayout.addView(this.mRightButtonLayout, layoutParams);
        }
    }

    private void initTitleNViewLayout() {
        boolean z;
        IFrameView iFrameView;
        if (this.mTitleNViewLayout == null) {
            this.mTitleNViewLayout = new RelativeLayout(getContext());
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, this.mInnerHeight);
            ViewParent parent = getParent();
            int i = 0;
            if (!TextUtils.equals(this.mStyle.optString("position", AbsoluteConst.JSON_VALUE_POSITION_ABSOLUTE), AbsoluteConst.JSON_VALUE_POSITION_ABSOLUTE) && parent != null && (parent instanceof ViewGroup)) {
                int i2 = 0;
                while (true) {
                    ViewGroup viewGroup = (ViewGroup) parent;
                    if (i2 >= viewGroup.getChildCount()) {
                        break;
                    }
                    Object tag = viewGroup.getChildAt(i2).getTag();
                    if (tag != null && "StatusBar".equalsIgnoreCase(tag.toString())) {
                        z = true;
                        break;
                    }
                    i2++;
                }
            }
            z = false;
            if (!z && (iFrameView = this.mFrameViewParent) != null && iFrameView.obtainApp().obtainStatusBarMgr().isImmersive) {
                i = 0 + DeviceInfo.sStatusBarHeight;
            }
            layoutParams.topMargin = i;
            addView(this.mTitleNViewLayout, layoutParams);
        }
    }

    public static boolean isBase64Image(String str) {
        return Pattern.compile("^data:image/.*;base64,").matcher(str).find();
    }

    public boolean isStatusBarHas() {
        IWebview iWebview = this.mWebView;
        if (iWebview == null || iWebview.obtainFrameView() == null) {
            return false;
        }
        return ((AdaFrameItem) this.mWebView.obtainFrameView()).obtainFrameOptions().isStatusbar;
    }

    private void layoutSubtitleIcon(String str, String str2, String str3, String str4, String str5, String str6, ImageView imageView, TextView textView, int i, String str7, String str8) {
        GifDrawable gifDrawable;
        int convertToScreenInt = PdrUtil.convertToScreenInt("10px", this.mInnerWidth, 0, this.mCreateScale);
        if (-1 == this.mTitlelayout.indexOfChild(imageView)) {
            this.mTitlelayout.addView(imageView);
        }
        if (!PdrUtil.isEmpty(str)) {
            int convertToScreenInt2 = PdrUtil.convertToScreenInt(str8, this.mInnerWidth, 0, this.mCreateScale);
            if (convertToScreenInt2 <= 0) {
                convertToScreenInt2 = this.mInnerHeight - convertToScreenInt;
            }
            int i2 = this.mInnerHeight;
            if (convertToScreenInt2 > i2) {
                convertToScreenInt2 = i2;
            }
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(convertToScreenInt2, convertToScreenInt2);
            layoutParams.addRule(9);
            layoutParams.addRule(15);
            layoutParams.rightMargin = convertToScreenInt / 2;
            int convertToScreenInt3 = PdrUtil.convertToScreenInt(str2, this.mInnerWidth, 0, this.mCreateScale);
            boolean isBase64Image = isBase64Image(str);
            if (!isBase64Image) {
                try {
                    gifDrawable = new GifDrawable(getContext().getContentResolver(), Uri.parse(getIconPath(str)));
                } catch (IOException | Exception unused) {
                    gifDrawable = null;
                }
            } else {
                gifDrawable = new GifDrawable(Base64.decode(str.replaceFirst("^data:image/.*;base64,", ""), 0));
            }
            if (convertToScreenInt3 <= 0) {
                RequestManager with = Glide.with(getContext());
                if (gifDrawable != null) {
                    imageView.setImageDrawable(gifDrawable);
                    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                } else {
                    with.load(isBase64Image ? Base64.decode(str.replaceFirst("^data:image/.*;base64,", ""), 0) : getIconPath(str)).transform(new CenterCrop()).into(imageView);
                }
            } else {
                RequestManager with2 = Glide.with(getContext());
                if (gifDrawable != null) {
                    gifDrawable.setTransform(new GIFCornerRadiusTransform(convertToScreenInt3, convertToScreenInt2));
                    imageView.setImageDrawable(gifDrawable);
                    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                } else {
                    with2.load(isBase64Image ? Base64.decode(str.replaceFirst("^data:image/.*;base64,", ""), 0) : getIconPath(str)).transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(convertToScreenInt3))).into(imageView);
                }
            }
            if (-1 == this.mTitlelayout.indexOfChild(imageView)) {
                this.mTitlelayout.addView(imageView, layoutParams);
            } else {
                imageView.setLayoutParams(layoutParams);
            }
            imageView.setVisibility(0);
        } else {
            imageView.setVisibility(8);
        }
        RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
        layoutParams2.addRule(10);
        if (imageView.getVisibility() != 0 && !str7.equals("left") && !str7.equals("auto")) {
            layoutParams2.addRule(14);
        } else {
            layoutParams2.addRule(1, imageView.getId());
        }
        if (-1 == this.mTitlelayout.indexOfChild(this.mTitleView)) {
            this.mTitlelayout.addView(this.mTitleView, layoutParams2);
        } else {
            this.mTitleView.setLayoutParams(layoutParams2);
        }
        if (-1 == this.mTitlelayout.indexOfChild(textView)) {
            this.mTitlelayout.addView(textView);
        }
        if (!PdrUtil.isEmpty(str3)) {
            RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(-2, -2);
            layoutParams3.addRule(3, this.mTitleView.getId());
            if (imageView.getVisibility() != 0 && !str7.equals("left") && !str7.equals("auto")) {
                layoutParams3.addRule(14);
            } else {
                layoutParams3.addRule(1, imageView.getId());
            }
            textView.setText(str3);
            if ("clip".equals(str6)) {
                textView.setEllipsize(null);
            } else {
                textView.setEllipsize(TextUtils.TruncateAt.END);
            }
            textView.setSingleLine();
            textView.setLines(1);
            textView.setTextColor(PdrUtil.isEmpty(str4) ? i : PdrUtil.stringToColor(str4));
            textView.getPaint().setTextSize(PdrUtil.convertToScreenInt(PdrUtil.isEmpty(str5) ? "12px" : str5, this.mInnerWidth, 0, this.mCreateScale));
            if (-1 == this.mTitlelayout.indexOfChild(textView)) {
                this.mTitlelayout.addView(textView, layoutParams3);
            } else {
                textView.setLayoutParams(layoutParams3);
            }
            textView.setVisibility(0);
        } else {
            textView.setVisibility(8);
        }
        if (textView.getVisibility() == 0) {
            RelativeLayout.LayoutParams layoutParams4 = (RelativeLayout.LayoutParams) this.mTitleView.getLayoutParams();
            layoutParams4.addRule(10);
            layoutParams4.removeRule(15);
            this.mTitleView.setLayoutParams(layoutParams2);
            return;
        }
        RelativeLayout.LayoutParams layoutParams5 = (RelativeLayout.LayoutParams) this.mTitleView.getLayoutParams();
        layoutParams5.removeRule(10);
        layoutParams5.addRule(15);
        this.mTitleView.setLayoutParams(layoutParams2);
    }

    private void setButtonColor(View view, String str, String str2, String str3) {
        int stringToColor;
        int stringToColor2;
        int stringToColor3;
        if (view != null) {
            Drawable background = view.getBackground();
            if (background != null && (background instanceof NativeViewBackButtonDrawable)) {
                try {
                    stringToColor3 = Color.parseColor(str);
                } catch (Exception unused) {
                    stringToColor3 = PdrUtil.stringToColor(str);
                }
                NativeViewBackButtonDrawable nativeViewBackButtonDrawable = (NativeViewBackButtonDrawable) background;
                if (stringToColor3 != nativeViewBackButtonDrawable.getDrawableColor()) {
                    nativeViewBackButtonDrawable.setDrawableColor(stringToColor3);
                }
            }
            try {
                stringToColor = Color.parseColor(str2);
            } catch (Exception unused2) {
                stringToColor = PdrUtil.stringToColor(str2);
            }
            try {
                stringToColor2 = Color.parseColor(str3);
            } catch (Exception unused3) {
                stringToColor2 = PdrUtil.stringToColor(str3);
            }
            if (!(view instanceof RelativeLayout) && !(view instanceof BadgeRelateiveLayout)) {
                if (view instanceof TextView) {
                    TextView textView = (TextView) view;
                    if (stringToColor != textView.getTextColors().getDefaultColor()) {
                        textView.setTextColor(createColorStateList(stringToColor, stringToColor2));
                        return;
                    }
                    return;
                } else if (view instanceof LinearLayout) {
                    LinearLayout linearLayout = (LinearLayout) view;
                    for (int i = 0; i < linearLayout.getChildCount(); i++) {
                        View childAt = linearLayout.getChildAt(i);
                        if (childAt instanceof TextView) {
                            TextView textView2 = (TextView) childAt;
                            if (stringToColor != textView2.getTextColors().getDefaultColor()) {
                                textView2.setTextColor(createColorStateList(stringToColor, stringToColor2));
                            }
                        } else if (childAt instanceof RelativeLayout) {
                            TextView textView3 = (TextView) ((RelativeLayout) childAt).getChildAt(0);
                            if (stringToColor != textView3.getTextColors().getDefaultColor()) {
                                textView3.setTextColor(createColorStateList(stringToColor, stringToColor2));
                            }
                        }
                    }
                    return;
                } else {
                    return;
                }
            }
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) {
                TextView textView4 = (TextView) viewGroup.getChildAt(i2);
                if (stringToColor != textView4.getTextColors().getDefaultColor()) {
                    textView4.setTextColor(createColorStateList(stringToColor, stringToColor2));
                }
            }
        }
    }

    public void setTextAndFont(String str, String str2, String str3, TextView textView, boolean z) {
        Typeface typeface;
        String convert2AbsFullPath;
        if (!z && !str3.equals("none")) {
            typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/dcloud_iconfont.ttf");
            str3.hashCode();
            char c = 65535;
            switch (str3.hashCode()) {
                case -677145915:
                    if (str3.equals("forward")) {
                        c = 0;
                        break;
                    }
                    break;
                case 3015911:
                    if (str3.equals("back")) {
                        c = 1;
                        break;
                    }
                    break;
                case 3208415:
                    if (str3.equals("home")) {
                        c = 2;
                        break;
                    }
                    break;
                case 3347807:
                    if (str3.equals(AbsoluteConst.EVENTS_MENU)) {
                        c = 3;
                        break;
                    }
                    break;
                case 94756344:
                    if (str3.equals("close")) {
                        c = 4;
                        break;
                    }
                    break;
                case 109400031:
                    if (str3.equals("share")) {
                        c = 5;
                        break;
                    }
                    break;
                case 1050790300:
                    if (str3.equals("favorite")) {
                        c = 6;
                        break;
                    }
                    break;
            }
            switch (c) {
                case 0:
                    str = "\ue600";
                    break;
                case 1:
                    str = "\ue601";
                    break;
                case 2:
                    str = "\ue605";
                    break;
                case 3:
                    str = "\ue606";
                    break;
                case 4:
                    str = "\ue650";
                    break;
                case 5:
                    str = "\ue602";
                    break;
                case 6:
                    str = "\ue604";
                    break;
            }
            textView.setText(str);
        } else {
            textView.setText(str);
            if (this.mApp == null || this.mWebView == null || TextUtils.isEmpty(str2)) {
                typeface = null;
            } else {
                if (str2.contains("__wap2app.ttf")) {
                    convert2AbsFullPath = BaseInfo.sBaseWap2AppTemplatePath + "wap2app__template/__wap2app.ttf";
                    if (!new File(convert2AbsFullPath).exists()) {
                        convert2AbsFullPath = this.mWebView.obtainApp().convert2AbsFullPath(this.mWebView.obtainFullUrl(), str2);
                    }
                } else {
                    convert2AbsFullPath = this.mWebView.obtainApp().convert2AbsFullPath(this.mWebView.obtainFullUrl(), str2);
                }
                typeface = NativeTypefaceFactory.getTypeface(this.mWebView.obtainApp(), convert2AbsFullPath);
            }
        }
        if (typeface != null) {
            textView.setTypeface(typeface);
        }
    }

    public void setTextGravity(String str, String str2) {
        char c;
        int hashCode = str.hashCode();
        if (hashCode == -1364013995) {
            if (str.equals("center")) {
                c = 2;
            }
            c = 65535;
        } else if (hashCode != 3317767) {
            if (hashCode == 108511772 && str.equals("right")) {
                c = 1;
            }
            c = 65535;
        } else {
            if (str.equals("left")) {
                c = 0;
            }
            c = 65535;
        }
        if (c == 0) {
            this.searchInput.setGravity(GravityCompat.START);
            this.searchInput.setHint(str2);
        } else if (c != 1) {
            this.searchInput.setGravity(17);
            EditText editText = this.searchInput;
            editText.setHint("\ue660 " + str2);
        } else {
            this.searchInput.setGravity(GravityCompat.END);
            EditText editText2 = this.searchInput;
            editText2.setHint("\ue660 " + str2);
        }
    }

    private void showCapsuleMenu(final JSONArray jSONArray) {
        a aVar;
        try {
            if (Build.VERSION.SDK_INT >= 21) {
                aVar = new a(this.mWebView.getActivity());
            } else {
                aVar = new a(this.mWebView.getActivity(), 16973837);
            }
            aVar.a(new a.b() {
                @Override
                public void initCancelText(TextView textView) {
                    TextPaint paint = textView.getPaint();
                    if (TitleNView.this.mMenuButtonFontWeight.equals(Constants.Value.BOLD)) {
                        paint.setFakeBoldText(true);
                    } else {
                        paint.setFakeBoldText(false);
                    }
                }

                @Override
                public void initTextItem(int i, TextView textView, String str) {
                    if (TitleNView.this.mMenuButtons.size() > i) {
                        ButtonDataItem buttonDataItem = (ButtonDataItem) TitleNView.this.mMenuButtons.get(i);
                        TitleNView.this.setTextAndFont(str, buttonDataItem.getFontSrc(), buttonDataItem.getFontType(), textView, TextUtils.isEmpty(buttonDataItem.getFontType()));
                    } else if (jSONArray.length() > i) {
                        if (jSONArray.optJSONObject(i).optString("type", "").equals("interval")) {
                            textView.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#e5e5e5")));
                            textView.getLayoutParams().height = 10;
                            return;
                        }
                        textView.setText(str);
                    }
                    TextPaint paint = textView.getPaint();
                    if (TitleNView.this.mMenuButtonFontWeight.equals(Constants.Value.BOLD)) {
                        paint.setFakeBoldText(true);
                    } else {
                        paint.setFakeBoldText(false);
                    }
                    textView.setTextColor(TitleNView.this.mMenuButtonTextColor);
                }

                @Override
                public boolean onDismiss(int i) {
                    int i2 = i - 1;
                    return i2 > 0 && jSONArray.length() > i2 && jSONArray.optJSONObject(i2).optString("type", "").equals("interval");
                }

                @Override
                public void onItemClick(int i) {
                    int i2 = i - 1;
                    if (i2 < 0) {
                        return;
                    }
                    if (TitleNView.this.mMenuButtons.size() > i2) {
                        ButtonDataItem buttonDataItem = (ButtonDataItem) TitleNView.this.mMenuButtons.get(i2);
                        if (buttonDataItem != null) {
                            AbsMgr obtainWindowMgr = TitleNView.this.mWebView.obtainFrameView().obtainWindowMgr();
                            IMgr.MgrType mgrType = IMgr.MgrType.FeatureMgr;
                            IApp iApp = TitleNView.this.mApp;
                            Object processEvent = obtainWindowMgr.processEvent(mgrType, 10, new Object[]{iApp, AbsoluteConst.F_UI, "findWebview", new String[]{iApp.obtainAppId(), buttonDataItem.getWebviewUuid()}});
                            IWebview iWebview = null;
                            if (processEvent != null && (processEvent instanceof IWebview)) {
                                iWebview = (IWebview) processEvent;
                            }
                            if (iWebview == null) {
                                iWebview = TitleNView.this.mWebView;
                            }
                            TitleNView.this.buttonOnclick(buttonDataItem.getOnclick(), iWebview);
                        }
                    } else if (jSONArray.length() > i2) {
                        JSONObject optJSONObject = jSONArray.optJSONObject(i2);
                        if (!optJSONObject.optString("type", "").equals("interval") && optJSONObject.has("id")) {
                            String optString = optJSONObject.optString("id");
                            Bundle bundle = new Bundle();
                            bundle.putString("id", optString);
                            bundle.putString("appid", TitleNView.this.mWebView.obtainApp().obtainAppId());
                            IWebview iWebview2 = TitleNView.this.mWebView;
                            iWebview2.obtainFrameView().obtainWindowMgr().processEvent(IMgr.MgrType.WindowMgr, 77, new Object[]{iWebview2, bundle});
                        }
                    }
                }
            });
            aVar.b(getContext().getString(R.string.dcloud_common_cancel)).d(this.mMenuButtonTextColor).a(PdrUtil.parseFloat(this.mMenuButtonFontSize, 0.0f, 0.0f, 1.0f)).a(jSONArray).a(true).b(false).e(0);
            aVar.j();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void updateCapsuleLayout() {
        CapsuleLayout capsuleLayout = this.mCapsuleLayout;
        if (capsuleLayout == null || capsuleLayout.isDiy) {
            return;
        }
        String backgroundColor = getBackgroundColor();
        if (TextUtils.isEmpty(backgroundColor)) {
            return;
        }
        if (this.mCapsuleLayout.checkColorToStyle(PdrUtil.stringToColor(backgroundColor)) == 1) {
            this.closeBt.setTextColor(-16777216);
            this.menuBt.setTextColor(-16777216);
            return;
        }
        this.closeBt.setTextColor(-1);
        this.menuBt.setTextColor(-1);
    }

    @Override
    public void addBackButton(String str, String str2, String str3, JSONObject jSONObject) {
        TextView textView;
        TextView textView2;
        TextView textView3;
        String str4;
        String str5;
        int stringToColor;
        int stringToColor2;
        initTitleNViewLayout();
        initLeftButtonLayout();
        BadgeLinearLayout badgeLinearLayout = this.mBackButton;
        boolean z = true;
        if (badgeLinearLayout == null) {
            BadgeLinearLayout badgeLinearLayout2 = new BadgeLinearLayout(this, getContext(), this.mCreateScale, this.redDotColor);
            this.mBackButton = badgeLinearLayout2;
            badgeLinearLayout2.setContentDescription(getResources().getString(R.string.dcloud_titlenview_back_button_description));
            this.mBackButton.setTag("TitleNView.BackButton");
            this.mBackButton.setGravity(17);
            textView = new TextView(getContext());
            textView.setGravity(17);
            textView.setId(View.generateViewId());
            textView.setIncludeFontPadding(false);
            textView2 = new TextView(getContext());
            textView2.setGravity(17);
            textView2.setIncludeFontPadding(false);
            textView3 = new TextView(getContext());
            textView3.setGravity(17);
            textView3.setIncludeFontPadding(false);
            textView3.setTextColor(-1);
            textView3.setVisibility(8);
            RelativeLayout relativeLayout = new RelativeLayout(getContext());
            relativeLayout.setGravity(16);
            this.mBackButton.addView(textView, new LinearLayout.LayoutParams(-2, 500));
            this.mBackButton.addView(relativeLayout, new LinearLayout.LayoutParams(-2, -1));
            relativeLayout.addView(textView2, new RelativeLayout.LayoutParams(-2, -1));
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
            layoutParams.addRule(15);
            relativeLayout.addView(textView3, layoutParams);
        } else {
            textView = (TextView) badgeLinearLayout.getChildAt(0);
            RelativeLayout relativeLayout2 = (RelativeLayout) this.mBackButton.getChildAt(1);
            textView2 = (TextView) relativeLayout2.getChildAt(0);
            textView3 = (TextView) relativeLayout2.getChildAt(1);
        }
        IFrameView iFrameView = this.mFrameViewParent;
        if (iFrameView != null && 5 == iFrameView.getFrameType()) {
            textView.setText((jSONObject == null || !jSONObject.has("text")) ? "\ue650" : jSONObject.optString("text"));
        } else {
            textView.setText((jSONObject == null || !jSONObject.has("text")) ? "\ue601" : jSONObject.optString("text"));
        }
        textView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/dcloud_iconfont.ttf"));
        textView2.setText((jSONObject == null || !jSONObject.has("title")) ? "" : jSONObject.optString("title"));
        this.mBackButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Activity activity;
                IApp iApp = TitleNView.this.mApp;
                if (iApp == null || (activity = iApp.getActivity()) == null) {
                    return;
                }
                activity.onBackPressed();
            }
        });
        String str6 = "16px";
        if ("transparent".equals(str3)) {
            textView.getPaint().setTextSize(PdrUtil.convertToScreenInt((jSONObject == null || !jSONObject.has(Constants.Name.FONT_SIZE)) ? "22px" : jSONObject.optString(Constants.Name.FONT_SIZE), this.mInnerWidth, 0, this.mCreateScale));
            textView2.getPaint().setTextSize(PdrUtil.convertToScreenInt((jSONObject == null || !jSONObject.has("titleSize")) ? "16px" : jSONObject.optString("titleSize"), this.mInnerWidth, 0, this.mCreateScale));
            IFrameView iFrameView2 = this.mFrameViewParent;
            if (iFrameView2 != null && 5 == iFrameView2.getFrameType()) {
                this.mBackButton.setPadding(0, 0, 0, 0);
            } else {
                this.mBackButton.setPadding(0, 0, PdrUtil.convertToScreenInt("2px", this.mInnerWidth, 0, this.mCreateScale), 0);
            }
            NativeViewBackButtonDrawable nativeViewBackButtonDrawable = new NativeViewBackButtonDrawable(PdrUtil.stringToColor((jSONObject == null || !jSONObject.has("background")) ? TitleNViewUtil.TRANSPARENT_BUTTON_BACKGROUND_COLOR : jSONObject.optString("background")));
            nativeViewBackButtonDrawable.setWidth("backButton");
            this.mBackButton.setBackground(nativeViewBackButtonDrawable);
            str4 = TitleNViewUtil.TRANSPARENT_BUTTON_TEXT_COLOR;
            str5 = TitleNViewUtil.changeColorAlpha(TitleNViewUtil.TRANSPARENT_BUTTON_TEXT_COLOR, 0.3f);
        } else {
            textView.getPaint().setTextSize(PdrUtil.convertToScreenInt((jSONObject == null || !jSONObject.has(Constants.Name.FONT_SIZE)) ? "27px" : jSONObject.optString(Constants.Name.FONT_SIZE), this.mInnerWidth, 0, this.mCreateScale));
            textView2.getPaint().setTextSize(PdrUtil.convertToScreenInt((jSONObject == null || !jSONObject.has("titleSize")) ? "16px" : jSONObject.optString("titleSize"), this.mInnerWidth, 0, this.mCreateScale));
            str4 = str;
            str5 = str2;
        }
        if (jSONObject != null && jSONObject.has("badgeSize")) {
            str6 = jSONObject.optString("badgeSize");
        }
        int convertToScreenInt = PdrUtil.convertToScreenInt(str6, this.mInnerWidth, 0, this.mCreateScale);
        textView3.getPaint().setTextSize(convertToScreenInt);
        ViewGroup.LayoutParams layoutParams2 = textView3.getLayoutParams();
        layoutParams2.height = PdrUtil.convertToScreenInt("2px", this.mInnerWidth, 0, this.mCreateScale) + convertToScreenInt;
        textView3.setLayoutParams(layoutParams2);
        textView3.setMinWidth(layoutParams2.height);
        int i = convertToScreenInt / 4;
        textView3.setPadding(i, getPaddingTop(), i, getPaddingBottom());
        String optString = (jSONObject == null || !jSONObject.has(Constants.Name.FONT_WEIGHT)) ? "normal" : jSONObject.optString(Constants.Name.FONT_WEIGHT);
        if (optString.equals("normal")) {
            textView.getPaint().setFakeBoldText(false);
        } else if (optString.equals(Constants.Value.BOLD)) {
            textView.getPaint().setFakeBoldText(true);
        }
        String optString2 = (jSONObject == null || !jSONObject.has("titleWeight")) ? "normal" : jSONObject.optString("titleWeight");
        if (optString2.equals("normal")) {
            textView2.getPaint().setFakeBoldText(false);
        } else if (optString2.equals(Constants.Value.BOLD)) {
            textView2.getPaint().setFakeBoldText(true);
        }
        String str7 = null;
        String optString3 = (jSONObject == null || !jSONObject.has("badgeText")) ? null : jSONObject.optString("badgeText");
        this.mBackButton.setBadgeStr(optString3);
        this.mBackButton.setDrawRedDot((jSONObject != null && jSONObject.has("redDot") && jSONObject.optBoolean("redDot")) ? false : false);
        if (!PdrUtil.isEmpty(optString3)) {
            textView3.setText(optString3, TextView.BufferType.SPANNABLE);
            textView3.setVisibility(0);
        } else {
            textView3.setVisibility(8);
        }
        String optString4 = (jSONObject == null || !jSONObject.has("badgeBackground")) ? null : jSONObject.optString("badgeBackground");
        if (jSONObject != null && jSONObject.has("badgeColor")) {
            str7 = jSONObject.optString("badgeColor");
        }
        GradientDrawable gradientDrawable = new GradientDrawable();
        if (!PdrUtil.isEmpty(optString4)) {
            gradientDrawable.setColor(PdrUtil.stringToColor(optString4));
        } else {
            gradientDrawable.setColor(-65536);
        }
        gradientDrawable.setCornerRadius(layoutParams2.height / 2);
        textView3.setBackground(gradientDrawable);
        if (!PdrUtil.isEmpty(str7)) {
            textView3.setTextColor(PdrUtil.stringToColor(str7));
        }
        try {
            stringToColor = Color.parseColor(str4);
        } catch (Exception unused) {
            stringToColor = PdrUtil.stringToColor(str4);
        }
        try {
            stringToColor2 = Color.parseColor(str5);
        } catch (Exception unused2) {
            stringToColor2 = PdrUtil.stringToColor(str5);
        }
        textView.setTextColor(createColorStateList(stringToColor, stringToColor2));
        textView2.setTextColor(createColorStateList(stringToColor, stringToColor2));
        if (this.mBackButton.getParent() != null) {
            ((ViewGroup) this.mBackButton.getParent()).removeView(this.mBackButton);
        }
        if (-1 == this.mLeftButtonLayout.indexOfChild(this.mBackButton)) {
            int convertToScreenInt2 = this.mInnerHeight - PdrUtil.convertToScreenInt("12px", this.mAppScreenWidth, 0, this.mCreateScale);
            LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(-2, convertToScreenInt2);
            layoutParams3.leftMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
            this.mBackButton.setMinimumWidth(convertToScreenInt2);
            this.mLeftButtonLayout.addView(this.mBackButton, 0, layoutParams3);
        }
        this.mBackButton.setVisibility(0);
        requestLayout();
        caculateTitleMargin();
    }

    @Override
    public void addHomeButton(String str, String str2, String str3) {
        int stringToColor;
        int stringToColor2;
        initTitleNViewLayout();
        initLeftButtonLayout();
        initRightButtonLayout();
        if (this.mHomeButton == null) {
            TextView textView = new TextView(getContext());
            this.mHomeButton = textView;
            textView.setGravity(17);
            this.mHomeButton.setTag("TitleNView.HomeButton");
            this.mHomeButton.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/dcloud_iconfont.ttf"));
            this.mHomeButton.setText("\ue605");
            this.mHomeButton.setIncludeFontPadding(false);
            this.mHomeButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    IApp iApp = TitleNView.this.mApp;
                    if (iApp == null || iApp.getActivity() == null) {
                        return;
                    }
                    TitleNView.this.mFrameViewParent.obtainWebAppRootView().goHome(TitleNView.this.mFrameViewParent);
                }
            });
            if ("transparent".equals(str3)) {
                this.mHomeButton.getPaint().setTextSize(PdrUtil.convertToScreenInt("22px", this.mInnerWidth, 0, this.mCreateScale));
                NativeViewBackButtonDrawable nativeViewBackButtonDrawable = new NativeViewBackButtonDrawable(Color.parseColor(TitleNViewUtil.TRANSPARENT_BUTTON_BACKGROUND_COLOR));
                nativeViewBackButtonDrawable.setWidth("");
                this.mHomeButton.setBackground(nativeViewBackButtonDrawable);
                str = TitleNViewUtil.TRANSPARENT_BUTTON_TEXT_COLOR;
                str2 = TitleNViewUtil.changeColorAlpha(TitleNViewUtil.TRANSPARENT_BUTTON_TEXT_COLOR, 0.3f);
            } else {
                this.mHomeButton.getPaint().setTextSize(PdrUtil.convertToScreenInt("27px", this.mInnerWidth, 0, this.mCreateScale));
            }
            try {
                stringToColor = Color.parseColor(str);
            } catch (Exception unused) {
                stringToColor = PdrUtil.stringToColor(str);
            }
            try {
                stringToColor2 = Color.parseColor(str2);
            } catch (Exception unused2) {
                stringToColor2 = PdrUtil.stringToColor(str2);
            }
            this.mHomeButton.setTextColor(createColorStateList(stringToColor, stringToColor2));
        }
        int convertToScreenInt = this.mInnerHeight - PdrUtil.convertToScreenInt("12px", this.mAppScreenWidth, 0, this.mCreateScale);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(convertToScreenInt, convertToScreenInt);
        if (this.mHomeButton.getParent() != null) {
            ((ViewGroup) this.mHomeButton.getParent()).removeView(this.mHomeButton);
        }
        if (this.mRightButtonLayout.getChildCount() == 0) {
            layoutParams.rightMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
            this.mRightButtonLayout.addView(this.mHomeButton, 0, layoutParams);
        } else if (this.mRightButtonLayout.getChildCount() == 1 && -1 == this.mRightButtonLayout.indexOfChild(this.mHomeButton)) {
            layoutParams.rightMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
            this.mRightButtonLayout.addView(this.mHomeButton, 0, layoutParams);
        } else if (this.mRightButtonLayout.getChildCount() == 2 && -1 == this.mRightButtonLayout.indexOfChild(this.mHomeButton)) {
            if (this.mLeftButtonLayout.getChildCount() == 1 && this.mBackButton != null && -1 == this.mLeftButtonLayout.indexOfChild(this.mHomeButton)) {
                layoutParams.leftMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
                this.mLeftButtonLayout.addView(this.mHomeButton, 1, layoutParams);
            } else if (this.mLeftButtonLayout.getChildCount() == 2 && -1 == this.mLeftButtonLayout.indexOfChild(this.mHomeButton)) {
                LinearLayout linearLayout = this.mLeftButtonLayout;
                linearLayout.removeView(linearLayout.getChildAt(1));
                layoutParams.leftMargin = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
                this.mLeftButtonLayout.addView(this.mHomeButton, 1, layoutParams);
            }
        }
        this.mHomeButton.setVisibility(0);
        requestLayout();
        caculateTitleMargin();
    }

    @Override
    public void addLeftButton(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, IWebview iWebview, String str11, String str12, boolean z, String str13, boolean z2, String str14) {
        int i;
        int convertToScreenInt;
        View createButton = createButton(str, str3, str4, str5, str6, str7, str8, str10, iWebview, str11, str12, z, str13, z2, str14, str9);
        initTitleNViewLayout();
        initLeftButtonLayout();
        if (-1 == this.mLeftButtonLayout.indexOfChild(createButton)) {
            int convertToScreenInt2 = this.mInnerHeight - PdrUtil.convertToScreenInt("12px", this.mAppScreenWidth, 0, this.mCreateScale);
            int convertToScreenInt3 = PdrUtil.convertToScreenInt(str14, this.mAppScreenWidth, -1, this.mCreateScale);
            int convertToScreenInt4 = PdrUtil.convertToScreenInt(str9, this.mAppScreenWidth, -1, this.mCreateScale);
            String str15 = "5px";
            if (convertToScreenInt3 <= 0 || convertToScreenInt4 <= convertToScreenInt3) {
                if (PdrUtil.isEmpty(str9)) {
                    i = convertToScreenInt2;
                } else if (!str9.equals("auto")) {
                    i = PdrUtil.convertToScreenInt(str9, this.mAppScreenWidth, convertToScreenInt2, this.mCreateScale);
                    str15 = "0px";
                }
                convertToScreenInt = PdrUtil.convertToScreenInt(str15, this.mAppScreenWidth, 0, this.mCreateScale);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(i, convertToScreenInt2);
                layoutParams.leftMargin = convertToScreenInt;
                this.mLeftButtonLayout.addView(createButton, layoutParams);
                if (!PdrUtil.isEmpty(str9) && str9.equals("auto") && z2) {
                    createButton.setPadding(convertToScreenInt, createButton.getPaddingTop(), convertToScreenInt, createButton.getPaddingBottom());
                }
            }
            i = -2;
            convertToScreenInt = PdrUtil.convertToScreenInt(str15, this.mAppScreenWidth, 0, this.mCreateScale);
            LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(i, convertToScreenInt2);
            layoutParams2.leftMargin = convertToScreenInt;
            this.mLeftButtonLayout.addView(createButton, layoutParams2);
            if (!PdrUtil.isEmpty(str9)) {
                createButton.setPadding(convertToScreenInt, createButton.getPaddingTop(), convertToScreenInt, createButton.getPaddingBottom());
            }
        }
        caculateTitleMargin();
    }

    @Override
    public void addRightButton(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, IWebview iWebview, String str11, String str12, boolean z, String str13, boolean z2, String str14) {
        int i;
        int convertToScreenInt;
        initTitleNViewLayout();
        initRightButtonLayout();
        if ((this.maxButton <= 2 || this.mRightButtonLayout.getChildCount() > this.maxButton - 2) && this.mMenuButtons != null) {
            ButtonDataItem buttonDataItem = new ButtonDataItem(str, str2, iWebview != null ? iWebview.getWebviewUUID() : null, str7, str8, str10);
            this.mMenuButtons.add(buttonDataItem);
            this.mButtons.add(buttonDataItem);
            return;
        }
        View createButton = createButton(str, str3, str4, str5, str6, str7, str8, str10, iWebview, str11, str12, z, str13, z2, str14, str9);
        if (-1 == this.mRightButtonLayout.indexOfChild(createButton)) {
            int convertToScreenInt2 = this.mInnerHeight - PdrUtil.convertToScreenInt("12px", this.mAppScreenWidth, 0, this.mCreateScale);
            int convertToScreenInt3 = PdrUtil.convertToScreenInt(str14, this.mAppScreenWidth, -1, this.mCreateScale);
            int convertToScreenInt4 = PdrUtil.convertToScreenInt(str9, this.mAppScreenWidth, -1, this.mCreateScale);
            String str15 = "5px";
            if (convertToScreenInt3 <= 0 || convertToScreenInt4 <= convertToScreenInt3) {
                if (PdrUtil.isEmpty(str9)) {
                    i = convertToScreenInt2;
                } else if (!str9.equals("auto")) {
                    i = PdrUtil.convertToScreenInt(str9, this.mAppScreenWidth, convertToScreenInt2, this.mCreateScale);
                    str15 = "0px";
                }
                convertToScreenInt = PdrUtil.convertToScreenInt(str15, this.mAppScreenWidth, 0, this.mCreateScale);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(i, convertToScreenInt2);
                layoutParams.rightMargin = convertToScreenInt;
                this.mRightButtonLayout.addView(createButton, 0, layoutParams);
                if (!PdrUtil.isEmpty(str9) && str9.equals("auto") && z2) {
                    createButton.setPadding(convertToScreenInt, createButton.getPaddingTop(), convertToScreenInt, createButton.getPaddingBottom());
                }
            }
            i = -2;
            convertToScreenInt = PdrUtil.convertToScreenInt(str15, this.mAppScreenWidth, 0, this.mCreateScale);
            LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(i, convertToScreenInt2);
            layoutParams2.rightMargin = convertToScreenInt;
            this.mRightButtonLayout.addView(createButton, 0, layoutParams2);
            if (!PdrUtil.isEmpty(str9)) {
                createButton.setPadding(convertToScreenInt, createButton.getPaddingTop(), convertToScreenInt, createButton.getPaddingBottom());
            }
        }
        caculateTitleMargin();
    }

    @Override
    public void addSearchInput(final String str, String str2, String str3, String str4, String str5, String str6, boolean z, final boolean z2, final IWebview iWebview) {
        boolean z3;
        final TextView textView;
        int stringToColor;
        int stringToColor2;
        int stringToColor3;
        initTitleNViewLayout();
        initLeftButtonLayout();
        initRightButtonLayout();
        initCenterSearchLayout();
        RelativeLayout relativeLayout = this.mTitlelayout;
        if (relativeLayout != null) {
            relativeLayout.setVisibility(4);
        }
        Typeface createFromAsset = Typeface.createFromAsset(getContext().getAssets(), "fonts/dcloud_iconfont.ttf");
        int convertToScreenInt = PdrUtil.convertToScreenInt("13px", this.mInnerWidth, 0, this.mCreateScale);
        int convertToScreenInt2 = PdrUtil.convertToScreenInt("8px", this.mAppScreenWidth, 0, this.mCreateScale);
        if (this.searchInput == null) {
            TextView textView2 = new TextView(getContext());
            textView2.setGravity(17);
            textView2.setTypeface(createFromAsset);
            textView2.setText("\ue660 ");
            textView2.setIncludeFontPadding(false);
            float f = convertToScreenInt;
            textView2.getPaint().setTextSize(f);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -1);
            layoutParams.leftMargin = convertToScreenInt2;
            this.centerSearchLayout.addView(textView2, layoutParams);
            EditText editText = new EditText(getContext());
            this.searchInput = editText;
            editText.setTag("TitleNView.SearchInput");
            int i = convertToScreenInt2 / 2;
            this.searchInput.setPadding(0, i, 0, i);
            this.searchInput.setPaddingRelative(0, i, 0, i);
            this.searchInput.setIncludeFontPadding(false);
            this.searchInput.setGravity(17);
            this.searchInput.setSingleLine();
            this.searchInput.setLines(1);
            this.searchInput.setTypeface(createFromAsset);
            this.searchInput.setImeOptions(3);
            this.searchInput.getPaint().setTextSize(f);
            this.searchInput.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
            z3 = true;
        } else {
            z3 = false;
        }
        initTitleNViewLayout();
        if (this.searchInput.getParent() != null) {
            ((ViewGroup) this.searchInput.getParent()).removeView(this.searchInput);
        }
        if (-1 == this.centerSearchLayout.indexOfChild(this.searchInput)) {
            this.centerSearchLayout.addView(this.searchInput, 1, new LinearLayout.LayoutParams(-1, -2, 1.0f));
        }
        TextView textView3 = this.centerSearchLayout.getChildAt(0) instanceof TextView ? (TextView) this.centerSearchLayout.getChildAt(0) : null;
        if (textView3 != null) {
            if (str.equalsIgnoreCase("left")) {
                textView3.setVisibility(0);
            } else if (this.searchInput.getText() != null && this.searchInput.getText().toString().length() > 0) {
                textView3.setVisibility(0);
            } else {
                textView3.setVisibility(8);
            }
        }
        if (this.centerSearchLayout.getChildCount() > 2) {
            textView = (TextView) this.centerSearchLayout.getChildAt(2);
        } else {
            TextView textView4 = new TextView(getContext());
            textView4.setGravity(17);
            textView4.setTypeface(createFromAsset);
            textView4.setText("\ue650");
            textView4.setTextColor(-1);
            textView4.setTextSize(0, convertToScreenInt);
            textView4.setIncludeFontPadding(false);
            textView4.getPaint().setFakeBoldText(true);
            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setCornerRadius(100.0f);
            gradientDrawable.setColor(-4802890);
            textView4.setBackground(gradientDrawable);
            int i2 = convertToScreenInt2 / 4;
            textView4.setPadding(i2, i2, i2, i2);
            LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-2, -2);
            layoutParams2.rightMargin = convertToScreenInt2;
            this.centerSearchLayout.addView(textView4, 2, layoutParams2);
            textView4.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    TitleNView.this.searchInput.setText("");
                }
            });
            textView4.setVisibility(8);
            textView = textView4;
        }
        if (PdrUtil.isEmpty(str2)) {
            stringToColor = Color.parseColor("#8fffffff");
        } else {
            try {
                stringToColor = Color.parseColor(str2);
            } catch (Exception unused) {
                stringToColor = PdrUtil.stringToColor(str2);
            }
        }
        int convertToScreenInt3 = PdrUtil.isEmpty(str3) ? 0 : PdrUtil.convertToScreenInt(str3, this.mInnerWidth, 0, this.mCreateScale);
        String str7 = !PdrUtil.isEmpty(str4) ? str4 : "";
        this.searchInput.setHint("\ue660 " + str7);
        if (PdrUtil.isEmpty(str5)) {
            stringToColor2 = Color.parseColor("#CCCCCC");
        } else {
            try {
                stringToColor2 = Color.parseColor(str5);
            } catch (Exception unused2) {
                stringToColor2 = PdrUtil.stringToColor(str5);
            }
        }
        if (textView3 != null) {
            textView3.setTextColor(stringToColor2);
        }
        this.searchInput.setHintTextColor(stringToColor2);
        this.searchInput.setEllipsize(TextUtils.TruncateAt.END);
        this.searchInput.setBackground(null);
        this.centerSearchLayout.setBackground(new SearchInputDrawable(stringToColor, convertToScreenInt3));
        if (PdrUtil.isEmpty(str6)) {
            stringToColor3 = -16777216;
        } else {
            try {
                stringToColor3 = Color.parseColor(str6);
            } catch (Exception unused3) {
                stringToColor3 = PdrUtil.stringToColor(str6);
            }
        }
        this.searchInput.setTextColor(stringToColor3);
        if (z3) {
            this.searchInput.addTextChangedListener(new TextWatcher() {
                @Override
                public void afterTextChanged(Editable editable) {
                }

                @Override
                public void beforeTextChanged(CharSequence charSequence, int i3, int i4, int i5) {
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i3, int i4, int i5) {
                    if (charSequence.toString().length() > 0) {
                        textView.setVisibility(0);
                    } else {
                        textView.setVisibility(8);
                    }
                    String jsResponseText = JSUtil.toJsResponseText(charSequence.toString());
                    IWebview iWebview2 = TitleNView.this.mWebView;
                    if (iWebview2 != null && iWebview2.obtainFrameView() != null && (TitleNView.this.mWebView.obtainFrameView() instanceof AdaFrameView)) {
                        ((AdaFrameView) TitleNView.this.mWebView.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_CHANGED, StringUtil.format("{text:\"%s\"}", jsResponseText));
                        return;
                    }
                    IWebview iWebview3 = iWebview;
                    if (iWebview3 == null || iWebview3.obtainFrameView() == null || !(iWebview.obtainFrameView() instanceof AdaFrameView)) {
                        return;
                    }
                    ((AdaFrameView) iWebview.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_CHANGED, StringUtil.format("{text:\"%s\"}", jsResponseText));
                }
            });
        }
        final TextView textView5 = textView3;
        final String str8 = str7;
        this.searchInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean z4) {
                if (!TitleNView.this.isSetText.get()) {
                    IWebview iWebview2 = TitleNView.this.mWebView;
                    if (iWebview2 != null && iWebview2.obtainFrameView() != null && (TitleNView.this.mWebView.obtainFrameView() instanceof AdaFrameView)) {
                        ((AdaFrameView) TitleNView.this.mWebView.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_FOCUSCHANGED, StringUtil.format("{focus:%b}", Boolean.valueOf(z4)));
                    }
                    IWebview iWebview3 = iWebview;
                    if (iWebview3 != null && iWebview3.obtainFrameView() != null && (iWebview.obtainFrameView() instanceof AdaFrameView)) {
                        ((AdaFrameView) iWebview.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_FOCUSCHANGED, StringUtil.format("{focus:%b}", Boolean.valueOf(z4)));
                    }
                }
                if (z4) {
                    TitleNView.this.searchInput.setGravity(3);
                    textView5.setVisibility(0);
                    TitleNView.this.searchInput.setHint(str8);
                } else if (TitleNView.this.searchInput.getText().toString().length() < 1) {
                    TitleNView.this.setTextGravity(str, str8);
                    if (str.equalsIgnoreCase("left")) {
                        textView5.setVisibility(0);
                    } else {
                        textView5.setVisibility(8);
                    }
                }
            }
        });
        this.searchInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView6, int i3, KeyEvent keyEvent) {
                if (i3 == 3) {
                    String jsResponseText = JSUtil.toJsResponseText(textView6.getText().toString());
                    IWebview iWebview2 = TitleNView.this.mWebView;
                    if (iWebview2 != null && iWebview2.obtainFrameView() != null && (TitleNView.this.mWebView.obtainFrameView() instanceof AdaFrameView)) {
                        ((AdaFrameView) TitleNView.this.mWebView.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_CONFIRMED, StringUtil.format("{text:\"%s\"}", jsResponseText));
                        return true;
                    }
                    IWebview iWebview3 = iWebview;
                    if (iWebview3 != null && iWebview3.obtainFrameView() != null && (iWebview.obtainFrameView() instanceof AdaFrameView)) {
                        ((AdaFrameView) iWebview.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_CONFIRMED, StringUtil.format("{text:\"%s\"}", jsResponseText));
                    }
                }
                return false;
            }
        });
        if (this.searchInput.getText() == null || this.searchInput.getText().toString().length() < 1) {
            setTextGravity(str, str7);
        }
        boolean z4 = !z;
        this.searchInput.setCursorVisible(z4);
        this.searchInput.setFocusable(z4);
        this.searchInput.setFocusableInTouchMode(z4);
        final IWebview iWebview2 = this.mWebView;
        if (iWebview2 == null) {
            iWebview2 = iWebview;
        }
        try {
            final boolean didCloseSplash = ((IWebAppRootView) ((AdaFrameView) iWebview2.obtainFrameView()).getParent()).didCloseSplash();
            if (!didCloseSplash) {
                iWebview2.obtainApp().registerSysEventListener(new ISysEventListener() {
                    @Override
                    public boolean onExecute(ISysEventListener.SysEventType sysEventType, Object obj) {
                        ISysEventListener.SysEventType sysEventType2;
                        if (z2 && sysEventType == (sysEventType2 = ISysEventListener.SysEventType.onSplashclosed)) {
                            TitleNView.this.searchInput.requestFocus();
                            if (!DeviceInfo.isIMEShow) {
                                DeviceInfo.showIME(TitleNView.this.searchInput);
                            }
                            iWebview2.obtainApp().unregisterSysEventListener(this, sysEventType2);
                        }
                        if (z2) {
                            return false;
                        }
                        DeviceInfo.hideIME(TitleNView.this.searchInput);
                        return false;
                    }
                }, ISysEventListener.SysEventType.onSplashclosed);
            }
            iWebview2.obtainFrameView().addFrameViewListener(new IEventCallback() {
                @Override
                public Object onCallBack(String str9, Object obj) {
                    if (AbsoluteConst.EVENTS_SHOW_ANIMATION_END.equalsIgnoreCase(str9) && z2 && didCloseSplash) {
                        TitleNView.this.searchInput.requestFocus();
                        if (!DeviceInfo.isIMEShow) {
                            DeviceInfo.showIME(TitleNView.this.searchInput);
                        }
                        iWebview2.obtainFrameView().removeFrameViewListener(this);
                        return null;
                    }
                    return null;
                }
            });
        } catch (Exception unused4) {
        }
        if (!z2) {
            DeviceInfo.hideIME(this.searchInput);
        }
        if (z) {
            this.searchInput.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    IWebview iWebview3 = TitleNView.this.mWebView;
                    if (iWebview3 != null && iWebview3.obtainFrameView() != null && (TitleNView.this.mWebView.obtainFrameView() instanceof AdaFrameView)) {
                        ((AdaFrameView) TitleNView.this.mWebView.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_CLICKED, String.format(" ", new Object[0]));
                        return;
                    }
                    IWebview iWebview4 = iWebview;
                    if (iWebview4 == null || iWebview4.obtainFrameView() == null || !(iWebview.obtainFrameView() instanceof AdaFrameView)) {
                        return;
                    }
                    ((AdaFrameView) iWebview.obtainFrameView()).dispatchFrameViewEvents(AbsoluteConst.EVENT_TITLENVIEW_SEARCHINPUT_CLICKED, String.format(" ", new Object[0]));
                }
            });
        }
        this.searchInput.setVisibility(0);
        requestLayout();
    }

    @Override
    public void clearButtons() {
        LinearLayout linearLayout = this.mRightButtonLayout;
        if (linearLayout != null) {
            linearLayout.removeAllViews();
        }
        LinearLayout linearLayout2 = this.mLeftButtonLayout;
        if (linearLayout2 != null) {
            linearLayout2.removeAllViews();
        }
        ArrayList<ButtonDataItem> arrayList = this.mMenuButtons;
        if (arrayList != null) {
            arrayList.clear();
        }
        ArrayList<Object> arrayList2 = this.mButtons;
        if (arrayList2 != null) {
            arrayList2.clear();
        }
    }

    @Override
    public void clearNativeViewData() {
        IFrameView iFrameView = this.mFrameViewParent;
        if (iFrameView != null && (iFrameView instanceof AdaFrameView)) {
            ((AdaFrameView) iFrameView).removeNativeViewChild(this);
        }
        postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    TitleNView.this.setVisibility(8);
                    if (TitleNView.this.getParent() != null) {
                        ((ViewGroup) TitleNView.this.getParent()).removeView(TitleNView.this);
                    }
                    TitleNView.this.clearViewData();
                    if (TitleNView.this.mButtons != null) {
                        Iterator it = TitleNView.this.mButtons.iterator();
                        while (it.hasNext()) {
                            Object next = it.next();
                            if (next instanceof BadgeRelateiveLayout) {
                                View view = (View) next;
                                if (view.getBackground() != null) {
                                    view.getBackground().setCallback(null);
                                }
                            }
                        }
                        TitleNView.this.mButtons.clear();
                    }
                    TitleNView.this.mFrameViewParent = null;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, 200);
    }

    @Override
    public void clearSearchInput() {
        LinearLayout linearLayout = this.centerSearchLayout;
        if (linearLayout == null || this.mTitleNViewLayout == null) {
            return;
        }
        linearLayout.removeAllViews();
        this.mTitleNViewLayout.removeView(this.centerSearchLayout);
        this.centerSearchLayout = null;
        this.searchInput = null;
        RelativeLayout relativeLayout = this.mTitlelayout;
        if (relativeLayout != null) {
            relativeLayout.setVisibility(0);
        }
    }

    @Override
    public String getBackgroundColor() {
        return getStyleBackgroundColor();
    }

    @Override
    public String getStatusBarColor() {
        JSONObject optJSONObject;
        int stringToColor;
        if (!this.isImmersed) {
            return "{color:-1,alpha:true}";
        }
        if (this.mStyle.has(AbsoluteConst.JSONKEY_STATUSBAR) && (optJSONObject = this.mStyle.optJSONObject(AbsoluteConst.JSONKEY_STATUSBAR)) != null && optJSONObject.has("backgroundnoalpha")) {
            String optString = optJSONObject.optString("backgroundnoalpha");
            try {
                stringToColor = Color.parseColor(optString);
            } catch (Exception unused) {
                stringToColor = PdrUtil.stringToColor(optString);
            }
            return "{color:" + stringToColor + ",alpha:false}";
        }
        View view = this.mStatusbarView;
        if (view != null) {
            Drawable background = view.getBackground();
            if (background instanceof ColorDrawable) {
                int color = ((ColorDrawable) background).getColor();
                return "{color:" + color + ",alpha:true}";
            }
            return "{color:-1,alpha:true}";
        }
        ViewParent parent = getParent();
        if (!TextUtils.equals(this.mStyle.optString("position", AbsoluteConst.JSON_VALUE_POSITION_ABSOLUTE), AbsoluteConst.JSON_VALUE_POSITION_ABSOLUTE) || parent == null || !(parent instanceof ViewGroup)) {
            return "{color:-1,alpha:true}";
        }
        int i = 0;
        while (true) {
            ViewGroup viewGroup = (ViewGroup) parent;
            if (i >= viewGroup.getChildCount()) {
                return "{color:-1,alpha:true}";
            }
            Object tag = viewGroup.getChildAt(i).getTag();
            if (tag != null && "StatusBar".equalsIgnoreCase(tag.toString())) {
                Drawable background2 = viewGroup.getChildAt(i).getBackground();
                if (background2 instanceof ColorDrawable) {
                    int color2 = ((ColorDrawable) background2).getColor();
                    return "{color:" + color2 + ",alpha:true}";
                }
            }
            i++;
        }
    }

    @Override
    public int getTitleColor() {
        return this.mTitleView.getTextColors().getDefaultColor();
    }

    @Override
    public String getTitleNViewSearchInputText() {
        EditText editText = this.searchInput;
        return editText != null ? editText.getText().toString() : "";
    }

    @Override
    public String getViewType() {
        return AbsoluteConst.NATIVE_TITLE_N_VIEW;
    }

    @Override
    public void init() {
        View view;
        super.init();
        if (this.mStyle.has("blurEffect")) {
            this.mBlurEffect = this.mStyle.optString("blurEffect", "none");
        }
        if (this.mBackgroudView == null) {
            View view2 = new View(getContext());
            this.mBackgroudView = view2;
            addView(view2, 0, new FrameLayout.LayoutParams(-1, -1));
        }
        updateCapsuleLayout();
        this.redDotColor = -65536;
        if (this.mStyle != null) {
            if (this.mBackGroundDrawable == null) {
                BackGroundDrawable backGroundDrawable = new BackGroundDrawable();
                this.mBackGroundDrawable = backGroundDrawable;
                this.mBackgroudView.setBackground(backGroundDrawable);
            }
            if (this.mStyle.has(AbsoluteConst.JSONKEY_STATUSBAR) && this.mStyle.has(Constants.Name.BACKGROUND_IMAGE) && (view = this.mStatusbarView) != null) {
                view.setVisibility(8);
            }
            this.mBackGroundDrawable.setBackgroundColor(this.mBackGroundColor);
            this.mBackGroundDrawable.updatebound();
            this.mBackGroundDrawable.setBackgroundImage(this.mBackgroundImageSrc);
            this.mBackGroundDrawable.setAlpha(Color.alpha(this.mBackGroundColor));
            this.mBackGroundDrawable.invalidateSelf();
            if (this.mStyle.has("redDotColor") && !PdrUtil.isEmpty(this.mStyle.optString("redDotColor"))) {
                this.redDotColor = PdrUtil.stringToColor(this.mStyle.optString("redDotColor"));
            }
        }
        if ((DCBlurDraweeView.LIGHT.equals(this.mBlurEffect) || DCBlurDraweeView.DARK.equals(this.mBlurEffect) || DCBlurDraweeView.EXTRALIGHT.equals(this.mBlurEffect)) && this.mBlurDraweeView == null) {
            int i = this.mInnerHeight;
            if (this.isStatusBar && this.isImmersed) {
                i += DeviceInfo.sStatusBarHeight;
            }
            if (this.mWebView.obtainWindowView() instanceof IX5WebView) {
                this.mBlurDraweeView = new DCBlurDraweeView(getContext(), false, "none");
            } else {
                this.mBlurDraweeView = new DCBlurDraweeView(getContext(), true, DCBlurDraweeView.SEMI_AUTOMATICALLY);
            }
            addView(this.mBlurDraweeView, 0, new FrameLayout.LayoutParams(-1, i));
            this.mBlurDraweeView.setGravityType(48);
            this.mBlurDraweeView.setBlurEffect(this.mBlurEffect);
            this.mBlurDraweeView.setBlurRadius(20);
            this.mBlurDraweeView.setDownscaleFactor(0.3f);
            this.mBlurDraweeView.setRootView(this.mWebView.obtainFrameView().obtainMainView());
            this.mBlurDraweeView.setBlurLayoutChangeCallBack(new DCBlurDraweeView.BlurLayoutChangeCallBack() {
                @Override
                public void setVisibility(int i2) {
                    NativeView.NativeCanvasView nativeCanvasView = TitleNView.this.mCanvasView;
                    if (nativeCanvasView != null) {
                        nativeCanvasView.setVisibility(i2);
                    }
                    if (TitleNView.this.mTitleNViewLayout != null) {
                        TitleNView.this.mTitleNViewLayout.setVisibility(i2);
                    }
                    View view3 = TitleNView.this.mStatusbarView;
                    if (view3 != null && view3.getVisibility() != 8) {
                        TitleNView.this.mStatusbarView.setVisibility(i2);
                    }
                    if (TitleNView.this.mBackgroudView != null) {
                        TitleNView.this.mBackgroudView.setVisibility(i2);
                    }
                }
            });
        }
    }

    @Override
    public void measureChildViewToTop(int i) {
        super.measureChildViewToTop(i);
        RelativeLayout relativeLayout = this.mTitleNViewLayout;
        if (relativeLayout == null || relativeLayout.getLayoutParams() == null) {
            return;
        }
        ((FrameLayout.LayoutParams) this.mTitleNViewLayout.getLayoutParams()).topMargin = i;
    }

    @Override
    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        caculateTitleMargin();
    }

    @Override
    public void reMeasure() {
        measureFitViewParent(false);
    }

    @Override
    public void removeBackButton() {
        BadgeLinearLayout badgeLinearLayout = this.mBackButton;
        if (badgeLinearLayout != null) {
            badgeLinearLayout.setVisibility(8);
        }
    }

    @Override
    public void removeHomeButton() {
        TextView textView = this.mHomeButton;
        if (textView != null) {
            textView.setVisibility(8);
        }
    }

    @Override
    public void removeSplitLine() {
        RelativeLayout relativeLayout;
        View view = this.mSplitLine;
        if (view != null && (relativeLayout = this.mTitleNViewLayout) != null) {
            relativeLayout.removeView(view);
        }
        this.mSplitLine = null;
    }

    @Override
    public void resetNativeView() {
        int i;
        IFrameView iFrameView = this.mFrameViewParent;
        if (iFrameView != null) {
            try {
                String titleNViewId = TitleNViewUtil.getTitleNViewId(iFrameView);
                if (this.mOverlayMaps.containsKey(titleNViewId)) {
                    i = this.mOverlayMaps.get(titleNViewId).intValue();
                    this.mOverlayMaps.clear();
                    this.mOverlayMaps.put(titleNViewId, Integer.valueOf(i));
                } else {
                    this.mOverlayMaps.clear();
                    i = -1;
                }
                if (-1 != i) {
                    NativeView.Overlay overlay = this.mOverlays.get(i);
                    Iterator<NativeView.Overlay> it = this.mOverlays.iterator();
                    while (it.hasNext()) {
                        NativeView.Overlay next = it.next();
                        if (next != overlay) {
                            NativeBitmap nativeBitmap = next.mNativeBitmap;
                            if (nativeBitmap != null) {
                                nativeBitmap.recycle(true);
                            }
                            it.remove();
                        }
                    }
                } else {
                    clearViewData();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            clearViewData();
        }
        clearAnimate();
    }

    @Override
    public void setBackButtonColor(String str, String str2, String str3) {
        setButtonColor(this.mBackButton, str, str2, str3);
    }

    @Override
    public void setBackgroundColor(String str) {
        setStyleBackgroundColor(str);
        updateCapsuleLayout();
    }

    @Override
    public void setBackgroundImage(String str) {
        if (this.mBackgroundImageSrc.equals(str)) {
            return;
        }
        this.mBackgroundImageSrc = str;
        if (this.mBackGroundDrawable == null) {
            this.mBackGroundDrawable = new BackGroundDrawable();
        }
        this.mBackGroundDrawable.setBackgroundImage(this.mBackgroundImageSrc);
        this.mBackgroudView.setBackground(this.mBackGroundDrawable);
        this.mBackGroundDrawable.invalidateSelf();
    }

    @Override
    public void setBackgroundRepeat(String str) {
        BackGroundDrawable backGroundDrawable = this.mBackGroundDrawable;
        if (backGroundDrawable != null) {
            backGroundDrawable.setRepeatType(str, this.mBackgroundImageSrc);
        }
    }

    @Override
    public void setBadgeText(JSONObject jSONObject, boolean z) {
        int optInt = jSONObject.optInt("index");
        String optString = jSONObject.optString("text");
        if (!z) {
            optString = "";
        }
        if (optInt >= this.mButtons.size() || optInt < 0) {
            return;
        }
        Object obj = this.mButtons.get(optInt);
        if (obj instanceof BadgeRelateiveLayout) {
            ((BadgeRelateiveLayout) obj).setBadgeStr(optString);
        }
    }

    @Override
    public void setButtonColorByIndex(int i, String str, String str2, String str3) {
        Object obj = this.mButtons.get(i);
        if (obj == null || !(obj instanceof View)) {
            return;
        }
        setButtonColor((View) obj, str, str2, str3);
    }

    @Override
    public void setButtonsColor(String str, String str2, String str3) {
        for (int i = 0; i < this.mButtons.size(); i++) {
            setButtonColorByIndex(i, str, str2, str3);
        }
    }

    @Override
    public void setCapsuleButtonStyle(JSONObject jSONObject) {
        CapsuleLayout capsuleLayout = this.mCapsuleLayout;
        if (capsuleLayout == null || jSONObject == null) {
            return;
        }
        capsuleLayout.isDiy = true;
        if (jSONObject.has("backgroundColor")) {
            this.mCapsuleLayout.setBackgroundColor(PdrUtil.stringToColor(jSONObject.optString("backgroundColor")));
        }
        if (jSONObject.has(Constants.Name.BORDER_COLOR)) {
            this.mCapsuleLayout.setRoundColor(PdrUtil.stringToColor(jSONObject.optString(Constants.Name.BORDER_COLOR)));
        }
        if (jSONObject.has("highlightColor")) {
            int stringToColor = PdrUtil.stringToColor(jSONObject.optString("highlightColor"));
            TextView textView = this.menuBt;
            if (textView != null) {
                this.mCapsuleLayout.setButtonSelectColor(textView, CapsuleLayout.ButtonType.LIFT, stringToColor);
            }
            TextView textView2 = this.closeBt;
            if (textView2 != null) {
                this.mCapsuleLayout.setButtonSelectColor(textView2, CapsuleLayout.ButtonType.RIGHT, stringToColor);
            }
        }
        if (jSONObject.has("textColor")) {
            int stringToColor2 = PdrUtil.stringToColor(jSONObject.optString("textColor"));
            TextView textView3 = this.menuBt;
            if (textView3 != null) {
                textView3.setTextColor(stringToColor2);
            }
            TextView textView4 = this.closeBt;
            if (textView4 != null) {
                textView4.setTextColor(stringToColor2);
            }
        }
    }

    @Override
    public void setHomeButtonColor(String str, String str2, String str3) {
        setButtonColor(this.mHomeButton, str, str2, str3);
    }

    @Override
    public void setIconSubTitleStyle(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) {
        ImageView imageView;
        TextView textView;
        RelativeLayout relativeLayout = this.mTitlelayout;
        if (relativeLayout != null) {
            if (relativeLayout.getChildAt(0) instanceof ImageView) {
                imageView = (ImageView) this.mTitlelayout.getChildAt(0);
            } else {
                imageView = new ImageView(getContext());
                imageView.setId(View.generateViewId());
            }
            ImageView imageView2 = imageView;
            if (this.mTitlelayout.getChildAt(2) instanceof TextView) {
                textView = (TextView) this.mTitlelayout.getChildAt(2);
            } else {
                textView = new TextView(getContext());
                textView.setId(View.generateViewId());
            }
            layoutSubtitleIcon(str, str2, str3, str4, str5, str6, imageView2, textView, PdrUtil.stringToColor(str7), str8, str9);
        }
    }

    @Override
    public void setProgress(String str, String str2) {
        int stringToColor;
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            if (this.mProgress == null) {
                Progress progress = new Progress(getContext());
                this.mProgress = progress;
                progress.setTag("TitleNView.Progress");
            }
            try {
                stringToColor = Color.parseColor(str2);
            } catch (Exception unused) {
                stringToColor = PdrUtil.stringToColor(str2);
            }
            this.mProgress.setColorInt(stringToColor);
            this.mProgress.setHeightInt(PdrUtil.convertToScreenInt(str, this.mInnerWidth, 0, this.mCreateScale));
            return;
        }
        Progress progress2 = this.mProgress;
        if (progress2 != null) {
            if (!progress2.isFinish()) {
                this.mProgress.finishProgress();
            } else {
                this.mProgress.setVisibility(0);
            }
        }
    }

    @Override
    public void setRedDot(JSONObject jSONObject, boolean z) {
        int optInt = jSONObject.optInt("index");
        if (optInt >= this.mButtons.size() || optInt < 0) {
            return;
        }
        Object obj = this.mButtons.get(optInt);
        if (obj instanceof BadgeRelateiveLayout) {
            ((BadgeRelateiveLayout) obj).setDrawRedDot(z);
        }
    }

    @Override
    public void setRedDotColor(int i) {
        if (this.redDotColor != i) {
            this.redDotColor = i;
            this.mBackButton.setRedDotColor(i);
            if (this.mButtons.size() > 0) {
                Iterator<Object> it = this.mButtons.iterator();
                while (it.hasNext()) {
                    Object next = it.next();
                    if (next instanceof BadgeRelateiveLayout) {
                        ((BadgeRelateiveLayout) next).setRedDotColor(this.redDotColor);
                    }
                }
            }
        }
    }

    @Override
    public void setSearchInputColor(String str) {
        Drawable background;
        int stringToColor;
        LinearLayout linearLayout = this.centerSearchLayout;
        if (linearLayout == null || (background = linearLayout.getBackground()) == null || !(background instanceof SearchInputDrawable)) {
            return;
        }
        try {
            stringToColor = Color.parseColor(str);
        } catch (Exception unused) {
            stringToColor = PdrUtil.stringToColor(str);
        }
        SearchInputDrawable searchInputDrawable = (SearchInputDrawable) background;
        if (stringToColor != searchInputDrawable.getDrawableColor()) {
            searchInputDrawable.setDrawableColor(stringToColor);
        }
    }

    @Override
    public void setSearchInputFocus(boolean z) {
        EditText editText = this.searchInput;
        if (editText != null) {
            if (z) {
                DeviceInfo.hideIME(editText);
                if (this.searchInput.requestFocus()) {
                    DeviceInfo.showIME(this.searchInput);
                    return;
                }
                return;
            }
            editText.clearFocus();
            DeviceInfo.hideIME(this.searchInput);
        }
    }

    @Override
    public void setShadow(JSONObject jSONObject) {
        BackGroundDrawable backGroundDrawable = this.mBackGroundDrawable;
        if (backGroundDrawable != null) {
            backGroundDrawable.setShadowColor(jSONObject);
        }
    }

    @Override
    public void setSplitLine(String str, String str2) {
        int stringToColor;
        if (this.mSplitLine == null) {
            View view = new View(getContext());
            this.mSplitLine = view;
            view.setTag("TitleNView.SplitLine");
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -2);
            layoutParams.addRule(12);
            this.mSplitLine.setLayoutParams(layoutParams);
        }
        initTitleNViewLayout();
        RelativeLayout relativeLayout = this.mTitleNViewLayout;
        if (relativeLayout != null && -1 == relativeLayout.indexOfChild(this.mSplitLine)) {
            RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -2);
            layoutParams2.addRule(12);
            this.mTitleNViewLayout.addView(this.mSplitLine, layoutParams2);
        }
        try {
            stringToColor = Color.parseColor(str2);
        } catch (Exception unused) {
            stringToColor = PdrUtil.stringToColor(str2);
        }
        this.mSplitLine.setBackgroundColor(stringToColor);
        this.mSplitLine.getLayoutParams().height = PdrUtil.convertToScreenInt(str, this.mInnerWidth, 0, this.mCreateScale);
        this.mSplitLine.requestLayout();
        this.mSplitLine.invalidate();
    }

    @Override
    public void setStatusBarColor(int i) {
        if (!this.isImmersed) {
            return;
        }
        if (this.mStatusbarView != null) {
            if (TextUtils.isEmpty(this.mBackgroundImageSrc) || !isStatusBar()) {
                this.mStatusbarView.setBackgroundColor(i);
                this.mStatusbarView.invalidate();
                return;
            }
            return;
        }
        ViewParent parent = getParent();
        if (!TextUtils.equals(this.mStyle.optString("position", AbsoluteConst.JSON_VALUE_POSITION_ABSOLUTE), AbsoluteConst.JSON_VALUE_POSITION_ABSOLUTE) || parent == null || !(parent instanceof ViewGroup)) {
            return;
        }
        int i2 = 0;
        while (true) {
            ViewGroup viewGroup = (ViewGroup) parent;
            if (i2 >= viewGroup.getChildCount()) {
                return;
            }
            View childAt = viewGroup.getChildAt(i2);
            if (childAt.getTag() != null && "StatusBar".equalsIgnoreCase(childAt.getTag().toString())) {
                childAt.setBackgroundColor(i);
                childAt.invalidate();
                return;
            }
            i2++;
        }
    }

    @Override
    public void setStyleBackgroundColor(int i) {
        this.mBackGroundDrawable.setBackgroundColor(i);
    }

    @Override
    public void setTitle(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, String str11, String str12) {
        ImageView imageView;
        TextView textView;
        int stringToColor;
        initTitleNViewLayout();
        initLeftButtonLayout();
        if (this.mTitlelayout == null) {
            this.mTitlelayout = new RelativeLayout(getContext());
        }
        if (this.mTitlelayout.getChildAt(0) instanceof ImageView) {
            imageView = (ImageView) this.mTitlelayout.getChildAt(0);
        } else {
            imageView = new ImageView(getContext());
            imageView.setId(View.generateViewId());
        }
        ImageView imageView2 = imageView;
        if (this.mTitleView == null) {
            TextView textView2 = new TextView(getContext());
            this.mTitleView = textView2;
            textView2.setTag("TitleNView.Title");
            this.mTitleView.setLines(1);
            this.mTitleView.setSingleLine(true);
            this.mTitleView.setIncludeFontPadding(false);
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
            layoutParams.addRule(13);
            this.mTitleView.setLayoutParams(layoutParams);
            if ("clip".equals(str4)) {
                this.mTitleView.setEllipsize(null);
            } else {
                this.mTitleView.setEllipsize(TextUtils.TruncateAt.END);
            }
            this.mTitleView.setId(View.generateViewId());
        }
        if (this.mTitlelayout.getChildAt(2) instanceof TextView) {
            textView = (TextView) this.mTitlelayout.getChildAt(2);
        } else {
            textView = new TextView(getContext());
            textView.setId(View.generateViewId());
        }
        TextView textView3 = textView;
        if (!TextUtils.isEmpty(str) && !str.equals(this.mTitleView.getText())) {
            this.mTitleView.setText(str);
        }
        this.mTitleView.getPaint().setTextSize(PdrUtil.convertToScreenInt(str3, this.mInnerWidth, PdrUtil.convertToScreenInt("17px", this.mInnerWidth, 0, this.mCreateScale), this.mCreateScale));
        try {
            stringToColor = Color.parseColor(str2);
        } catch (Exception unused) {
            stringToColor = PdrUtil.stringToColor(str2);
        }
        int i = stringToColor;
        this.mTitleView.setTextColor(i);
        if (-1 == this.mTitleNViewLayout.indexOfChild(this.mTitlelayout)) {
            this.mTitleNViewLayout.addView(this.mTitlelayout);
        }
        RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
        int convertToScreenInt = PdrUtil.convertToScreenInt("88px", this.mInnerWidth, 0, this.mCreateScale);
        if (!str5.equals("left") && !str5.equals("auto")) {
            layoutParams2.addRule(13);
            layoutParams2.removeRule(1);
            layoutParams2.removeRule(15);
            layoutParams2.leftMargin = convertToScreenInt;
        } else {
            layoutParams2.addRule(1, this.mLeftButtonLayout.getId());
            layoutParams2.addRule(15);
            layoutParams2.removeRule(13);
            layoutParams2.leftMargin = PdrUtil.convertToScreenInt("10px", this.mInnerWidth, 0, this.mCreateScale);
        }
        layoutSubtitleIcon(str6, str7, str8, str9, str10, str11, imageView2, textView3, i, str5, str12);
        layoutParams2.rightMargin = convertToScreenInt;
        this.mTitlelayout.setLayoutParams(layoutParams2);
        EditText editText = this.searchInput;
        if (editText == null || editText.getVisibility() != 0) {
            return;
        }
        this.mTitlelayout.setVisibility(4);
    }

    @Override
    public void setTitleAlign(String str) {
        RelativeLayout relativeLayout = this.mTitlelayout;
        if (relativeLayout == null) {
            return;
        }
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams();
        if (!str.equals("left") && !str.equals("auto")) {
            layoutParams.addRule(13);
            layoutParams.removeRule(1);
            layoutParams.removeRule(15);
            layoutParams.leftMargin = layoutParams.rightMargin;
        } else {
            layoutParams.addRule(1, this.mLeftButtonLayout.getId());
            layoutParams.addRule(15);
            layoutParams.removeRule(13);
            layoutParams.leftMargin = PdrUtil.convertToScreenInt("5px", this.mInnerWidth, 0, this.mCreateScale);
        }
        this.mTitlelayout.setLayoutParams(layoutParams);
    }

    @Override
    public void setTitleColor(String str) {
        int stringToColor;
        TextView textView = this.mTitleView;
        if (textView != null) {
            int defaultColor = textView.getTextColors().getDefaultColor();
            try {
                stringToColor = Color.parseColor(str);
            } catch (Exception unused) {
                stringToColor = PdrUtil.stringToColor(str);
            }
            if (stringToColor != defaultColor) {
                this.mTitleView.setTextColor(stringToColor);
            }
        }
    }

    @Override
    public boolean setTitleNViewButtonStyle(int i, String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, IWebview iWebview, String str10, String str11, String str12, String str13, String str14, String str15, String str16, String str17) {
        int i2;
        int i3;
        int i4;
        int i5;
        int i6;
        int stringToColor;
        int stringToColor2;
        int stringToColor3;
        if (i >= this.mButtons.size() || i < 0) {
            return false;
        }
        Object obj = this.mButtons.get(i);
        if (obj instanceof View) {
            ViewGroup viewGroup = (ViewGroup) obj;
            if (viewGroup.getChildCount() >= 1) {
                TextView textView = (TextView) viewGroup.getChildAt(0);
                if (PdrUtil.isEmpty(str3) || PdrUtil.isEmpty(str4)) {
                    i2 = -1;
                    i3 = -1;
                } else {
                    try {
                        stringToColor2 = Color.parseColor(str3);
                    } catch (Exception unused) {
                        stringToColor2 = PdrUtil.stringToColor(str3);
                    }
                    try {
                        stringToColor3 = Color.parseColor(str4);
                    } catch (Exception unused2) {
                        stringToColor3 = PdrUtil.stringToColor(str4);
                    }
                    textView.setTextColor(createColorStateList(stringToColor2, stringToColor3));
                    i3 = stringToColor2;
                    i2 = stringToColor3;
                }
                if (!PdrUtil.isEmpty(str5)) {
                    if (Constants.Value.BOLD.equals(str5)) {
                        textView.getPaint().setFakeBoldText(true);
                    } else {
                        textView.getPaint().setFakeBoldText(false);
                    }
                    textView.postInvalidate();
                }
                if (!PdrUtil.isEmpty(str6)) {
                    textView.setTextSize(0, PdrUtil.convertToScreenInt(str6, this.mInnerWidth, 0, this.mCreateScale));
                }
                if (PdrUtil.isEmpty(str8) && PdrUtil.isEmpty(str)) {
                    i4 = i2;
                    i5 = i3;
                } else {
                    i4 = i2;
                    i5 = i3;
                    setTextAndFont(str, str7, str8, textView, PdrUtil.isEmpty(str8));
                }
                Drawable background = viewGroup.getBackground();
                if (!PdrUtil.isEmpty(str10) && str15.equals("transparent")) {
                    try {
                        stringToColor = Color.parseColor(str10);
                    } catch (Exception unused3) {
                        stringToColor = PdrUtil.stringToColor(str10);
                    }
                    boolean z = background instanceof NativeViewBackButtonDrawable;
                    if (z) {
                        ((NativeViewBackButtonDrawable) background).setWidth(str14);
                    }
                    if (z) {
                        NativeViewBackButtonDrawable nativeViewBackButtonDrawable = (NativeViewBackButtonDrawable) background;
                        if (stringToColor != nativeViewBackButtonDrawable.getDrawableColor()) {
                            nativeViewBackButtonDrawable.setDrawableColor(stringToColor);
                        }
                    }
                }
                if (str12 != null && (viewGroup instanceof BadgeRelateiveLayout)) {
                    ((BadgeRelateiveLayout) viewGroup).setBadgeStr(str12);
                }
                if ((viewGroup instanceof BadgeRelateiveLayout) && !PdrUtil.isEmpty(str11)) {
                    ((BadgeRelateiveLayout) viewGroup).setDrawRedDot(Boolean.parseBoolean(str11));
                }
                if (viewGroup.getChildCount() >= 2 && !PdrUtil.isEmpty(str13)) {
                    TextView textView2 = (TextView) viewGroup.getChildAt(1);
                    if (Boolean.parseBoolean(str13)) {
                        textView2.setVisibility(0);
                        textView.setEllipsize(TextUtils.TruncateAt.END);
                    } else {
                        textView2.setVisibility(8);
                        textView.setEllipsize(null);
                    }
                } else if (!PdrUtil.isEmpty(str13) && Boolean.parseBoolean(str13)) {
                    TextView addSelect = addSelect(viewGroup, textView, 0);
                    int i7 = i5;
                    if (-1 != i7 && -1 != (i6 = i4)) {
                        addSelect.setTextColor(createColorStateList(i7, i6));
                    }
                }
                if (str9 != null) {
                    addButtonOnClickListener(str9, iWebview, viewGroup);
                }
                if (!PdrUtil.isEmpty(str14) && str14.equals("auto") && !PdrUtil.isEmpty(str13) && Boolean.parseBoolean(str13)) {
                    int convertToScreenInt = PdrUtil.convertToScreenInt("5px", this.mAppScreenWidth, 0, this.mCreateScale);
                    viewGroup.setPadding(convertToScreenInt, textView.getPaddingTop(), convertToScreenInt, textView.getPaddingBottom());
                } else {
                    viewGroup.setPadding(0, textView.getPaddingTop(), 0, textView.getPaddingBottom());
                }
                if (!PdrUtil.isEmpty(str16) || !PdrUtil.isEmpty(str14)) {
                    int convertToScreenInt2 = PdrUtil.convertToScreenInt(str16, this.mAppScreenWidth, 0, this.mCreateScale);
                    int convertToScreenInt3 = PdrUtil.convertToScreenInt(PdrUtil.isEmpty(str14) ? str17 : str14, this.mAppScreenWidth, 0, this.mCreateScale);
                    if (convertToScreenInt2 > 0) {
                        textView.setEllipsize(TextUtils.TruncateAt.END);
                        textView.setMaxWidth(convertToScreenInt2);
                    }
                    ViewGroup.LayoutParams layoutParams = viewGroup.getLayoutParams();
                    int i8 = layoutParams.width;
                    if (convertToScreenInt2 <= 0 || convertToScreenInt3 <= convertToScreenInt2) {
                        if (!PdrUtil.isEmpty(str14)) {
                            if (!str14.equals("auto")) {
                                i8 = PdrUtil.convertToScreenInt(str14, this.mAppScreenWidth, layoutParams.height, this.mCreateScale);
                            }
                        }
                        layoutParams.width = i8;
                        viewGroup.setLayoutParams(layoutParams);
                    }
                    i8 = -2;
                    layoutParams.width = i8;
                    viewGroup.setLayoutParams(layoutParams);
                }
                caculateTitleMargin();
            } else if (obj instanceof ButtonDataItem) {
                ((ButtonDataItem) obj).update(str, str2, iWebview != null ? iWebview.getWebviewUUID() : null, str7, str8, str9);
            }
        }
        return true;
    }

    @Override
    public void setTitleNViewFocusable(boolean z) {
        DCBlurDraweeView dCBlurDraweeView = this.mBlurDraweeView;
        if (dCBlurDraweeView == null || !dCBlurDraweeView.checkBlurEffect(this.mBlurEffect)) {
            return;
        }
        this.mBlurDraweeView.setContentFocusable(z);
    }

    @Override
    public void setTitleNViewPadding(int i, int i2, int i3, int i4) {
        initTitleNViewLayout();
        this.mTitleNViewLayout.setPadding(i, i2, i3, i4);
    }

    @Override
    public void setTitleNViewSearchInputText(String str) {
        EditText editText = this.searchInput;
        if (editText != null) {
            editText.setText(str);
            this.searchInput.setSelection(str.length());
            if (this.searchInput.isFocusable()) {
                return;
            }
            this.isSetText.set(true);
            this.searchInput.setFocusable(true);
            this.searchInput.setFocusableInTouchMode(true);
            this.searchInput.requestFocus();
            this.searchInput.setFocusable(false);
            this.searchInput.setFocusableInTouchMode(false);
            this.isSetText.set(false);
        }
    }

    @Override
    public void setTitleOverflow(String str) {
        if (this.mTitleView == null || TextUtils.isEmpty(str)) {
            return;
        }
        if ("clip".equals(str)) {
            this.mTitleView.setEllipsize(null);
        } else {
            this.mTitleView.setEllipsize(TextUtils.TruncateAt.END);
        }
    }

    @Override
    public void setTitleSize(String str) {
        if (this.mTitleView == null || TextUtils.isEmpty(str) || !str.endsWith("px")) {
            return;
        }
        float textSize = this.mTitleView.getPaint().getTextSize();
        float convertToScreenInt = PdrUtil.convertToScreenInt(str, this.mInnerWidth, 0, this.mCreateScale);
        if (textSize != convertToScreenInt) {
            this.mTitleView.getPaint().setTextSize(convertToScreenInt);
        }
    }

    @Override
    public void setTitleText(String str) {
        if (this.mTitleView == null || TextUtils.isEmpty(str) || str.equals(this.mTitleView.getText())) {
            return;
        }
        this.mTitleView.setText(str);
    }

    @Override
    public void startProgress() {
        Progress progress = this.mProgress;
        if (progress != null) {
            progress.setVisibility(0);
            this.mProgress.setAlphaInt(255);
            this.mProgress.setCurProgress(0);
            this.mProgress.setWebviewProgress(0);
            RelativeLayout relativeLayout = this.mTitleNViewLayout;
            if (relativeLayout != null && -1 == relativeLayout.indexOfChild(this.mProgress)) {
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, (int) this.mProgress.getHeightInt());
                layoutParams.addRule(12);
                this.mTitleNViewLayout.addView(this.mProgress, layoutParams);
            }
            IFrameView iFrameView = this.mFrameViewParent;
            if (iFrameView == null || iFrameView.obtainWebView() == null || this.mFrameViewParent.obtainWebView().obtainWindowView() == null) {
                return;
            }
            if (this.mIWebviewStateListenerImpl != null) {
                this.mFrameViewParent.obtainWebView().removeStateListener(this.mIWebviewStateListenerImpl);
            }
            this.mIWebviewStateListenerImpl = new IWebviewStateListenerImpl(this.mProgress);
            this.mFrameViewParent.obtainWebView().addStateListener(this.mIWebviewStateListenerImpl);
        }
    }

    @Override
    public void stopProgress() {
        Progress progress = this.mProgress;
        if (progress == null || progress.isFinish()) {
            return;
        }
        this.mProgress.finishProgress();
    }

    private ColorStateList createColorStateList(int i, int i2) {
        return new ColorStateList(new int[][]{new int[]{16842919, 16842910}, new int[]{16842910, 16842908}, new int[]{16842910}, new int[]{16842908}, new int[]{16842909}, new int[0]}, new int[]{i2, i, i, i, i, i});
    }

    private class BadgeLinearLayout extends LinearLayout {
        private String badgeStr;
        Rect canvasRect;
        float circle4PX;
        float circle8PX;
        private boolean isDrawRedDot;
        private Paint redDotPaint;
        TextPaint textPaint;

        public BadgeLinearLayout(Context context) {
            super(context);
            this.isDrawRedDot = false;
            this.badgeStr = "";
            this.canvasRect = new Rect();
        }

        @Override
        protected void dispatchDraw(Canvas canvas) {
            super.dispatchDraw(canvas);
            canvas.getClipBounds(this.canvasRect);
            if (this.isDrawRedDot && PdrUtil.isEmpty(this.badgeStr)) {
                Rect rect = this.canvasRect;
                float f = this.circle4PX;
                canvas.drawCircle(rect.right - f, rect.top + f, f, this.redDotPaint);
            }
        }

        @Override
        public void draw(Canvas canvas) {
            super.draw(canvas);
        }

        public void setBadgeStr(String str) {
            if (str == null || str.equals(this.badgeStr)) {
                return;
            }
            if (str.length() > 4) {
                this.badgeStr = str.trim().substring(0, 3) + "…";
            } else {
                this.badgeStr = str.trim();
            }
            postInvalidate();
        }

        public void setDrawRedDot(boolean z) {
            if (this.isDrawRedDot != z) {
                this.isDrawRedDot = z;
                postInvalidate();
            }
        }

        public void setRedDotColor(int i) {
            this.redDotPaint.setColor(i);
            postInvalidate();
        }

        public BadgeLinearLayout(TitleNView titleNView, Context context, float f, int i) {
            this(context);
            Paint paint = new Paint();
            this.redDotPaint = paint;
            paint.setColor(i);
            this.redDotPaint.setAntiAlias(true);
            TextPaint textPaint = new TextPaint();
            this.textPaint = textPaint;
            textPaint.setColor(-1);
            this.textPaint.setFakeBoldText(true);
            this.textPaint.setTextAlign(Paint.Align.CENTER);
            float convertToScreenInt = PdrUtil.convertToScreenInt("8px", 0, 0, f);
            this.circle8PX = convertToScreenInt;
            this.textPaint.setTextSize(convertToScreenInt);
            this.circle4PX = PdrUtil.convertToScreenInt("4px", 0, 0, f);
        }
    }

    public class BadgeRelateiveLayout extends LinearLayout {
        private String badgeStr;
        Rect canvasRect;
        float circle4PX;
        float circle8PX;
        private boolean isDrawRedDot;
        private Paint redDotPaint;
        TextPaint textPaint;

        public BadgeRelateiveLayout(Context context) {
            super(context);
            this.isDrawRedDot = false;
            this.badgeStr = "";
            this.canvasRect = new Rect();
        }

        @Override
        protected void dispatchDraw(Canvas canvas) {
            super.dispatchDraw(canvas);
            canvas.getClipBounds(this.canvasRect);
            if (this.isDrawRedDot && PdrUtil.isEmpty(this.badgeStr)) {
                Rect rect = this.canvasRect;
                float f = this.circle4PX;
                canvas.drawCircle(rect.right - f, rect.top + f, f, this.redDotPaint);
            }
            if (this.badgeStr.length() > 0) {
                Rect rect2 = new Rect();
                TextPaint textPaint = this.textPaint;
                String str = this.badgeStr;
                textPaint.getTextBounds(str, 0, str.length(), rect2);
                Paint paint = new Paint(this.redDotPaint);
                paint.setColor(-65536);
                float abs = (this.canvasRect.right - Math.abs(rect2.width())) - this.circle8PX;
                Rect rect3 = this.canvasRect;
                int i = rect3.top;
                RectF rectF = new RectF(abs, i, rect3.right, i + Math.abs(rect2.height()) + this.circle4PX);
                canvas.drawRoundRect(rectF, rectF.height() / 2.0f, rectF.height() / 2.0f, paint);
                Paint.FontMetrics fontMetrics = this.textPaint.getFontMetrics();
                canvas.drawText(this.badgeStr, rectF.centerX(), (rectF.centerY() - (fontMetrics.top / 2.0f)) - (fontMetrics.bottom / 2.0f), this.textPaint);
            }
        }

        @Override
        public void draw(Canvas canvas) {
            super.draw(canvas);
        }

        public void setBadgeStr(String str) {
            if (str == null || str.equals(this.badgeStr)) {
                return;
            }
            if (str.length() > 4) {
                this.badgeStr = str.trim().substring(0, 3) + "…";
            } else {
                this.badgeStr = str.trim();
            }
            postInvalidate();
        }

        public void setDrawRedDot(boolean z) {
            if (this.isDrawRedDot != z) {
                this.isDrawRedDot = z;
                postInvalidate();
            }
        }

        public void setRedDotColor(int i) {
            this.redDotPaint.setColor(i);
            postInvalidate();
        }

        public BadgeRelateiveLayout(TitleNView titleNView, Context context, float f, int i) {
            this(context);
            Paint paint = new Paint();
            this.redDotPaint = paint;
            paint.setColor(i);
            this.redDotPaint.setAntiAlias(true);
            TextPaint textPaint = new TextPaint();
            this.textPaint = textPaint;
            textPaint.setColor(-1);
            this.textPaint.setFakeBoldText(true);
            this.textPaint.setTextAlign(Paint.Align.CENTER);
            float convertToScreenInt = PdrUtil.convertToScreenInt("8px", 0, 0, f);
            this.circle8PX = convertToScreenInt;
            this.textPaint.setTextSize(convertToScreenInt);
            this.circle4PX = PdrUtil.convertToScreenInt("4px", 0, 0, f);
        }
    }

    @Override
    public void setTitleColor(int i) {
        TextView textView = this.mTitleView;
        if (textView == null || i == textView.getTextColors().getDefaultColor()) {
            return;
        }
        this.mTitleView.setTextColor(i);
    }
}