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

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


package com.tencent.mtt.browser.video.external.extend;

import android.app.Dialog;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;
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.threadpool.BrowserExecutorSupplier;
import com.tencent.mtt.R;
import com.tencent.mtt.base.functionwindow.IFunctionWndFactory;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.stat.StatManager;
import com.tencent.mtt.browser.download.core.impl.DownloadServiceManager;
import com.tencent.mtt.browser.download.engine.DownloadErrorDetail;
import com.tencent.mtt.browser.download.engine.DownloadTask;
import com.tencent.mtt.browser.download.engine.DownloadTaskListener;
import com.tencent.mtt.browser.download.engine.PauseReason;
import com.tencent.mtt.browser.download.engine.RemovePolicy;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.hippy.qb.modules.appdownload.HippyAppConstants;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.video.browser.export.constant.StatVideoConsts;
import com.tencent.mtt.video.browser.export.db.IVideoDbHelper;
import com.tencent.mtt.video.export.IH5VideoPlayer;
import com.tencent.mtt.video.export.VideoEngine;
import com.tencent.mtt.video.export.VideoHost;
import com.tencent.mtt.video.internal.engine.VideoManager;
import com.tencent.mtt.video.internal.engine.VideoSettingManager;
import com.tencent.mtt.view.common.QBTextView;
import com.tencent.mtt.view.dialog.newui.SimpleDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.IDownloadFileDialogBuilder;
import com.tencent.mtt.view.dialog.newui.builder.api.IDownloadWithProgressDialogBuilder;
import com.tencent.mtt.view.dialog.newui.dialog.DialogBase;
import com.tencent.mtt.view.dialog.newui.view.TitleImageOnClickListener;
import com.tencent.mtt.view.dialog.newui.view.ViewOnClickListener;
import com.tencent.mtt.view.dialog.newui.view.component.ProgressBarWithText;
import com.tencent.mtt.view.dialog.newui.view.getter.IProgressViewGetter;
import com.tencent.mtt.view.dialog.newui.view.getter.IViewGetter;
import com.tencent.qqlive.module.videoreport.collect.EventCollector;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class H5VideoDownloadMenuDialogNewStyle {

    private QBTextView f45586a;

    private ProgressBarWithText f45587b;

    private Map<String, String> f45589d;
    private View.OnClickListener e;
    private Bundle h;
    private DialogBase i;

    private boolean f45588c = false;
    private boolean f = false;
    private boolean g = false;
    private int j = 0;

    public static class VideoDownloadTaskListener implements DownloadTaskListener {

        private final int f45615a;

        private final WeakReference<H5VideoDownloadMenuDialogNewStyle> f45616b;

        private final boolean[] f45617c;

        private VideoDownloadTaskListener(int i, H5VideoDownloadMenuDialogNewStyle h5VideoDownloadMenuDialogNewStyle, boolean[] zArr) {
            this.f45615a = i;
            this.f45616b = new WeakReference<>(h5VideoDownloadMenuDialogNewStyle);
            this.f45617c = zArr;
        }

        @Override
        public void onTaskCompleted(DownloadTask downloadTask) {
            H5VideoDownloadMenuDialogNewStyle h5VideoDownloadMenuDialogNewStyle;
            if (downloadTask == null || downloadTask.i() != this.f45615a || (h5VideoDownloadMenuDialogNewStyle = this.f45616b.get()) == null) {
                return;
            }
            h5VideoDownloadMenuDialogNewStyle.b(downloadTask.j());
        }

        @Override
        public void onTaskCreated(DownloadTask downloadTask) {
        }

        @Override
        public void onTaskFailed(DownloadTask downloadTask, DownloadErrorDetail downloadErrorDetail) {
        }

        @Override
        public void onTaskPaused(DownloadTask downloadTask, PauseReason pauseReason) {
            if (this.f45616b.get() == null) {
                return;
            }
            this.f45617c[0] = true;
        }

        @Override
        public void onTaskProgress(DownloadTask downloadTask) {
            if (downloadTask == null || downloadTask.i() != this.f45615a) {
                return;
            }
            final int V = downloadTask.V();
            BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
                @Override
                public void run() {
                    H5VideoDownloadMenuDialogNewStyle h5VideoDownloadMenuDialogNewStyle = (H5VideoDownloadMenuDialogNewStyle) VideoDownloadTaskListener.this.f45616b.get();
                    if (h5VideoDownloadMenuDialogNewStyle == null) {
                        return;
                    }
                    h5VideoDownloadMenuDialogNewStyle.j = V;
                    h5VideoDownloadMenuDialogNewStyle.f45587b.a(V / 100.0f, String.format(MttResources.l(R.string.bvn), Integer.valueOf(V)));
                }
            });
        }

        @Override
        public void onTaskRemoved(DownloadTask downloadTask) {
        }

        @Override
        public void onTaskStarted(DownloadTask downloadTask) {
        }

        @Override
        public void onTaskWaiting(DownloadTask downloadTask) {
        }
    }

    public H5VideoDownloadMenuDialogNewStyle(Bundle bundle, Map<String, String> map) {
        this.h = bundle;
        this.f45589d = map == null ? new HashMap() : new HashMap(map);
        StatVideoConsts.addExtraToParams(this.f45589d, Collections.singletonMap(StatVideoConsts.KEY_DIALOG_STYLE, "new"));
        a(bundle);
    }

    private void a(Bundle bundle) {
        String string = bundle.getString("video_url");
        this.f45588c = bundle.getBoolean("isFullScreen");
        DownloadTask downloadTaskByUrl = DownloadServiceManager.a().getDownloadTaskByUrl(string);
        boolean[] zArr = new boolean[1];
        zArr[0] = downloadTaskByUrl != null && downloadTaskByUrl.ac() == PauseReason.MANUAL;
        boolean a2 = a(downloadTaskByUrl);
        if (!a2 && downloadTaskByUrl != null) {
            DownloadServiceManager.a().removeDownloadTask(downloadTaskByUrl.i(), RemovePolicy.DELETE_TASK_AND_FILE);
        }
        if (a2) {
            this.j = downloadTaskByUrl.V();
            IDownloadWithProgressDialogBuilder a3 = SimpleDialogBuilder.h().b(true).a("https://static.res.qq.com/nav/video/video_download_dialog_image.png").e(MttResources.l(R.string.bvk)).a((CharSequence) MttResources.l(R.string.bvk));
            IProgressViewGetter a4 = a3.a();
            IViewGetter b2 = a3.b();
            this.i = a3.d();
            this.f45586a = b2.c();
            this.f45587b = a4.a();
            if (downloadTaskByUrl.aB()) {
                b(string);
            } else {
                a(string);
                a(string, downloadTaskByUrl, zArr);
            }
            DownloadServiceManager.a().addTaskListener(new VideoDownloadTaskListener(downloadTaskByUrl.i(), this, zArr));
            return;
        }
        this.f = true;
        IViewGetter b3 = b(bundle);
        VideoHost videohost = VideoEngine.getInstance().getVideohost();
        if (videohost != null) {
            videohost.userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION97, this.f45589d);
        }
        if (b3 != null) {
            this.f45586a = b3.b();
            QBTextView qBTextView = this.f45586a;
            if (qBTextView != null) {
                qBTextView.setSingleLine(true);
                this.f45586a.setMaxLines(1);
                this.f45586a.setEllipsize(TextUtils.TruncateAt.END);
            }
        }
    }

    public void a(final Runnable runnable) {
        Logs.c("H5VideoDownloadMenuDialogNewStyle", "[ID857230465] showEncryptDownloadConfirmDialog ");
        if (!VideoSettingManager.a().r()) {
            runnable.run();
            return;
        }
        final VideoHost videoHost = VideoManager.getInstance().getVideoHost();
        SimpleDialogBuilder.e().b(true).d(MttResources.l(R.string.buy)).e(MttResources.l(R.string.bux)).a(MttResources.l(R.string.buw)).a_(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                dialogBase.dismiss();
                H5VideoDownloadMenuDialogNewStyle.this.c();
                VideoHost videoHost2 = videoHost;
                if (videoHost2 != null) {
                    videoHost2.userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION76, H5VideoDownloadMenuDialogNewStyle.this.f45589d);
                }
                Logs.c("H5VideoDownloadMenuDialogNewStyle", "[ID857230465] onClick confirm dialog BTN_ID_POSITIVE");
                runnable.run();
            }
        }).c(MttResources.l(R.string.bur)).c(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                dialogBase.dismiss();
                VideoHost videoHost2 = videoHost;
                if (videoHost2 != null) {
                    videoHost2.userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION77, H5VideoDownloadMenuDialogNewStyle.this.f45589d);
                }
                Logs.c("H5VideoDownloadMenuDialogNewStyle", "[ID857230465] onClick confirm dialog BTN_ID_NEGATIVE");
            }
        }).e();
        if (videoHost != null) {
            videoHost.userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION75, this.f45589d);
        }
    }

    private void a(final String str) {
        if (this.f45586a == null) {
            return;
        }
        SpannableString spannableString = new SpannableString(MttResources.l(R.string.bvm));
        spannableString.setSpan(new ForegroundColorSpan(MttResources.c(R.color.a62)), 6, 10, 33);
        this.f45586a.setText(spannableString);
        this.f45586a.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StatManager b2;
                String str2;
                EventCollector.getInstance().onViewClickedBefore(view);
                DownloadingJumpHelper.a("toast", str);
                if (H5VideoDownloadMenuDialogNewStyle.this.f45588c) {
                    b2 = StatManager.b();
                    str2 = "CQIB103_1";
                } else {
                    b2 = StatManager.b();
                    str2 = "CQIB103_2";
                }
                b2.c(str2);
                if (VideoEngine.getInstance().getVideohost() != null) {
                    VideoEngine.getInstance().getVideohost().userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION32, H5VideoDownloadMenuDialogNewStyle.this.f45589d);
                }
                EventCollector.getInstance().onViewClicked(view);
            }
        });
    }

    private void a(final String str, final DownloadTask downloadTask, final boolean[] zArr) {
        int V = downloadTask.V();
        this.f45587b.a(V / 100.0f, downloadTask.F() ? MttResources.l(R.string.byb) : String.format(MttResources.l(R.string.bvn), Integer.valueOf(V)));
        this.f45587b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ProgressBarWithText progressBarWithText;
                float f;
                String format;
                StatManager b2;
                String str2;
                EventCollector.getInstance().onViewClickedBefore(view);
                if (downloadTask.aB()) {
                    DownloadingJumpHelper.a("toast", str);
                    if (H5VideoDownloadMenuDialogNewStyle.this.f45588c) {
                        b2 = StatManager.b();
                        str2 = "CQIB104_1";
                    } else {
                        b2 = StatManager.b();
                        str2 = "CQIB104_2";
                    }
                    b2.c(str2);
                } else {
                    boolean[] zArr2 = zArr;
                    if (zArr2[0]) {
                        zArr2[0] = false;
                        DownloadServiceManager.a().resumeDownloadTask(downloadTask.i());
                        int min = Math.min(Math.max(H5VideoDownloadMenuDialogNewStyle.this.j, 0), 100);
                        progressBarWithText = H5VideoDownloadMenuDialogNewStyle.this.f45587b;
                        f = min / 100.0f;
                        format = String.format(MttResources.l(R.string.bvn), Integer.valueOf(min));
                    } else {
                        zArr2[0] = true;
                        DownloadServiceManager.a().pauseDownloadTask(downloadTask.i(), PauseReason.MANUAL);
                        int min2 = Math.min(Math.max(H5VideoDownloadMenuDialogNewStyle.this.j, 0), 100);
                        progressBarWithText = H5VideoDownloadMenuDialogNewStyle.this.f45587b;
                        f = min2 / 100.0f;
                        format = String.format(MttResources.l(R.string.byb), Integer.valueOf(min2));
                    }
                    progressBarWithText.a(f, format);
                }
                EventCollector.getInstance().onViewClicked(view);
            }
        });
    }

    public void a(long[] jArr, Bundle bundle) {
        if (System.currentTimeMillis() - jArr[0] < 500) {
            return;
        }
        jArr[0] = System.currentTimeMillis();
        Logs.c(IH5VideoPlayer.TAG, "H5VideoDownloadMenuDialogNewStyle,[854882707] onClick action=rename");
        Logs.c("H5VideoDownloadMenuDialogNewStyle", "[ID857230465] onClick action=rename");
        Bundle bundle2 = new Bundle();
        bundle2.putString(HippyAppConstants.KEY_FILE_NAME, bundle.getString(IVideoDbHelper.COLUMN_TITLE));
        bundle2.putString("fileParentPath", "/");
        UrlParams d2 = new UrlParams(IFunctionWndFactory.WND_FILE_RENAME).d(2).a(bundle2).a(33).d(true);
        EventEmiter.getDefault().register("FILERENAME_KEY_NEW_FILE_NAME_EVENT", this);
        ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(d2);
        if (VideoEngine.getInstance().getVideohost() != null) {
            VideoEngine.getInstance().getVideohost().userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION36, this.f45589d);
        }
    }

    private boolean a(DownloadTask downloadTask) {
        int U;
        return (downloadTask == null || (U = downloadTask.U()) == 7 || U == 8 || U == 9 || U == 5) ? false : true;
    }

    private IViewGetter b(final Bundle bundle) {
        final long[] jArr = {0};
        IDownloadFileDialogBuilder c2 = SimpleDialogBuilder.d().b(true).d(bundle.getString(IVideoDbHelper.COLUMN_TITLE)).d(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                H5VideoDownloadMenuDialogNewStyle.this.a(jArr, bundle);
            }
        }).a(new TitleImageOnClickListener() {
            @Override
            public void a(QBTextView qBTextView, DialogBase dialogBase) {
                H5VideoDownloadMenuDialogNewStyle.this.a(jArr, bundle);
            }
        }).e(H5VideoDownloadMenuDialog.a(bundle.getLong("video_file_size"))).a(MttResources.l(R.string.bvp)).a_(new ViewOnClickListener() {
            @Override
            public void onClick(final View view, DialogBase dialogBase) {
                VideoHost videoHost = VideoManager.getInstance().getVideoHost();
                if (videoHost != null) {
                    videoHost.userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION6, H5VideoDownloadMenuDialogNewStyle.this.f45589d);
                }
                H5VideoDownloadMenuDialogNewStyle.this.g = true;
                H5VideoDownloadMenuDialogNewStyle.this.a(new Runnable() {
                    @Override
                    public void run() {
                        H5VideoDownloadMenuDialogNewStyle.this.g = true;
                        if (H5VideoDownloadMenuDialogNewStyle.this.e != null) {
                            H5VideoDownloadMenuDialogNewStyle.this.e.onClick(view);
                        }
                    }
                });
            }
        }).b(MttResources.l(R.string.bxe)).b(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                dialogBase.dismiss();
                H5VideoDownloadMenuDialogNewStyle.this.g = true;
                if (H5VideoDownloadMenuDialogNewStyle.this.e != null) {
                    H5VideoDownloadMenuDialogNewStyle.this.e.onClick(view);
                }
            }
        }).c("取消").c(new ViewOnClickListener() {
            @Override
            public void onClick(View view, DialogBase dialogBase) {
                dialogBase.dismiss();
            }
        });
        IViewGetter b2 = c2.b();
        this.i = c2.d();
        return b2;
    }

    public void b(final String str) {
        BrowserExecutorSupplier.forMainThreadTasks().execute(new Runnable() {
            @Override
            public void run() {
                H5VideoDownloadMenuDialogNewStyle.this.f45586a.setText(MttResources.l(R.string.bvk));
                H5VideoDownloadMenuDialogNewStyle.this.f45586a.setOnClickListener(null);
                H5VideoDownloadMenuDialogNewStyle.this.f45587b.a(1.0f, MttResources.l(R.string.bya));
                H5VideoDownloadMenuDialogNewStyle.this.f45587b.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        StatManager b2;
                        String str2;
                        EventCollector.getInstance().onViewClickedBefore(view);
                        H5VideoDownloadMenuDialogNewStyle.this.c();
                        DownloadingJumpHelper.a("video_Popup", str);
                        if (H5VideoDownloadMenuDialogNewStyle.this.f45588c) {
                            b2 = StatManager.b();
                            str2 = "CQIB104_1";
                        } else {
                            b2 = StatManager.b();
                            str2 = "CQIB104_2";
                        }
                        b2.c(str2);
                        EventCollector.getInstance().onViewClicked(view);
                    }
                });
            }
        });
    }

    public Dialog a() {
        return this.i;
    }

    public void a(View.OnClickListener onClickListener) {
        this.e = onClickListener;
    }

    public String b() {
        QBTextView qBTextView = this.f45586a;
        return qBTextView != null ? qBTextView.getText().toString() : "";
    }

    public void c() {
        DialogBase dialogBase = this.i;
        if (dialogBase == null || !dialogBase.isShowing()) {
            this.i = null;
            return;
        }
        this.i.dismiss();
        this.i = null;
        EventEmiter.getDefault().unregister("FILERENAME_KEY_NEW_FILE_NAME_EVENT", this);
        VideoHost videohost = VideoEngine.getInstance().getVideohost();
        if (videohost == null || !this.f || this.g) {
            return;
        }
        videohost.userBehaviorWithParams(StatVideoConsts.VALUE_EVENT_VIDEO_ACTION105, this.f45589d);
    }

    public boolean d() {
        DialogBase dialogBase = this.i;
        return dialogBase != null && dialogBase.isShowing();
    }

    @EventReceiver(createMethod = CreateMethod.NONE, eventName = "FILERENAME_KEY_NEW_FILE_NAME_EVENT")
    public void doOnRenameCalled(EventMessage eventMessage) {
        String string = ((Bundle) eventMessage.arg).getString("newFileName");
        if (TextUtils.isEmpty(string)) {
            return;
        }
        QBTextView qBTextView = this.f45586a;
        if (qBTextView != null) {
            qBTextView.setText(string);
        }
        Bundle bundle = this.h;
        if (bundle != null) {
            bundle.putString(IVideoDbHelper.COLUMN_TITLE, string);
        }
    }

    public void e() {
        if (this.i == null) {
            return;
        }
        Logs.c("H5VideoDownloadMenuDialogNewStyle", "[ID857230465] show ");
        this.i.show();
    }
}