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

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


package com.tencent.mtt.external.novel.player;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.LinearLayout;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.UrlUtils;
import com.tencent.mtt.AppInfoHolder;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.stat.UnitTimeHelper;
import com.tencent.mtt.browser.audiofm.facade.AudioPlayItem;
import com.tencent.mtt.browser.audiofm.facade.IAudioPlayFacade;
import com.tencent.mtt.browser.audiofm.facade.IAudioPlayerViewWrapper;
import com.tencent.mtt.browser.audiofm.facade.IPlayerParamsCache;
import com.tencent.mtt.browser.setting.manager.SkinEventHub;
import com.tencent.mtt.browser.setting.skin.ISkinChangeListener;
import com.tencent.mtt.browser.setting.skin.SkinChangeEvent;
import com.tencent.mtt.browser.ui.PullDownView;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.hippy.common.HippyMap;
import com.tencent.mtt.hippy.modules.Promise;
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.eventdefine.HippyEventHubDefineBase;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.qbcontext.core.QBContext;

public class NovelPlayerContainer implements IAudioPlayerViewWrapper, ISkinChangeListener, HippyEventHubBase.IEventListener {

    QBHippyWindow f55659a;

    NovelPlayerHippyEventHub f55660b;

    int f55661c;

    protected NovelPlayer f55662d;
    protected View e;
    String f;
    boolean g;
    protected boolean h = false;

    public NovelPlayerContainer(String str) {
        this.f = str;
    }

    private void a(String str) {
        NovelPlayerHippyEventHub novelPlayerHippyEventHub;
        QBHippyWindow qBHippyWindow = this.f55659a;
        if (qBHippyWindow == null || (novelPlayerHippyEventHub = this.f55660b) == null) {
            return;
        }
        novelPlayerHippyEventHub.sendEventToHippy(HippyEventHubDefineBase.EVENT_LIFE_CYCLE, qBHippyWindow.getId(), "", str, null, "novelAudioPlayer", String.valueOf(this.f55661c), null);
    }

    public void a(String str, HippyMap hippyMap) {
        String str2;
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        sb.append(", ");
        if (hippyMap != null) {
            str2 = hippyMap.getString("url") + ", " + hippyMap.getString(ICircleModule.CIRCLE_ARGUMENTS);
        } else {
            str2 = " null bundle.";
        }
        sb.append(str2);
        Logs.c("NovelPlayerContainer", sb.toString());
        if (str.equals(HippyEventHubDefineBase.ABILITY_LOAD_RNPAGE.name)) {
            ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(hippyMap.getString("url")).d(true).c(0).b(1));
        } else if (str.equals(HippyEventHubDefineBase.ABILITY_BACK.name)) {
            ((IAudioPlayFacade) QBContext.getInstance().getService(IAudioPlayFacade.class)).closeFullPlayerWindow();
        }
    }

    private void e() {
        this.g = true;
        Logs.c("NovelPlayerContainer", "release: boodId=" + this.f);
        a(HippyEventHubDefineBase.TYPE_ON_DESTROY);
        NovelPlayerHippyEventHub novelPlayerHippyEventHub = this.f55660b;
        if (novelPlayerHippyEventHub != null) {
            novelPlayerHippyEventHub.deRegistNativeMethod("novelAudioPlayer");
            this.f55660b.unregisterListener(this);
            this.f55660b.setQBHippyWindow((QBHippyWindow) null);
            this.f55660b.setHippyQBWebView(null);
            this.f55660b.setOnMoreMenuClickListener(null);
            this.f55660b = null;
        }
        QBHippyWindow qBHippyWindow = this.f55659a;
        if (qBHippyWindow != null) {
            ViewParent parent = qBHippyWindow.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(this.f55659a);
            }
            QBHippyEngineManager.getInstance().destroyModule(this.f55659a);
        }
        SkinEventHub.a().a(this);
    }

    private boolean f() {
        AudioPlayItem g = ((IAudioPlayFacade) QBContext.getInstance().getService(IAudioPlayFacade.class)).getPlayController().g();
        return g == null || !g.l;
    }

    @Override
    public View a(Activity activity, Bundle bundle) {
        Logs.c("NovelPlayerContainer", "createContentView: bookid=" + this.f);
        this.h = true;
        UnitTimeHelper unitTimeHelper = new UnitTimeHelper();
        unitTimeHelper.a("novelAudioPlayer");
        StatManager.b().a(unitTimeHelper, 0);
        View view = this.e;
        if (view != null) {
            ViewParent parent = view.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(this.e);
            }
            Logs.c("NovelPlayerContainer", "createContentView: 已存在相同书籍播放器对象,复用");
        } else {
            SkinEventHub.a().b(this);
            this.f55659a = (QBHippyWindow) QBHippyEngineManager.getInstance().loadModule(new ModuleParams.Builder().setModuleName("novelAudioPlayer").setComponentName("novelAudioPlayer").setDemotionUrl("https://audio.html5.qq.com").setActivity(activity).setProps(b(activity, bundle)).build());
            this.f55659a.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0f));
            this.f55660b.setQBHippyWindow(this.f55659a);
            d();
            LinearLayout linearLayout = new LinearLayout(activity);
            linearLayout.addView(this.f55659a);
            this.e = a(activity, linearLayout);
        }
        return this.e;
    }

    PullDownView a(Activity activity, LinearLayout linearLayout) {
        PullDownView pullDownView = new PullDownView(activity);
        pullDownView.addView(linearLayout);
        pullDownView.a(linearLayout, this.f55659a);
        pullDownView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        pullDownView.setCallback(new PullDownView.Callback() {
            @Override
            public void a() {
                Logs.c("NovelPlayerContainer", "onAnimationEnd: boodId=" + NovelPlayerContainer.this.f);
                ((IAudioPlayFacade) QBContext.getInstance().getService(IAudioPlayFacade.class)).closeFullPlayerWindow();
            }

            @Override
            public boolean b() {
                return false;
            }
        });
        return pullDownView;
    }

    @Override
    public void a() {
        Logs.c("NovelPlayerContainer", "active: boodId=" + this.f);
        a(HippyEventHubDefineBase.TYPE_ON_ACTIVE);
    }

    @Override
    public void a(View.OnClickListener onClickListener) {
        NovelPlayerHippyEventHub novelPlayerHippyEventHub = this.f55660b;
        if (novelPlayerHippyEventHub != null) {
            novelPlayerHippyEventHub.setOnMoreMenuClickListener(onClickListener);
        }
    }

    Bundle b(Activity activity, Bundle bundle) {
        String str;
        this.f55661c = hashCode();
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            bundle2.putAll(bundle);
        }
        bundle2.putAll(((IPlayerParamsCache) QBContext.getInstance().getService(IPlayerParamsCache.class)).getOpenNovelPlayerParams());
        bundle2.putBoolean("firstOpenHippyNovelAudio", f());
        String string = bundle2.getString("url", "");
        int i = bundle2.getInt("openFrom");
        if (i != 1) {
            str = i == 2 ? "fromentry=novelReader" : "fromentry=floatBall";
            String addParamsToUrl = UrlUtils.addParamsToUrl(string, "_t=" + System.currentTimeMillis());
            this.f55660b = new NovelPlayerHippyEventHub(activity);
            bundle2.putString("abilities", this.f55660b.getCommonAbilityString());
            bundle2.putString("guid", AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_GUID));
            bundle2.putString("qua2", AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_QUA2_3));
            bundle2.putString("primaryKey", String.valueOf(hashCode()));
            bundle2.putString("url", addParamsToUrl);
            return bundle2;
        }
        string = UrlUtils.addParamsToUrl(string, str);
        String addParamsToUrl2 = UrlUtils.addParamsToUrl(string, "_t=" + System.currentTimeMillis());
        this.f55660b = new NovelPlayerHippyEventHub(activity);
        bundle2.putString("abilities", this.f55660b.getCommonAbilityString());
        bundle2.putString("guid", AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_GUID));
        bundle2.putString("qua2", AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_QUA2_3));
        bundle2.putString("primaryKey", String.valueOf(hashCode()));
        bundle2.putString("url", addParamsToUrl2);
        return bundle2;
    }

    @Override
    public void b() {
        Logs.c("NovelPlayerContainer", "deactive: boodId=" + this.f);
        a(HippyEventHubDefineBase.TYPE_ON_DEACTIVE);
    }

    @Override
    public void c() {
        Logs.c("NovelPlayerContainer", "destroy: boodId=" + this.f);
        if (!this.f55662d.b()) {
            e();
        }
        if (this.h) {
            this.h = false;
            UnitTimeHelper unitTimeHelper = new UnitTimeHelper();
            unitTimeHelper.a("novelAudioPlayer");
            StatManager.b().c(unitTimeHelper, 0);
        }
    }

    void d() {
        this.f55660b.registerListener(this);
        this.f55660b.registNativeMethod("novelAudioPlayer");
        this.f55662d = new NovelPlayer();
        this.f55662d.a(this.f55660b);
        this.f55662d.a(this);
        this.f55662d.a(String.valueOf(this.f55661c));
        this.f55660b.a(this.f55662d);
    }

    @Override
    public boolean onReactEvent(final String str, final HippyMap hippyMap, Promise promise) {
        if (hippyMap.containsKey(ICircleModule.CIRCLE_ARGUMENTS)) {
            if (!TextUtils.equals(String.valueOf(this.f55661c), hippyMap.getMap(ICircleModule.CIRCLE_ARGUMENTS).getString("primaryKey"))) {
                return false;
            }
        }
        if (hippyMap.containsKey("primaryKey")) {
            if (!TextUtils.equals(String.valueOf(this.f55661c), hippyMap.getString("primaryKey"))) {
                return false;
            }
        }
        BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
            @Override
            public void run() {
                NovelPlayerContainer.this.a(str, hippyMap);
            }
        });
        return true;
    }

    @Override
    public void onSkinChanged(SkinChangeEvent skinChangeEvent) {
        QBHippyWindow qBHippyWindow = this.f55659a;
        if (qBHippyWindow != null) {
            qBHippyWindow.onSkinChanged();
        }
    }
}