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

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


package com.tencent.mtt.hippy.qb.portal;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import com.tencent.common.utils.UrlUtils;
import com.tencent.mtt.browser.jsextension.open.IOpenJsApis;
import com.tencent.mtt.hippy.common.HippyMap;
import com.tencent.mtt.hippy.modules.Promise;
import com.tencent.mtt.hippy.qb.IHippyWindow;
import com.tencent.mtt.hippy.qb.ModuleParams;
import com.tencent.mtt.hippy.qb.QBHippyEngineManager;
import com.tencent.mtt.hippy.qb.QBHippyWindow;
import com.tencent.mtt.hippy.qb.modules.base.ICircleModule;
import com.tencent.mtt.hippy.qb.portal.HippyEventHubBase;
import com.tencent.mtt.hippy.qb.portal.HippyVerticalConfigManager;
import com.tencent.mtt.hippy.qb.portal.eventdefine.HippyEventHubDefineBase;
import com.tencent.mtt.hippy.uimanager.HippyCustomViewCreator;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.view.layout.QBFrameLayout;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public abstract class HippyRootViewBase extends QBFrameLayout implements IHippyWindow.HippyBusinessLoadListener, IHippyWindow.HippyInstanceLoadSuccessListener, ModuleParams.CusTomDemotionCallBack, HippyEventHubBase.IEventListener {
    public static final String KEY_COMP_NAME = "component";
    public static final String KEY_MODULE = "module";
    public static final String TAG = "RNNativePage";
    private boolean mDebugUrl;
    private HippyEventHubBase mEventHub;
    protected HippyEventHubBase.IEventListener mEventListener;
    protected Map<String, String> mExtraData;
    private int mHashCode;
    private QBHippyWindow mHippyRootView;
    private int mOrientation;
    private ArrayList<String> mPeddingActions;
    protected HippyBackWebView mReactBakWebView;
    private HippyVerticalConfigManager.ReactConfigInfo mReactConfigInfo;
    private String mUrl;
    public String mValueCompName;
    public String mValueModule;

    public HippyRootViewBase(Context context, String str) {
        super(context);
        this.mValueModule = "";
        this.mValueCompName = "";
        this.mExtraData = new HashMap();
        this.mHashCode = 0;
        this.mPeddingActions = new ArrayList<>();
        this.mUrl = "";
        this.mOrientation = -1;
        this.mDebugUrl = false;
        this.mEventListener = null;
        this.mHashCode = hashCode();
        this.mUrl = str;
    }

    private void createReactView() {
        this.mEventHub = createEventHub(this.mHippyRootView);
        Bundle bundle = new Bundle(9);
        bundle.putString("abilities", this.mEventHub.getCommonAbilityString());
        bundle.putString("customerAbilities", this.mEventHub.getCustomerAbilityString());
        bundle.putString("primaryKey", String.valueOf(this.mHashCode));
        bundle.putString("url", this.mUrl);
        int i = this.mOrientation;
        if (i != -1) {
            bundle.putInt("orientation", i);
        }
        for (String str : this.mExtraData.keySet()) {
            bundle.putString(str, this.mExtraData.get(str));
        }
        this.mHippyRootView = (QBHippyWindow) QBHippyEngineManager.getInstance().loadModule(new ModuleParams.Builder().setModuleName(this.mValueModule).setComponentName(this.mValueCompName).setProps(bundle).setActivity((Activity) getContext()).setCusTomDemotionCallBack(this).setCustomViewCreator(getCustomViewCreater()).setDebug(this.mDebugUrl).setInstanceLoadSuccessListener(this).setHippyBusinessLoadListener(this).build());
        if (this.mHippyRootView != null) {
            addView(this.mHippyRootView, new ViewGroup.LayoutParams(-1, -1));
            this.mEventHub.setQBHippyWindow(this.mHippyRootView);
            this.mEventHub.registerListener(this);
            this.mEventHub.registNativeMethod(this.mValueModule);
        } else {
            Logs.e(TAG, "mRnRootView loadModule Failed");
        }
        sendPeddingEvent();
    }

    private void sendPeddingEvent() {
        if (this.mPeddingActions.size() > 0) {
            post(new Runnable() {
                @Override
                public void run() {
                    Iterator it = HippyRootViewBase.this.mPeddingActions.iterator();
                    while (it.hasNext()) {
                        HippyRootViewBase.this.sendLifecycleEvent((String) it.next());
                    }
                    HippyRootViewBase.this.mPeddingActions.clear();
                }
            });
        }
    }

    private void startCreateReactView() {
        if (this.mHippyRootView != null) {
            return;
        }
        createReactView();
    }

    public void active() {
        if (this.mHippyRootView != null) {
            sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_ACTIVE);
        } else {
            this.mPeddingActions.add(HippyEventHubDefineBase.TYPE_ON_ACTIVE);
        }
    }

    protected abstract HippyEventHubBase createEventHub(QBHippyWindow qBHippyWindow);

    public void deactive() {
        if (this.mHippyRootView != null) {
            sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_DEACTIVE);
        } else {
            this.mPeddingActions.add(HippyEventHubDefineBase.TYPE_ON_DEACTIVE);
        }
    }

    public void destroy() {
        sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_DESTROY);
        HippyEventHubBase hippyEventHubBase = this.mEventHub;
        if (hippyEventHubBase != null) {
            hippyEventHubBase.deRegistNativeMethod(this.mValueModule);
            this.mEventHub.unregisterListener(this);
            this.mEventHub = null;
        }
        QBHippyWindow qBHippyWindow = this.mHippyRootView;
        if (qBHippyWindow != null) {
            qBHippyWindow.destroy();
            this.mHippyRootView = null;
        }
    }

    public View getCusTomDemotionView() {
        HippyBackWebView hippyBackWebView = this.mReactBakWebView;
        if (hippyBackWebView != null) {
            return hippyBackWebView;
        }
        HippyVerticalConfigManager.ReactConfigInfo reactConfigInfo = this.mReactConfigInfo;
        this.mReactBakWebView = new HippyBackWebView(getContext(), reactConfigInfo != null ? reactConfigInfo.backUrl : "https://qbrnweb.html5.qq.com/favnew");
        return this.mReactBakWebView;
    }

    public HippyCustomViewCreator getCustomViewCreater() {
        return null;
    }

    public void loadSuccess() {
    }

    public void loadUrl(String str) {
        preLoadUrl(str);
        if (TextUtils.isEmpty(this.mValueModule) || TextUtils.isEmpty(this.mValueCompName)) {
            return;
        }
        startCreateReactView();
    }

    @Override
    public void onBusinessBundleLoadBegin() {
    }

    public void onBusinessBundleLoadEnd() {
    }

    @Override
    public void onBusinessBundleLoadSuc() {
    }

    public boolean onReactEvent(String str, HippyMap hippyMap, Promise promise) {
        if (hippyMap == null) {
            return false;
        }
        if (hippyMap.containsKey(ICircleModule.CIRCLE_ARGUMENTS)) {
            HippyMap map = hippyMap.getMap(ICircleModule.CIRCLE_ARGUMENTS);
            if (map == null) {
                return false;
            }
            if (!TextUtils.equals(String.valueOf(this.mHashCode), map.getString("primaryKey"))) {
                return true;
            }
        }
        if (hippyMap.containsKey("primaryKey")) {
            if (!TextUtils.equals(String.valueOf(this.mHashCode), hippyMap.getString("primaryKey"))) {
                return true;
            }
        }
        HippyEventHubBase.IEventListener iEventListener = this.mEventListener;
        return iEventListener != null && iEventListener.onReactEvent(str, hippyMap, promise);
    }

    public void onSkinChanged() {
        QBHippyWindow qBHippyWindow = this.mHippyRootView;
        if (qBHippyWindow != null) {
            qBHippyWindow.onSkinChanged();
        }
        HippyBackWebView hippyBackWebView = this.mReactBakWebView;
        if (hippyBackWebView != null) {
            hippyBackWebView.switchSkin();
        }
    }

    public void preLoadUrl(String str) {
        HashMap<String, String> urlParam = UrlUtils.getUrlParam(str);
        if (urlParam.containsKey("module") && urlParam.containsKey("component")) {
            if (urlParam.containsKey("module") && urlParam.containsKey("component")) {
                this.mValueModule = urlParam.get("module");
                this.mValueCompName = urlParam.get("component");
                if (!TextUtils.isEmpty(this.mValueModule) && !TextUtils.isEmpty(this.mValueCompName)) {
                    this.mReactConfigInfo = HippyVerticalConfigManager.getInstance().getConfigInfo(this.mValueModule);
                }
            }
            if (urlParam.containsKey("orientation")) {
                int parseInt = Integer.parseInt(urlParam.get("orientation"));
                this.mOrientation = -1;
                if (parseInt == 2 || parseInt == 1) {
                    this.mOrientation = parseInt;
                }
            }
            if (urlParam.containsKey("debug")) {
                String str2 = urlParam.get("debug");
                if (IOpenJsApis.TRUE.equalsIgnoreCase(str2) || "1".equalsIgnoreCase(str2)) {
                    this.mDebugUrl = true;
                } else {
                    this.mDebugUrl = false;
                }
            }
            this.mUrl = str;
        }
    }

    public void sendEvent(String str, Bundle bundle) {
        QBHippyWindow qBHippyWindow = this.mHippyRootView;
        if (qBHippyWindow != null) {
            this.mEventHub.sendEventToHippy(str, qBHippyWindow.getId(), "", "", null, this.mValueModule, String.valueOf(this.mHashCode), bundle);
        }
    }

    public void sendLifecycleEvent(String str) {
        HippyEventHubBase hippyEventHubBase;
        QBHippyWindow qBHippyWindow = this.mHippyRootView;
        if (qBHippyWindow == null || (hippyEventHubBase = this.mEventHub) == null) {
            return;
        }
        hippyEventHubBase.sendEventToHippy(HippyEventHubDefineBase.EVENT_LIFE_CYCLE, qBHippyWindow.getId(), "", str, null, this.mValueModule, String.valueOf(this.mHashCode), null);
    }

    public void setEventListener(HippyEventHubBase.IEventListener iEventListener) {
        this.mEventListener = iEventListener;
    }

    public void setExtraData(Map<String, String> map) {
        if (map == null) {
            return;
        }
        this.mExtraData.putAll(map);
    }
}