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

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


package com.tencent.mtt.browser.bra.toolbar.shareguide;

import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.tencent.common.manifest.EventEmiter;
import com.tencent.common.manifest.EventMessage;
import com.tencent.common.manifest.annotation.CreateMethod;
import com.tencent.common.manifest.annotation.EventReceiver;
import com.tencent.common.manifest.annotation.EventThreadMode;
import com.tencent.common.task.Continuation;
import com.tencent.common.task.QBTask;
import com.tencent.common.utils.StringUtils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.luggage.wxa.kr.ay;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.wup.DomainListDataManager;
import com.tencent.mtt.base.wup.PreferenceData;
import com.tencent.mtt.browser.bra.toolbar.ToolBarMenuContainer;
import com.tencent.mtt.browser.multiwindow.MultiWindowEvent;
import com.tencent.mtt.browser.multiwindow.facade.IMultiWindowService;
import com.tencent.mtt.browser.window.IWebView;
import com.tencent.mtt.lottie.LottieAnimationView;
import com.tencent.mtt.lottie.LottieComposition;
import com.tencent.mtt.lottie.LottieListener;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

public class ToolBarShareGuideManager implements ActivityHandler.ApplicationStateListener {

    private static ToolBarShareGuideManager f36074a;
    private static final Set<String> k = new HashSet<String>() {
        {
            add("m.ixigua.com");
            add("m.bilibili.com");
            add("m.iqiyi.com");
            add("haokan.baidu.com");
            add("m.youku.com");
            add("m.v.qq.com");
            add("d.bilibili.com");
            add("m.tv.sohu.com");
            add("www.bilibili.com");
            add("waptv.sogou.com");
            add("i.56.com");
            add("mobi.yy.com");
            add("tv.cctv.com");
            add("movie.sogou.com");
            add("pps.m.iqiyi.com");
            add("m.56.com");
            add("ishop.sogou.com");
            add("m.le.com");
            add("m.ssports.iqiyi.com");
            add("v.qq.com");
            add("m.baidu.com");
            add("m.sogou.com");
            add("readmodel.m.sogou.com");
            add("wap.sogou.com");
            add("wenwen.sogou.com");
            add("mp.weixin.qq.com");
            add("www.zhihu.com");
            add("baike.sogou.com");
            add("a.app.qq.com");
            add("zhidao.baidu.com");
            add("m.sohu.com");
            add("wk.baidu.com");
            add("pic.sogou.com");
            add("wapv.sogou.com");
            add("zhinan.sogou.com");
            add("baike.baidu.com");
            add("jingyan.baidu.com");
            add("3g.163.com");
            add("m.weibo.cn");
            add("a3.app.qq.com");
        }
    };

    private String f36075b;

    private long f36076c;
    private ToolBarMenuContainer f;
    private ActivityHandler.State h;

    private long f36077d = 0;
    private long e = 0;
    private boolean g = false;
    private Set<String> i = new HashSet();
    private Handler j = new AnonymousClass1(Looper.getMainLooper());

    public class AnonymousClass1 extends Handler {
        AnonymousClass1(Looper looper) {
            super(looper);
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 1) {
                ToolBarShareGuideManager.this.f36077d = 0L;
                if (ToolBarShareGuideManager.this.f != null && ToolBarShareGuideManager.this.f.getGlobalVisibleRect(new Rect()) && ToolBarShareGuideManager.this.f.isShown()) {
                    final LottieAnimationView shareLottieView = ToolBarShareGuideManager.this.f.getShareLottieView();
                    LottiePrefetchHelper.a(ToolBarShareGuideManager.this.f36075b, new LottieListener<LottieComposition>() {
                        @Override
                        public void onResult(final LottieComposition lottieComposition) {
                            if (lottieComposition != null) {
                                QBTask.b((Callable) new Callable<Void>() {
                                    @Override
                                    public Void call() throws Exception {
                                        ToolBarShareGuideManager.this.a(lottieComposition, shareLottieView);
                                        return null;
                                    }
                                });
                            }
                        }
                    });
                }
            }
        }
    }

    static class AnonymousClass5 {

        static final int[] f36085a = new int[MultiWindowEvent.Action.values().length];

        static {
            try {
                f36085a[MultiWindowEvent.Action.SHOW.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f36085a[MultiWindowEvent.Action.DISMISS.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f36085a[MultiWindowEvent.Action.ADD.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f36085a[MultiWindowEvent.Action.SWITCH.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f36085a[MultiWindowEvent.Action.CLEAR.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
        }
    }

    public ToolBarShareGuideManager() {
        this.f36075b = "https://static.res.qq.com/nav/qb/share/lottie/toolbar_share_lottie_v9.zip";
        this.f36076c = 0L;
        this.f36076c = StringUtils.a(PreferenceData.a("THIRD_WEB_GUIDE_SHARE_TIME_SPAN"), 60L) * 1000;
        String a2 = PreferenceData.a("THIRD_WEB_GUIDE_SHARE_LOTTIE_URL");
        if (!TextUtils.isEmpty(a2)) {
            this.f36075b = a2;
        }
        LottiePrefetchHelper.a(this.f36075b);
        c();
        EventEmiter.getDefault().register(IMultiWindowService.EVENT_MULTI_WINDOW, this);
    }

    public void a(LottieComposition lottieComposition, LottieAnimationView lottieAnimationView) {
        lottieAnimationView.setComposition(lottieComposition);
        lottieAnimationView.setFrame(0);
        this.f.a();
    }

    public void a(List<String> list) {
        if (list == null || list.isEmpty()) {
            return;
        }
        this.i.addAll(list);
    }

    private void c() {
        QBTask.c(new Callable<List<String>>() {
            @Override
            public List<String> call() throws Exception {
                return DomainListDataManager.a().a(ay.CTRL_INDEX);
            }
        }).a(new Continuation<List<String>, Object>() {
            @Override
            public Object then(QBTask<List<String>> qBTask) throws Exception {
                if (qBTask == null || qBTask.e() == null) {
                    return null;
                }
                ToolBarShareGuideManager.this.a(qBTask.e());
                return null;
            }
        }, 6);
    }

    private void d() {
        this.j.removeMessages(1);
        Handler handler = this.j;
        handler.sendMessageDelayed(handler.obtainMessage(1), this.f36076c);
        this.f36077d = System.currentTimeMillis();
    }

    private void e() {
        if (this.e != 0) {
            Handler handler = this.j;
            handler.sendMessageDelayed(handler.obtainMessage(1), this.e);
            this.f36077d = System.currentTimeMillis();
            this.e = 0L;
        }
    }

    private void f() {
        if (this.f36077d != 0) {
            this.j.removeMessages(1);
            this.e = this.f36076c - (System.currentTimeMillis() - this.f36077d);
        }
    }

    private void g() {
        this.f36077d = 0L;
        this.e = 0L;
        this.j.removeMessages(1);
        ToolBarMenuContainer toolBarMenuContainer = this.f;
        if (toolBarMenuContainer != null) {
            toolBarMenuContainer.b();
        }
    }

    public static ToolBarShareGuideManager getInstance() {
        if (f36074a == null) {
            synchronized (ToolBarShareGuideManager.class) {
                if (f36074a == null) {
                    f36074a = new ToolBarShareGuideManager();
                }
            }
        }
        return f36074a;
    }

    public void a() {
        if (this.g) {
            return;
        }
        EventEmiter.getDefault().register("com.tencent.mtt.browser.window.data.WindowInfo.onPageBackOrForwardChanged", this);
        ActivityHandler.b().a(this);
        this.g = true;
    }

    public void a(ToolBarMenuContainer toolBarMenuContainer) {
        this.f = toolBarMenuContainer;
    }

    public void b() {
        if (this.g) {
            EventEmiter.getDefault().unregister("com.tencent.mtt.browser.window.data.WindowInfo.onPageBackOrForwardChanged", this);
            ActivityHandler.b().b(this);
            this.g = false;
        }
    }

    @Override
    public void onApplicationState(ActivityHandler.State state) {
        if (!(this.h == ActivityHandler.State.background && state == ActivityHandler.State.foreground) && state == ActivityHandler.State.background) {
            this.h = ActivityHandler.State.background;
            g();
        }
    }

    @EventReceiver(createMethod = CreateMethod.NONE, eventName = IMultiWindowService.EVENT_MULTI_WINDOW, threadMode = EventThreadMode.MAINTHREAD)
    public void onMultiWindowStateChange(EventMessage eventMessage) {
        if (eventMessage != null && (eventMessage.arg instanceof MultiWindowEvent)) {
            int i = AnonymousClass5.f36085a[((MultiWindowEvent) eventMessage.arg).a().ordinal()];
            if (i == 1) {
                f();
                return;
            }
            if (i == 2) {
                e();
            } else if (i == 3 || i == 4 || i == 5) {
                g();
            }
        }
    }

    @EventReceiver(createMethod = CreateMethod.NONE, eventName = "com.tencent.mtt.browser.window.data.WindowInfo.onPageBackOrForwardChanged", threadMode = EventThreadMode.MAINTHREAD)
    public void onSceneChanged(EventMessage eventMessage) {
        if (eventMessage == null) {
            return;
        }
        g();
        IWebView iWebView = (IWebView) eventMessage.args[0];
        IWebView iWebView2 = (IWebView) eventMessage.args[1];
        if (iWebView2 != null && iWebView2.isPage(IWebView.TYPE.HTML)) {
            String hostNew = UrlUtils.getHostNew(iWebView2.getUrl());
            if (k.contains(hostNew) && !this.i.contains(hostNew)) {
                d();
                return;
            }
        } else if (iWebView == null || !iWebView.isPage(IWebView.TYPE.HTML) || iWebView2 == null || iWebView2.isPage(IWebView.TYPE.HTML)) {
            return;
        }
        g();
    }
}