QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 HippyTabPage.java 源代码,内容仅作参考
package com.tencent.mtt.hippy.qb.portal;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.UrlUtils;
import com.tencent.mtt.R;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.utils.DeviceUtils;
import com.tencent.mtt.base.utils.UIUtil;
import com.tencent.mtt.browser.StatusBarColorManager;
import com.tencent.mtt.browser.jsextension.open.IOpenJsApis;
import com.tencent.mtt.browser.setting.manager.SkinManager;
import com.tencent.mtt.browser.window.IWebView;
import com.tencent.mtt.browser.window.PageFrame;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.browser.window.WindowChangedListener;
import com.tencent.mtt.browser.window.WindowManager;
import com.tencent.mtt.browser.window.data.PageInfo;
import com.tencent.mtt.browser.window.home.view.FrameTabPage;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.hippy.HippyEngine;
import com.tencent.mtt.hippy.HippyInstanceContext;
import com.tencent.mtt.hippy.common.HippyArray;
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.HippyNativePage;
import com.tencent.mtt.hippy.qb.portal.HippyVerticalConfigManager;
import com.tencent.mtt.hippy.qb.portal.eventdefine.HippyEventHubDefineBase;
import com.tencent.mtt.hippy.qb.portal.eventdefine.HippyPageEventDefine;
import com.tencent.mtt.hippy.qb.update.HippyUpdateQuery;
import com.tencent.mtt.hippy.qb.update.MTT.JsBundleModule;
import com.tencent.mtt.hippy.qb.views.webview.HippyQBWebView;
import com.tencent.mtt.hippy.qb.views.webview.HippyQBWebViewController;
import com.tencent.mtt.hippy.uimanager.HippyCustomViewCreator;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.setting.BaseSettings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import qb.a.e;
public class HippyTabPage extends FrameTabPage implements WindowChangedListener, IHippyWindow.HippyInstanceLoadSuccessListener, ModuleParams.CusTomDemotionCallBack, HippyEventHubBase.IEventListener {
public static final String KEY_BACKGROUNDCOLOR = "backgroundColor";
public static final String KEY_COMP_NAME = "component";
public static final String KEY_MODULE = "module";
public static final String KEY_PRELOAD_WEBVIEW_URL = "preloadUrl";
public static final String KEY_TITLE = "title";
public static final String KEY_TRANSPARENT = "transparent";
public static final int MSG_BACK = 6;
public static final int MSG_INTERCEPT_UNIT_TIME = 4;
public static final int MSG_LOAD_RN_PAGE = 5;
public static final int MSG_RN_EVENT = 1;
public static final int MSG_SET_PAGE_TITLE = 3;
public static final String TAG = "HippyNativePage";
HippyEngine.BackPressHandler mBackPressHandler;
protected AtomicInteger mBackStackCounter;
String mBackgroundColor;
private StatusBarColorManager mBarColorManager;
private int mColor;
private Context mContext;
private String mCustomPageTitle;
private boolean mDebugUrl;
private HippyPageEventHub mEventHub;
protected Map<String, String> mExtraData;
protected int mHashCode;
HippyInstanceContext mHippyContext;
protected QBHippyWindow mHippyRootView;
private boolean mIsForNative;
private boolean mIsLoadHippySuccess;
private boolean mLayoutFromTop;
private int mOrientation;
private ArrayList<PeddingAction> mPeddingActions;
HippyQBWebView mPreloadWebView;
protected HippyBackWebView mReactBakWebView;
private HippyVerticalConfigManager.ReactConfigInfo mReactConfigInfo;
private boolean mSetComment;
private int mStatusBarHeight;
private Handler mUIHandler;
protected String mUrl;
protected HippyNativePage.IRNPageUrlListener mUrlListener;
public String mValueCompName;
public String mValueModule;
public String mValuePreloadWebviewUrl;
public String mValueTitle;
public static class PeddingAction {
String mAction;
Bundle mBundle;
public PeddingAction(String str, Bundle bundle) {
this.mAction = str;
this.mBundle = bundle;
}
}
public class PreloadWebViewCustomCreatorWrapper implements HippyCustomViewCreator {
PreloadWebViewCustomCreatorWrapper() {
}
@Override
public View createCustomView(String str, Context context, HippyMap hippyMap) {
if (TextUtils.equals(str, HippyQBWebViewController.CLASS_NAME) || TextUtils.equals(str, HippyQBWebViewController.CLASS_NAME_TKD)) {
String string = (hippyMap != null && hippyMap.containsKey("source") && hippyMap.getMap("source").containsKey("uri")) ? hippyMap.getMap("source").getString("uri") : "";
if (HippyTabPage.this.mPreloadWebView != null && !TextUtils.isEmpty(string) && string.equalsIgnoreCase(HippyTabPage.this.mPreloadWebView.getUrl())) {
final HippyQBWebView hippyQBWebView = HippyTabPage.this.mPreloadWebView;
HippyTabPage hippyTabPage = HippyTabPage.this;
hippyTabPage.mPreloadWebView = null;
hippyTabPage.post(new Runnable() {
@Override
public void run() {
hippyQBWebView.setEventsPending(false);
}
});
return hippyQBWebView;
}
}
if (HippyTabPage.this.getCustomViewCreater() != null) {
return HippyTabPage.this.getCustomViewCreater().createCustomView(str, context, hippyMap);
}
return null;
}
}
public HippyTabPage(Context context, String str, HippyNativePage.IRNPageUrlListener iRNPageUrlListener) {
super(context);
this.mValueModule = "";
this.mValueCompName = "";
this.mValueTitle = "";
this.mValuePreloadWebviewUrl = "";
this.mExtraData = new HashMap();
this.mUrl = "";
this.mHashCode = 0;
this.mPeddingActions = new ArrayList<>();
this.mOrientation = -1;
this.mCustomPageTitle = null;
this.mSetComment = false;
this.mDebugUrl = false;
this.mStatusBarHeight = 0;
this.mBarColorManager = null;
this.mColor = -2;
this.mLayoutFromTop = false;
this.mIsForNative = true;
this.mBackStackCounter = new AtomicInteger(0);
this.mIsLoadHippySuccess = false;
this.mBackgroundColor = null;
this.mPreloadWebView = null;
this.mContext = context;
this.mHashCode = hashCode();
this.mUrlListener = iRNPageUrlListener;
this.mBarColorManager = StatusBarColorManager.getInstance();
this.mStatusBarHeight = BaseSettings.a().m();
preLoadUrl(str);
initBackGroundColor();
WindowManager.a().a((WindowChangedListener) this);
this.mUIHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message message) {
PageFrame s;
int i = message.what;
if (i == 1) {
HippyTabPage.this.mUrlListener.onRNPageEventHandle(message);
return;
}
if (i != 5) {
if (i != 6) {
return;
}
if (HippyTabPage.this.mBackStackCounter.get() > 0) {
HippyTabPage.this.mBackStackCounter.decrementAndGet();
HippyTabPage.this.doHippyBack();
return;
} else {
if (HippyTabPage.this.interceptGoBackEvent() || (s = WindowManager.a().s()) == null || !s.canGoBack(false)) {
return;
}
s.back(false);
return;
}
}
HippyMap hippyMap = (HippyMap) ((Object[]) message.obj)[1];
String string = hippyMap.getString("url");
Bundle bundle = new Bundle(9);
bundle.putString("url", string);
if (hippyMap.containsKey(ICircleModule.CIRCLE_ARGUMENTS)) {
HippyMap map = hippyMap.getMap(ICircleModule.CIRCLE_ARGUMENTS);
for (String str2 : map.keySet()) {
bundle.putString(str2, map.get(str2).toString());
}
}
((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(string).a(bundle).d(true).c(0).b(1));
}
};
initPreloadWebview();
}
private void analysisStatusBarColor() {
int d2;
boolean l = SkinManager.s().l();
int i = R.color.theme_home_color_bkg;
if (l) {
d2 = MttResources.c(R.color.theme_home_color_bkg);
} else {
int statusBarBgColor = getStatusBarBgColor();
HippyVerticalConfigManager.ReactConfigInfo reactConfigInfo = this.mReactConfigInfo;
if (reactConfigInfo == null || reactConfigInfo.color == -2) {
if (this.mValueModule.equals("infoportal")) {
i = R.color.info_read_portal_top_bar_bg;
} else if (this.mValueModule.equals("sports")) {
i = R.color.a2u;
} else if (this.mValueModule.equals("nearby")) {
i = e.J;
} else if (statusBarBgColor != -2) {
this.mColor = statusBarBgColor;
i = -1;
}
if (i == -1) {
return;
} else {
d2 = MttResources.d(i);
}
} else {
d2 = this.mReactConfigInfo.color;
}
}
this.mColor = d2;
}
public void doHippyBack() {
sendEvent(HippyEventHubDefineBase.EVENT_DO_BACK, new Bundle(9));
}
private void handleGetJSBundleVersion(HippyMap hippyMap, final Promise promise) {
HippyArray array = hippyMap.getArray("moduleList");
final HippyMap hippyMap2 = new HippyMap();
ArrayList<String> arrayList = new ArrayList<>();
if (array == null || array.size() <= 0) {
return;
}
for (int i = 0; i < array.size(); i++) {
String string = array.getString(i);
String moduleVersionName = QBHippyEngineManager.getInstance().getModuleVersionName(string);
if (TextUtils.isEmpty(moduleVersionName)) {
arrayList.add(string);
} else {
hippyMap2.pushString(string, moduleVersionName);
}
}
if (arrayList.size() > 0) {
new HippyUpdateQuery().query(arrayList, new HippyUpdateQuery.QueryCallback() {
@Override
public void onFinish(ArrayList<JsBundleModule> arrayList2, int i2) {
if (arrayList2 != null && arrayList2.size() > 0) {
Iterator<JsBundleModule> it = arrayList2.iterator();
while (it.hasNext()) {
JsBundleModule next = it.next();
hippyMap2.pushString(next.sModuleName, next.sVersionName);
}
}
promise.resolve(hippyMap2);
}
});
} else {
promise.resolve(hippyMap2);
}
}
private void handleHippyRootParams(boolean z) {
if (this.mHippyRootView == null) {
return;
}
if (!this.mLayoutFromTop || (DeviceUtils.aq() && !DeviceUtils.a())) {
ViewGroup.LayoutParams layoutParams = this.mHippyRootView.getLayoutParams();
if (layoutParams == null) {
layoutParams = new FrameLayout.LayoutParams(-1, -1);
}
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
layoutParams2.topMargin = 0;
this.mHippyRootView.setLayoutParams(layoutParams2);
return;
}
ViewGroup.LayoutParams layoutParams3 = this.mHippyRootView.getLayoutParams();
if (layoutParams3 == null) {
layoutParams3 = new FrameLayout.LayoutParams(-1, -1);
}
FrameLayout.LayoutParams layoutParams4 = (FrameLayout.LayoutParams) layoutParams3;
layoutParams4.topMargin = ((z && getResources().getConfiguration().orientation != 2) || DeviceUtils.a()) ? -this.mStatusBarHeight : 0;
this.mHippyRootView.setLayoutParams(layoutParams4);
}
private void handlePreloadWebView(final HippyMap hippyMap) {
BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
@Override
public void run() {
if (HippyTabPage.this.mPreloadWebView == null) {
String string = hippyMap.getString("uri");
if (TextUtils.isEmpty(string) || HippyTabPage.this.mHippyRootView == null || HippyTabPage.this.mHippyRootView.getHippyRootView() == null) {
return;
}
HippyCustomViewCreator customViewCreater = HippyTabPage.this.getCustomViewCreater();
if (customViewCreater != null) {
HippyTabPage hippyTabPage = HippyTabPage.this;
hippyTabPage.mPreloadWebView = (HippyQBWebView) customViewCreater.createCustomView(HippyQBWebViewController.CLASS_NAME, hippyTabPage.mHippyRootView.getHippyRootView().getContext(), hippyMap);
}
if (HippyTabPage.this.mPreloadWebView == null) {
HippyTabPage hippyTabPage2 = HippyTabPage.this;
hippyTabPage2.mPreloadWebView = new HippyQBWebView(hippyTabPage2.mHippyRootView.getHippyRootView().getContext());
}
HippyTabPage.this.mPreloadWebView.setEventsPending(true);
HippyTabPage.this.mPreloadWebView.loadUrl(string);
}
}
});
}
private void handleUsedTime(HippyMap hippyMap) {
if ("start".equals(hippyMap.getString("type"))) {
HashMap hashMap = new HashMap();
hashMap.put("scene", hippyMap.getString("scene"));
String string = hippyMap.getString("kv");
if (!TextUtils.isEmpty(string)) {
hashMap.put("kv", string);
}
hashMap.put("ch", hippyMap.getString("ch") + "__" + hippyMap.getString("tabid"));
}
}
private void initBackGroundColor() {
}
private void initPreloadWebview() {
if (this.mPreloadWebView != null || TextUtils.isEmpty(this.mValuePreloadWebviewUrl)) {
return;
}
Context context = this.mContext;
this.mHippyContext = new HippyInstanceContext(context instanceof Activity ? (Activity) context : ActivityHandler.b().a());
HippyCustomViewCreator customViewCreater = getCustomViewCreater();
if (customViewCreater != null) {
this.mPreloadWebView = (HippyQBWebView) customViewCreater.createCustomView(HippyQBWebViewController.CLASS_NAME, this.mHippyContext, null);
}
if (this.mPreloadWebView == null) {
this.mPreloadWebView = new HippyQBWebView(this.mHippyContext);
}
this.mPreloadWebView.setEventsPending(true);
this.mPreloadWebView.loadUrl(this.mValuePreloadWebviewUrl);
}
public void sendLifecycleEvent(String str, Bundle bundle) {
QBHippyWindow qBHippyWindow = this.mHippyRootView;
if (qBHippyWindow != null) {
this.mEventHub.sendEventToHippy(HippyEventHubDefineBase.EVENT_LIFE_CYCLE, qBHippyWindow.getId(), "", str, null, this.mValueModule, String.valueOf(this.mHashCode), bundle);
}
}
private void sendPeddingEvent() {
if (this.mPeddingActions.size() > 0) {
this.mUIHandler.post(new Runnable() {
@Override
public void run() {
Iterator it = HippyTabPage.this.mPeddingActions.iterator();
while (it.hasNext()) {
PeddingAction peddingAction = (PeddingAction) it.next();
HippyTabPage.this.sendLifecycleEvent(peddingAction.mAction, peddingAction.mBundle);
}
HippyTabPage.this.mPeddingActions.clear();
}
});
}
}
private void startCreateReactView() {
if (this.mHippyRootView != null) {
return;
}
createReactView();
}
private void switchBakWebView() {
if (this.mReactBakWebView != null) {
return;
}
HippyVerticalConfigManager.ReactConfigInfo reactConfigInfo = this.mReactConfigInfo;
this.mReactBakWebView = new HippyBackWebView(getContext(), reactConfigInfo != null ? reactConfigInfo.backUrl : "");
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
layoutParams.topMargin = this.mStatusBarHeight;
addView(this.mReactBakWebView, layoutParams);
}
@Override
public void active() {
super.active();
if (this.mIsLoadHippySuccess) {
sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_ACTIVE, new Bundle());
} else {
this.mPeddingActions.add(new PeddingAction(HippyEventHubDefineBase.TYPE_ON_ACTIVE, new Bundle()));
}
HippyBackWebView hippyBackWebView = this.mReactBakWebView;
if (hippyBackWebView != null) {
hippyBackWebView.active();
}
}
@Override
public boolean can(int i) {
switch (i) {
case 1:
case 2:
case 3:
case 4:
case 7:
case 9:
case 11:
case 12:
return true;
case 5:
HippyVerticalConfigManager.ReactConfigInfo reactConfigInfo = this.mReactConfigInfo;
if (reactConfigInfo != null) {
return reactConfigInfo.noImage;
}
return true;
case 6:
case 8:
case 10:
default:
return false;
}
}
public void changeStatusBar(boolean z, boolean z2) {
HippyVerticalConfigManager.ReactConfigInfo reactConfigInfo = this.mReactConfigInfo;
this.mLayoutFromTop = reactConfigInfo == null ? false : reactConfigInfo.layoutFromTop;
Context context = this.mContext;
Window window = ((context == null || !(context instanceof Activity)) ? ActivityHandler.b().a() : (Activity) context).getWindow();
boolean ai = DeviceUtils.ai();
handleHippyRootParams(z);
if (DeviceUtils.aq()) {
analysisStatusBarColor();
if (this.mHippyRootView != null) {
if (this.mLayoutFromTop || ai || !z || !this.mIsForNative || DeviceUtils.a()) {
QBHippyWindow qBHippyWindow = this.mHippyRootView;
qBHippyWindow.setPadding(qBHippyWindow.getPaddingLeft(), 0, this.mHippyRootView.getPaddingRight(), this.mHippyRootView.getPaddingBottom());
} else {
QBHippyWindow qBHippyWindow2 = this.mHippyRootView;
qBHippyWindow2.setPadding(qBHippyWindow2.getPaddingLeft(), this.mStatusBarHeight, this.mHippyRootView.getPaddingRight(), this.mHippyRootView.getPaddingBottom());
}
this.mHippyRootView.setStatusBarColor(this.mColor);
}
if (z2 && this.mIsForNative && isActive()) {
this.mBarColorManager.a(window, statusBarType());
}
}
}
public void createReactView() {
this.mEventHub = getEventHub();
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);
}
bundle.putInt("multiWindowCount", WindowManager.a().y());
for (String str : this.mExtraData.keySet()) {
bundle.putString(str, this.mExtraData.get(str));
}
ModuleParams.Builder builder = new ModuleParams.Builder();
builder.setCusTomDemotionCallBack(this);
Context context = this.mContext;
Activity a2 = (context == null || !(context instanceof Activity)) ? ActivityHandler.b().a() : (Activity) context;
processBuilder(builder);
ModuleParams build = builder.setModuleName(this.mValueModule).setComponentName(this.mValueCompName).setProps(bundle).setActivity(a2).setCustomViewCreator(new PreloadWebViewCustomCreatorWrapper()).setDebug(this.mDebugUrl).setInstanceLoadSuccessListener(this).build();
HippyInstanceContext hippyInstanceContext = this.mHippyContext;
if (hippyInstanceContext != null) {
build.mHippyInstanceContext = hippyInstanceContext;
}
this.mHippyRootView = (QBHippyWindow) QBHippyEngineManager.getInstance().loadModule(build);
boolean l = BaseSettings.a().l();
if (this.mHippyRootView != null) {
addView(this.mHippyRootView, new FrameLayout.LayoutParams(-1, -1));
registerMethod();
} else {
Logs.e("HippyNativePage", "mRnRootView loadModule Failed");
switchBakWebView();
}
changeStatusBar(!l, true);
sendPeddingEvent();
}
@Override
public void deActive() {
super.deActive();
if (this.mIsLoadHippySuccess) {
sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_DEACTIVE, new Bundle());
} else {
this.mPeddingActions.add(new PeddingAction(HippyEventHubDefineBase.TYPE_ON_DEACTIVE, new Bundle()));
}
HippyBackWebView hippyBackWebView = this.mReactBakWebView;
if (hippyBackWebView != null) {
hippyBackWebView.deactive();
}
}
@Override
public void destroy() {
super.destroy();
sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_DESTROY, new Bundle());
HippyPageEventHub hippyPageEventHub = this.mEventHub;
if (hippyPageEventHub != null) {
hippyPageEventHub.deRegistNativeMethod(this.mValueModule);
this.mEventHub.unregisterListener(this);
this.mEventHub.setQBHippyWindow((QBHippyWindow) null);
this.mEventHub = null;
}
QBHippyWindow qBHippyWindow = this.mHippyRootView;
if (qBHippyWindow != null) {
qBHippyWindow.destroy();
this.mHippyRootView = null;
}
WindowManager.a().b(this);
}
@Override
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;
}
protected HippyPageEventHub getEventHub() {
return new HippyPageEventHub();
}
@Override
public String getPageTitle() {
if (!TextUtils.isEmpty(this.mCustomPageTitle)) {
return this.mCustomPageTitle;
}
HippyVerticalConfigManager.ReactConfigInfo reactConfigInfo = this.mReactConfigInfo;
return reactConfigInfo == null ? !TextUtils.isEmpty(this.mValueTitle) ? this.mValueTitle : "" : reactConfigInfo.title;
}
@Override
public View getPageView() {
return this;
}
public HippyVerticalConfigManager.ReactConfigInfo getRNVerticalConfigInfo(String str) {
return HippyVerticalConfigManager.getInstance().getConfigInfo(this.mValueModule);
}
public HashMap<String, Object> getReactConfig() {
return new HashMap<>();
}
@Override
public PageInfo getShareBundle() {
PageInfo pageInfo = new PageInfo();
pageInfo.a(getPageTitle()).b(getUrl());
pageInfo.a(0);
return pageInfo;
}
@Override
public int getStatusBarBgColor() {
return super.getStatusBarBgColor();
}
@Override
public String getUrl() {
return this.mUrl;
}
protected boolean interceptGoBackEvent() {
return false;
}
@Override
public void loadSuccess() {
this.mIsLoadHippySuccess = true;
if (!TextUtils.isEmpty(this.mValueModule) && !TextUtils.isEmpty(this.mValueCompName)) {
this.mReactConfigInfo = getRNVerticalConfigInfo(this.mValueModule);
Activity a2 = ActivityHandler.b().a();
if (a2 != null) {
changeStatusBar(true ^ DeviceUtils.b(a2.getWindow()), isActive());
}
}
sendPeddingEvent();
}
@Override
public void loadUrl(String str) {
super.loadUrl(str);
preLoadUrl(str);
if (TextUtils.isEmpty(this.mValueModule) || TextUtils.isEmpty(this.mValueCompName)) {
return;
}
startCreateReactView();
}
@Override
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
if (isActive()) {
if (configuration.orientation == 2) {
changeStatusBar(false, false);
} else {
changeStatusBar(!((ActivityHandler.b().a().getWindow().getAttributes().flags & 1024) == 1024), false);
}
}
}
@Override
public void onCurrentPageFrameChanged(PageFrame pageFrame) {
sendWndNum(WindowManager.a().w());
}
@Override
public void onImageLoadConfigChanged() {
super.onImageLoadConfigChanged();
QBHippyWindow qBHippyWindow = this.mHippyRootView;
if (qBHippyWindow != null) {
qBHippyWindow.onNoPicModeChanged();
}
HippyBackWebView hippyBackWebView = this.mReactBakWebView;
if (hippyBackWebView != null) {
hippyBackWebView.onImageLoadConfigChanged();
}
}
@Override
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i != 4) {
return super.onKeyDown(i, keyEvent);
}
boolean z = false;
if (this.mHippyRootView != null) {
if (this.mBackPressHandler == null) {
this.mBackPressHandler = new HippyEngine.BackPressHandler() {
@Override
public void handleBackPress() {
PageFrame s = WindowManager.a().s();
if (s != null) {
s.back(false);
}
}
};
}
z = this.mHippyRootView.onBackPressed(this.mBackPressHandler);
}
if (z) {
return true;
}
return super.onKeyDown(i, keyEvent);
}
@Override
public void onPageFrameAdded(PageFrame pageFrame, boolean z) {
sendWndNum(WindowManager.a().w());
}
@Override
public void onPageFrameClosed(PageFrame pageFrame) {
sendWndNum(WindowManager.a().w());
}
@Override
public boolean onReactEvent(String str, HippyMap hippyMap, Promise promise) {
if (hippyMap.containsKey(ICircleModule.CIRCLE_ARGUMENTS) && !TextUtils.equals(String.valueOf(this.mHashCode), hippyMap.getMap(ICircleModule.CIRCLE_ARGUMENTS).getString("primaryKey"))) {
return true;
}
if (hippyMap.containsKey("primaryKey")) {
if (!TextUtils.equals(String.valueOf(this.mHashCode), hippyMap.getString("primaryKey"))) {
return true;
}
} else {
if (HippyEventHubDefineBase.ABILITY_INTERCEPT_UNIT_TIME.name.equalsIgnoreCase(str)) {
this.mUIHandler.obtainMessage(4, new Object[]{str, hippyMap}).sendToTarget();
return true;
}
if (HippyPageEventDefine.ABILITY_USED_TIME.name.equalsIgnoreCase(str)) {
handleUsedTime(hippyMap);
return true;
}
if (HippyEventHubDefineBase.ABILITY_SET_PAGE_TITLE.name.equalsIgnoreCase(str)) {
this.mCustomPageTitle = hippyMap.getString("title");
return true;
}
if (HippyEventHubDefineBase.ABILITY_LOAD_RNPAGE.name.equalsIgnoreCase(str)) {
this.mUIHandler.obtainMessage(5, new Object[]{str, hippyMap}).sendToTarget();
return true;
}
if (HippyEventHubDefineBase.ABILITY_BACK.name.equalsIgnoreCase(str)) {
this.mUIHandler.obtainMessage(6, new Object[]{str, hippyMap}).sendToTarget();
return true;
}
if (HippyEventHubDefineBase.ABILITY_ADD_BACK_STACK.name.equalsIgnoreCase(str)) {
this.mBackStackCounter.incrementAndGet();
return true;
}
if (HippyEventHubDefineBase.ABILITY_REMOVE_BACK_STACK.name.equalsIgnoreCase(str)) {
if (this.mBackStackCounter.decrementAndGet() < 0) {
this.mBackStackCounter.set(0);
}
return true;
}
if (HippyEventHubDefineBase.ABILITY_PRELOAD_WEBVIEW.name.equalsIgnoreCase(str)) {
handlePreloadWebView(hippyMap);
return true;
}
if (HippyEventHubDefineBase.ABILITY_GET_JSBUNDLE_VERSION.name.equalsIgnoreCase(str)) {
handleGetJSBundleVersion(hippyMap, promise);
}
}
if (this.mUrlListener == null) {
return false;
}
Message obtainMessage = this.mUIHandler.obtainMessage();
obtainMessage.what = 1;
obtainMessage.obj = new Object[]{str, hippyMap};
this.mUIHandler.sendMessage(obtainMessage);
return true;
}
@Override
public void onSkinChanged() {
super.onSkinChanged();
QBHippyWindow qBHippyWindow = this.mHippyRootView;
if (qBHippyWindow != null) {
qBHippyWindow.onSkinChanged();
}
HippyBackWebView hippyBackWebView = this.mReactBakWebView;
if (hippyBackWebView != null) {
hippyBackWebView.switchSkin();
}
changeStatusBar(!((ActivityHandler.b().a().getWindow().getAttributes().flags & 1024) == 1024), true);
initBackGroundColor();
}
@Override
public void onStart() {
super.onStart();
if (this.mIsLoadHippySuccess) {
sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_START, new Bundle());
} else {
this.mPeddingActions.add(new PeddingAction(HippyEventHubDefineBase.TYPE_ON_START, new Bundle()));
}
}
@Override
public void onStatusBarVisible(boolean z) {
super.onStatusBarVisible(z);
changeStatusBar(z, false);
}
@Override
public void onStop() {
super.onStop();
if (this.mIsLoadHippySuccess) {
sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_STOP, new Bundle());
} else {
this.mPeddingActions.add(new PeddingAction(HippyEventHubDefineBase.TYPE_ON_STOP, new Bundle()));
}
}
public void preLoadUrl(String str) {
HashMap<String, String> urlParam = UrlUtils.getUrlParam(str);
if (urlParam != null && urlParam.containsKey("module") && urlParam.containsKey("component")) {
if (urlParam.containsKey("backgroundColor")) {
this.mBackgroundColor = urlParam.get("backgroundColor");
}
this.mValueTitle = urlParam.get("title");
this.mValueModule = urlParam.get("module");
this.mValueCompName = urlParam.get("component");
if (!TextUtils.isEmpty(this.mValueModule) && !TextUtils.isEmpty(this.mValueCompName)) {
this.mReactConfigInfo = getRNVerticalConfigInfo(this.mValueModule);
}
if (urlParam.containsKey("debug")) {
String str2 = urlParam.get("debug");
this.mDebugUrl = IOpenJsApis.TRUE.equalsIgnoreCase(str2) || "1".equalsIgnoreCase(str2);
}
if (urlParam.containsKey("preloadUrl")) {
this.mValuePreloadWebviewUrl = urlParam.get("preloadUrl");
}
this.mUrl = str;
}
}
protected void processBuilder(ModuleParams.Builder builder) {
}
protected void registerMethod() {
QBHippyWindow qBHippyWindow = this.mHippyRootView;
if (qBHippyWindow != null) {
this.mEventHub.setQBHippyWindow(qBHippyWindow);
this.mEventHub.registerListener(this);
this.mEventHub.registNativeMethod(this.mValueModule);
}
}
@Override
public void reload(int i) {
super.reload(i);
if (this.mHippyRootView != null) {
sendLifecycleEvent("reload", new Bundle());
}
HippyBackWebView hippyBackWebView = this.mReactBakWebView;
if (hippyBackWebView != null) {
hippyBackWebView.reload();
}
}
@Override
public void restoreState(String str, Bundle bundle) {
loadUrl(str);
}
public void sendEvent(String str, Bundle bundle) {
QBHippyWindow qBHippyWindow = this.mHippyRootView;
if (qBHippyWindow != null) {
qBHippyWindow.sendEvent(str, bundle);
}
}
public void sendWndNum(int i) {
HippyPageEventHub hippyPageEventHub = this.mEventHub;
if (hippyPageEventHub != null) {
hippyPageEventHub.sendWndNum(i);
}
}
@Override
public void setBackground(Drawable drawable) {
super.setBackground(drawable);
}
@Override
public void setBackgroundDrawable(Drawable drawable) {
super.setBackgroundDrawable(drawable);
}
@Override
public IWebView.STATUS_BAR statusBarType() {
return SkinManager.s().l() ? IWebView.STATUS_BAR.NO_SHOW_LIGHT : (UIUtil.a(this.mColor) || this.mColor == 0) ? IWebView.STATUS_BAR.NO_SHOW_DARK : IWebView.STATUS_BAR.NO_SHOW_LIGHT;
}
@Override
public void toPage(String str) {
super.toPage(str);
Bundle bundle = new Bundle(9);
bundle.putString("toPageUrl", str);
if (this.mIsLoadHippySuccess) {
sendLifecycleEvent(HippyEventHubDefineBase.TYPE_ON_TOPAGE, bundle);
} else {
this.mPeddingActions.add(new PeddingAction(HippyEventHubDefineBase.TYPE_ON_TOPAGE, new Bundle()));
}
}
}