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

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


package com.tencent.mtt.external.audio.rn;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.LinearLayout;
import com.tencent.common.manifest.EventEmiter;
import com.tencent.common.manifest.EventMessage;
import com.tencent.common.utils.UrlUtils;
import com.tencent.mtt.AppInfoHolder;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
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.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.external.audio.control.AudioPlayFacade;
import com.tencent.mtt.external.audio.view.AudioFMDoubleScrollView;
import com.tencent.mtt.external.audio.view.AudioFMPullDownView;
import com.tencent.mtt.external.audiofm.rn.AudioFMReactWebview;
import com.tencent.mtt.external.audiofm.rn.AudioHippyPageEventHub;
import com.tencent.mtt.external.audiofm.utils.AudioFMUrlUtils;
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.hippy.qb.views.doublescrollview.HippyQBDoubleScrollViewController;
import com.tencent.mtt.hippy.qb.views.webview.HippyQBWebViewController;
import com.tencent.mtt.hippy.uimanager.HippyCustomViewCreator;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.setting.BaseSettings;
import com.tencent.mtt.view.layout.QBLinearLayout;
import com.tencent.mtt.welfare.facade.IPendantService;
import com.tencent.tbs.core.MainActivity;
import java.util.HashMap;

public class AudioPlayerRNDialogView implements Handler.Callback, IAudioPlayerViewWrapper, HippyEventHubBase.IEventListener {

    private String f50427a;

    private String f50428b;

    private String f50429c;

    private AudioHippyPageEventHub f50430d;
    private QBHippyWindow e;
    private AudioFMReactWebview f;
    private int g;
    private Handler h;
    private boolean i;
    private AudioFMDoubleScrollView j;
    private Activity k;

    public AudioPlayerRNDialogView(Activity activity) {
        this((Bundle) null);
        this.k = activity;
    }

    public AudioPlayerRNDialogView(Bundle bundle) {
        this.f50427a = "AudioApp";
        this.f50428b = "AudioApp";
        this.f50429c = "qb://ext/audiofm/player?module=AudioApp&component=AudioApp";
        this.h = new Handler(Looper.getMainLooper(), this);
        this.g = hashCode();
        if (bundle != null) {
            this.i = bundle.getBoolean("fromBottomBar", false);
        }
    }

    private void a(String str) {
        AudioHippyPageEventHub audioHippyPageEventHub;
        QBHippyWindow qBHippyWindow = this.e;
        if (qBHippyWindow == null || (audioHippyPageEventHub = this.f50430d) == null) {
            return;
        }
        audioHippyPageEventHub.sendEventToHippy(HippyEventHubDefineBase.EVENT_LIFE_CYCLE, qBHippyWindow.getId(), "", str, null, this.f50428b, String.valueOf(this.g), null);
    }

    private String c(Bundle bundle) {
        String string = bundle.getString("url", this.f50429c);
        HashMap<String, String> urlParam = UrlUtils.getUrlParam(string);
        if (urlParam == null || !urlParam.containsKey("scene")) {
            StringBuilder sb = new StringBuilder();
            sb.append("scene=");
            sb.append(this.i ? "bottomBar" : "outside");
            string = UrlUtils.addParamsToUrl(string, sb.toString());
        }
        if ((urlParam == null || !urlParam.containsKey("from")) && !TextUtils.isEmpty(AudioFMUrlUtils.a())) {
            string = UrlUtils.addParamsToUrl(string, "from=" + AudioFMUrlUtils.a());
        }
        if ((urlParam == null || !urlParam.containsKey("ch")) && !TextUtils.isEmpty(AudioFMUrlUtils.d())) {
            string = UrlUtils.addParamsToUrl(string, "ch=" + AudioFMUrlUtils.d());
        }
        if ((urlParam == null || !urlParam.containsKey("ich")) && !TextUtils.isEmpty(AudioFMUrlUtils.b())) {
            string = UrlUtils.addParamsToUrl(string, "ich=" + AudioFMUrlUtils.b());
        }
        return a(bundle, string);
    }

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

    private HippyCustomViewCreator e() {
        return new HippyCustomViewCreator() {
            @Override
            public View createCustomView(String str, Context context, HippyMap hippyMap) {
                if (TextUtils.equals(str, HippyQBWebViewController.CLASS_NAME) || TextUtils.equals(str, HippyQBWebViewController.CLASS_NAME_TKD)) {
                    AudioPlayerRNDialogView.this.f = new AudioFMReactWebview(context);
                    if (AudioPlayerRNDialogView.this.f50430d != null) {
                        AudioPlayerRNDialogView.this.f50430d.setHippyQBWebView(AudioPlayerRNDialogView.this.f);
                    }
                    return AudioPlayerRNDialogView.this.f;
                }
                if (!TextUtils.equals(str, HippyQBDoubleScrollViewController.CLASS_NAME) && !TextUtils.equals(str, HippyQBDoubleScrollViewController.CLASS_NAME_TKD)) {
                    return null;
                }
                AudioPlayerRNDialogView.this.j = new AudioFMDoubleScrollView(context);
                return AudioPlayerRNDialogView.this.j;
            }
        };
    }

    @Override
    public View a(Activity activity, Bundle bundle) {
        ModuleParams.Builder builder = new ModuleParams.Builder();
        Bundle bundle2 = new Bundle();
        if (bundle != null) {
            bundle2.putAll(bundle);
        }
        a(bundle2);
        b(bundle2);
        String c2 = c(bundle2);
        this.f50430d = new AudioHippyPageEventHub(ActivityHandler.b().a());
        bundle2.putString("abilities", this.f50430d.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(this.g));
        bundle2.putString("url", c2);
        this.e = (QBHippyWindow) QBHippyEngineManager.getInstance().loadModule(builder.setModuleName(this.f50428b).setComponentName(this.f50427a).setDemotionUrl("https://audio.html5.qq.com").setActivity(ActivityHandler.b().a()).setProps(bundle2).setCustomViewCreator(e()).build());
        this.e.setLayoutParams(new LinearLayout.LayoutParams(-1, -1, 1.0f));
        this.f50430d.setQBHippyWindow(this.e);
        this.f50430d.registerListener(this);
        this.f50430d.registNativeMethod(this.f50427a);
        QBLinearLayout qBLinearLayout = new QBLinearLayout(activity);
        if (!"novelAudioPlayer".equals(this.f50427a)) {
            qBLinearLayout.setPadding(0, this.k == null ? BaseSettings.a().m() : 0, 0, 0);
        }
        qBLinearLayout.addView(this.e);
        AudioFMPullDownView audioFMPullDownView = new AudioFMPullDownView(activity);
        audioFMPullDownView.addView(qBLinearLayout);
        audioFMPullDownView.a(qBLinearLayout, this.e);
        audioFMPullDownView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        audioFMPullDownView.setCallback(new AudioFMPullDownView.Callback() {
            @Override
            public void a() {
                AudioPlayFacade.getInstance().closeFullPlayerWindow();
            }

            @Override
            public boolean b() {
                return AudioPlayerRNDialogView.this.j != null && AudioPlayerRNDialogView.this.j.a();
            }
        });
        Activity a2 = ActivityHandler.b().a();
        if (!(a2 instanceof MainActivity)) {
            EventEmiter.getDefault().emit(new EventMessage(IPendantService.EVENT_PAGE_SWITCH, 0, 0, a2.getWindow().getDecorView(), new String[]{"", "qb://ext/audiofm"}));
        }
        return audioFMPullDownView;
    }

    String a(Bundle bundle, String str) {
        String str2;
        if (!str.contains("module=novelAudioPlayer")) {
            return str;
        }
        int i = bundle.getInt("openFrom");
        if (i != 1) {
            str2 = i == 2 ? "fromentry=novelReader" : "fromentry=floatBall";
            return UrlUtils.addParamsToUrl(str, "_t=" + System.currentTimeMillis());
        }
        str = UrlUtils.addParamsToUrl(str, str2);
        return UrlUtils.addParamsToUrl(str, "_t=" + System.currentTimeMillis());
    }

    @Override
    public void a() {
        a(HippyEventHubDefineBase.TYPE_ON_ACTIVE);
    }

    void a(Bundle bundle) {
        bundle.putAll(((IPlayerParamsCache) QBContext.getInstance().getService(IPlayerParamsCache.class)).getOpenNovelPlayerParams());
        bundle.putBoolean("firstOpenHippyNovelAudio", d());
    }

    @Override
    public void a(View.OnClickListener onClickListener) {
        AudioHippyPageEventHub audioHippyPageEventHub = this.f50430d;
        if (audioHippyPageEventHub != null) {
            audioHippyPageEventHub.setOnMoreMenuClickListener(onClickListener);
        }
    }

    @Override
    public void b() {
        a(HippyEventHubDefineBase.TYPE_ON_DEACTIVE);
    }

    void b(Bundle bundle) {
        String string = bundle.getString("url");
        if (!TextUtils.isEmpty(string) && string.contains("module=novelAudioPlayer")) {
            this.f50428b = "novelAudioPlayer";
            this.f50427a = "novelAudioPlayer";
            this.f50429c = string;
        }
    }

    @Override
    public void c() {
        a(HippyEventHubDefineBase.TYPE_ON_DESTROY);
        AudioHippyPageEventHub audioHippyPageEventHub = this.f50430d;
        if (audioHippyPageEventHub != null) {
            audioHippyPageEventHub.deRegistNativeMethod(this.f50428b);
            this.f50430d.unregisterListener(this);
            this.f50430d.setQBHippyWindow((QBHippyWindow) null);
            this.f50430d.setHippyQBWebView(null);
            this.f50430d.setOnMoreMenuClickListener(null);
            this.f50430d = null;
        }
        QBHippyWindow qBHippyWindow = this.e;
        if (qBHippyWindow != null) {
            ViewParent parent = qBHippyWindow.getParent();
            if (parent != null && (parent instanceof ViewGroup)) {
                ((ViewGroup) parent).removeView(this.e);
            }
            QBHippyEngineManager.getInstance().destroyModule(this.e);
        }
        AudioFMReactWebview audioFMReactWebview = this.f;
        if (audioFMReactWebview != null) {
            if (audioFMReactWebview.getRealWebView() != null) {
                this.f.getRealWebView().setEventView(null);
            }
            this.f.destroy();
            this.f = null;
        }
        this.j = null;
    }

    @Override
    public boolean handleMessage(Message message) {
        if (message.what == 1) {
            Object[] objArr = (Object[]) message.obj;
            String str = (String) objArr[0];
            HippyMap hippyMap = (HippyMap) objArr[1];
            if (str.equals(HippyEventHubDefineBase.ABILITY_LOAD_RNPAGE.name)) {
                String string = hippyMap.getString("url");
                hippyMap.getString(ICircleModule.CIRCLE_ARGUMENTS);
                ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(string).d(true).c(0).b(1));
            }
            AudioPlayFacade.getInstance().closeFullPlayerWindow();
        }
        return false;
    }

    @Override
    public boolean onReactEvent(String str, HippyMap hippyMap, Promise promise) {
        if (hippyMap.containsKey(ICircleModule.CIRCLE_ARGUMENTS) && !TextUtils.equals(String.valueOf(this.g), hippyMap.getMap(ICircleModule.CIRCLE_ARGUMENTS).getString("primaryKey"))) {
            return false;
        }
        if (hippyMap.containsKey("primaryKey") && !TextUtils.equals(String.valueOf(this.g), hippyMap.getString("primaryKey"))) {
            return false;
        }
        Message obtainMessage = this.h.obtainMessage();
        obtainMessage.what = 1;
        obtainMessage.obj = new Object[]{str, hippyMap};
        this.h.sendMessage(obtainMessage);
        return true;
    }
}