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

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


package com.tencent.mtt.browser.homepage.view.search;

import MTT.SmartBox_HotWordsEgg;
import android.content.Context;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.manifest.EventEmiter;
import com.tencent.common.manifest.EventMessage;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.base.ui.widget.QBWebImageView;
import com.tencent.mtt.browser.homepage.HomePageProxy;
import com.tencent.mtt.browser.homepage.view.HomePageUIConfig;
import com.tencent.mtt.browser.multiwindow.facade.IMultiWindowService;
import com.tencent.mtt.browser.multiwindow.facade.MultiWindowStateListener;
import com.tencent.mtt.gifimage.GifDrawable;
import com.tencent.mtt.operation.event.EventLog;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.search.hotwords.SearchHotwordInfo;
import com.tencent.mtt.search.view.common.skin.SkinMode;
import com.tencent.mtt.search.view.common.skin.SkinModeDetector;
import java.util.HashMap;
import qb.a.e;
import qb.homepage.BuildConfig;

public class SearchLightGifController {
    private static boolean g;

    private final SearchGifImageView f41025a;

    private final FrameLayout f41026b;

    private final FrameLayout f41027c;

    private final FrameLayout f41028d;
    private final boolean e;
    private boolean i;
    private int j;
    private SearchHotwordInfo k;
    private QBWebImageView l;
    private Context m;
    private volatile long n;
    private int o;
    private int p;
    private int f = -1;
    private boolean h = false;
    private float q = -1.0f;

    public interface OnFetchGifListener {
        void a();

        void a(GifDrawable gifDrawable);
    }

    public SearchLightGifController(Context context, FrameLayout frameLayout, FrameLayout frameLayout2, FrameLayout frameLayout3, boolean z) {
        this.f41025a = new SearchGifImageView(context);
        this.f41025a.a(new GifDrawable.OnGifPlayCountBack() {
            @Override
            public void a(long j) {
                if (j != 1 || SearchLightGifController.this.k == null) {
                    return;
                }
                SearchBarGifManager.getInstance().c(SearchLightGifController.this.k.a());
            }
        });
        f();
        this.f41028d = frameLayout3;
        this.f41026b = frameLayout;
        this.f41027c = frameLayout2;
        this.e = z;
        this.m = context;
    }

    private FrameLayout.LayoutParams a(GifDrawable gifDrawable) {
        float f = SearchBarView.f40980a;
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) (gifDrawable.getIntrinsicWidth() / (gifDrawable.getIntrinsicHeight() / f)), (int) f);
        layoutParams.leftMargin = this.j;
        return layoutParams;
    }

    private void a(final SmartBox_HotWordsEgg smartBox_HotWordsEgg) {
        HomePageProxy.getInstance().a(smartBox_HotWordsEgg.iWordId > 0);
        this.f = smartBox_HotWordsEgg.iId;
        EventLog.a("搜索", "探照灯", "开始下载探照灯资源", "", "lypeerluo");
        GifDrawableFetcher.a(smartBox_HotWordsEgg.sIcon, new OnFetchGifListener() {
            @Override
            public void a() {
                SearchBarGifManager.getInstance().c(smartBox_HotWordsEgg);
            }

            @Override
            public void a(GifDrawable gifDrawable) {
                EventLog.a("搜索", "探照灯", "下载探照灯资源成功", "", "lypeerluo");
                if (SearchBarGifManager.getInstance().a(smartBox_HotWordsEgg)) {
                    SearchLightGifController.this.a(smartBox_HotWordsEgg, gifDrawable);
                    SearchBarGifManager.getInstance().b(smartBox_HotWordsEgg);
                } else {
                    EventLog.a("搜索", "探照灯", "当前有其他运营在跑着,先hold住", "", "lypeerluo");
                    SearchBarGifManager.getInstance().a(SearchLightGifController.this);
                    SearchBarGifManager.getInstance().c(smartBox_HotWordsEgg);
                }
            }
        });
    }

    public void a(SmartBox_HotWordsEgg smartBox_HotWordsEgg, GifDrawable gifDrawable) {
        EventLog.a("搜索", "探照灯", "开始展示探照灯", "", "lypeerluo");
        b(gifDrawable.getIntrinsicWidth());
        a(gifDrawable.getIntrinsicHeight());
        b(smartBox_HotWordsEgg.iPlayUnderWord == 1);
        this.f41025a.a(gifDrawable);
        this.f41025a.setImageDrawable(null);
        gifDrawable.setStayAtLastFrame(true);
        gifDrawable.setLoopCount(1);
        g = true;
        if (FeatureToggle.a(BuildConfig.FEATURE_TOGGLE_SEARCH_LIGHT_GIF_867523231)) {
            this.f41025a.setLayoutParams(c(this.q));
        } else {
            this.f41025a.setLayoutParams(a(gifDrawable));
        }
        this.f41025a.setVisibility(0);
        this.f41025a.b();
        this.n = System.currentTimeMillis();
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("tzd_hotword_expose", "1");
        a(hashMap);
        EventEmiter.getDefault().emit(new EventMessage("SearchConst.event_key_homepage_egg_gif_start_play", Integer.valueOf(smartBox_HotWordsEgg.iId)));
        l();
    }

    private void a(HashMap<String, String> hashMap) {
        if (hashMap == null) {
            return;
        }
        StatManager.b().b("MTT_SEARCH_BOX_LIGHT", hashMap);
    }

    private boolean a(SearchHotwordInfo searchHotwordInfo, boolean z, boolean z2) {
        if (searchHotwordInfo.a() == null || TextUtils.isEmpty(searchHotwordInfo.a().sIcon) || !this.h) {
            return false;
        }
        if ((b(searchHotwordInfo.a()) || d(searchHotwordInfo)) && z2 && this.e) {
            return ((g && z) || this.i) ? false : true;
        }
        return false;
    }

    private void b(boolean z) {
        FrameLayout frameLayout;
        k();
        if (z) {
            this.f41026b.setVisibility(0);
            this.f41026b.addView(this.f41025a);
            frameLayout = this.f41027c;
        } else {
            this.f41027c.setVisibility(0);
            this.f41027c.addView(this.f41025a);
            frameLayout = this.f41026b;
        }
        frameLayout.setVisibility(8);
    }

    private boolean b(SmartBox_HotWordsEgg smartBox_HotWordsEgg) {
        return smartBox_HotWordsEgg.iWordId <= 0;
    }

    private FrameLayout.LayoutParams c(float f) {
        int i;
        int i2;
        EventLog.a("搜索", "探照灯", "getLayoutParams", f + "", "lypeerluo");
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(0, 0);
        if (f > 0.0f && (i = this.p) > 0 && (i2 = this.o) > 0) {
            layoutParams.width = (int) (i2 / (i / f));
            layoutParams.height = (int) f;
            layoutParams.leftMargin = HomePageUIConfig.a();
            layoutParams.topMargin = SearchBarView.n;
        }
        return layoutParams;
    }

    private boolean c(SearchHotwordInfo searchHotwordInfo) {
        return searchHotwordInfo.a() != null && searchHotwordInfo.a().iId == this.f;
    }

    private boolean d(float f) {
        return f > 0.0f && f != this.q && (a() || c());
    }

    private boolean d(SearchHotwordInfo searchHotwordInfo) {
        return (b(searchHotwordInfo.a()) || searchHotwordInfo.c() == null || searchHotwordInfo.c().size() < 1 || searchHotwordInfo.c().get(0) == null || searchHotwordInfo.c().get(0).iId != searchHotwordInfo.a().iWordId) ? false : true;
    }

    private boolean e(SearchHotwordInfo searchHotwordInfo) {
        if (searchHotwordInfo == null || this.k == null || this.n <= 0) {
            return false;
        }
        return searchHotwordInfo.g().equals(this.k.g());
    }

    private void f() {
        this.f41025a.setBackgroundColor(0);
        this.f41025a.setLayoutParams(new FrameLayout.LayoutParams(-2, -1));
    }

    private void g() {
        h();
        i();
        this.l.setVisibility(0);
        this.l.setLoopCount(1);
        this.l.e();
        SearchCustomGifController.a().c();
    }

    private void h() {
        if (this.l == null) {
            this.l = new QBWebImageView(this.m);
            this.l.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
            this.l.setPlaceHolderColorId(e.U);
            this.l.setUrl("https://static.res.qq.com/nav/search/search_inputbox_blue_strip.gif");
        }
    }

    private void i() {
        j();
        this.f41028d.setVisibility(0);
        this.f41028d.addView(this.l);
    }

    private void j() {
        ViewParent parent = this.l.getParent();
        if (parent instanceof ViewGroup) {
            ((ViewGroup) parent).removeView(this.l);
        }
    }

    private void k() {
        ViewParent parent = this.f41025a.getParent();
        if (parent instanceof ViewGroup) {
            ((ViewGroup) parent).removeView(this.f41025a);
        }
    }

    private void l() {
        final IMultiWindowService iMultiWindowService = (IMultiWindowService) QBContext.getInstance().getService(IMultiWindowService.class);
        if (iMultiWindowService != null) {
            iMultiWindowService.addStateListener(new MultiWindowStateListener() {
                @Override
                public void f() {
                    SearchLightGifController.this.b();
                    iMultiWindowService.removeStateListener(this);
                }

                @Override
                public void g() {
                }
            });
        }
    }

    private boolean m() {
        return SkinModeDetector.a() == SkinMode.NORMAL;
    }

    private void n() {
        QBWebImageView qBWebImageView = this.l;
        if (qBWebImageView != null) {
            qBWebImageView.f();
            this.l.j();
            this.l.setVisibility(8);
            this.l = null;
        }
    }

    public void a(float f) {
        EventLog.a("搜索", "探照灯", "updateHeight", f + "", "lypeerluo");
        if (d(f)) {
            this.f41025a.setLayoutParams(c(f));
        }
        b(f);
    }

    public void a(int i) {
        this.p = i;
    }

    public void a(SearchHotwordInfo searchHotwordInfo) {
        EventLog.a("搜索", "探照灯", "收到探照灯更新数据请求", "", "lypeerluo");
        if (!a(searchHotwordInfo, c(searchHotwordInfo), m())) {
            EventLog.a("搜索", "探照灯", "不符合探照灯播放条件,返回", "", "lypeerluo");
            if (this.e && this.h && SearchCustomGifController.a().b()) {
                g();
                return;
            }
            return;
        }
        EventLog.a("搜索", "探照灯", "符合探照灯播放条件,开始尝试播放", "", "lypeerluo");
        this.k = searchHotwordInfo;
        SearchBarGifManager.getInstance().a(this.k);
        if (SearchBarGifManager.getInstance().a(searchHotwordInfo.a())) {
            a(searchHotwordInfo.a());
        } else {
            EventLog.a("搜索", "探照灯", "当前有其他运营在跑着,先hold住", "", "lypeerluo");
            SearchBarGifManager.getInstance().a(this);
        }
    }

    public void a(boolean z) {
        this.i = z;
    }

    public void a(boolean z, boolean z2) {
        this.h = true;
        if ((z || z2) && this.e) {
            g = false;
        }
        this.i = false;
    }

    public boolean a() {
        return this.f41025a.getVisibility() == 0;
    }

    public void b() {
        this.n = 0L;
        this.f41025a.a();
        this.f41025a.c();
        this.f41025a.setVisibility(8);
        k();
        HomePageProxy.getInstance().a(false);
        if (this.k == null) {
            return;
        }
        SearchBarGifManager.getInstance().c(this.k.a());
    }

    public void b(float f) {
        this.q = f;
    }

    public void b(int i) {
        this.o = i;
    }

    public void b(SearchHotwordInfo searchHotwordInfo) {
        if (e(searchHotwordInfo)) {
            long currentTimeMillis = System.currentTimeMillis() - this.n;
            HashMap<String, String> hashMap = new HashMap<>();
            hashMap.put("tzd_hotword_click", "1");
            hashMap.put("tzd_hotword_click_time", String.valueOf(currentTimeMillis));
            a(hashMap);
        }
    }

    public void c(int i) {
        this.j = i;
    }

    public boolean c() {
        GifDrawable gifDrawable = this.f41025a.getGifDrawable();
        if (gifDrawable != null) {
            return gifDrawable.isRunning();
        }
        return false;
    }

    public void d() {
        this.h = false;
        b();
        n();
    }

    public void e() {
        a(this.k);
    }
}