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

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


package com.tencent.mtt.docscan.imgproc;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.view.MotionEvent;
import com.tencent.common.fresco.cache.FImage;
import com.tencent.common.fresco.pipeline.ImageHub;
import com.tencent.mm.ui.widget.dialog.MMTipsBar;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.docscan.NewSdkSwitch;
import com.tencent.mtt.view.common.QBView;
import qb.a.e;

public class DocScanScanningView extends QBView implements ValueAnimator.AnimatorUpdateListener {
    private static final int i = MttResources.s(22);
    private static final int j = MttResources.s(4);
    private static int k = Color.rgb(79, 165, 249);

    private Drawable f49610a;

    private final ValueAnimator f49611b;

    private final Paint f49612c;

    private final Path f49613d;
    private boolean e;
    private boolean f;
    private int g;
    private IScanningAnimUpdateListener h;

    public interface IScanningAnimUpdateListener {
        void a(int i, boolean z, int i2);

        boolean a(int i);
    }

    public DocScanScanningView(Context context) {
        super(context);
        this.f49612c = new Paint(1);
        this.f49613d = new Path();
        this.f = true;
        this.g = 0;
        ImageHub.a().a("https://m4.publicimg.browser.qq.com/publicimg/nav/file/doc_scan_anim.png");
        this.f49611b = new ValueAnimator();
        this.f49612c.setColor(k);
        this.f49612c.setStrokeWidth(j);
        this.f49612c.setStyle(Paint.Style.STROKE);
        if (NewSdkSwitch.a()) {
            k = Color.argb(0, 0, 0, 0);
        }
    }

    static int a(DocScanScanningView docScanScanningView) {
        int i2 = docScanScanningView.g + 1;
        docScanScanningView.g = i2;
        return i2;
    }

    private void c() {
        if (this.f49610a != null) {
            return;
        }
        SystemClock.elapsedRealtime();
        FImage d2 = ImageHub.a().d("https://m4.publicimg.browser.qq.com/publicimg/nav/file/doc_scan_anim.png");
        Bitmap b2 = d2 != null ? d2.b() : null;
        if (b2 != null) {
            this.e = true;
            this.f49610a = new BitmapDrawable(b2);
        } else {
            this.e = false;
            this.f49610a = new ColorDrawable(MttResources.c(e.f));
        }
    }

    public void a() {
        if (this.f49611b.isRunning()) {
            return;
        }
        c();
        this.g = 0;
        this.f = true;
        this.f49611b.setRepeatCount(-1);
        this.f49611b.setRepeatMode(2);
        this.f49611b.setFloatValues(0.0f, 1.0f);
        this.f49611b.setDuration(MMTipsBar.DURATION_SHORT);
        this.f49611b.start();
        this.f49611b.removeAllListeners();
        this.f49611b.removeAllUpdateListeners();
        this.f49611b.addUpdateListener(this);
        this.f49611b.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animator) {
                onAnimationEnd(animator);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                DocScanScanningView.this.f49611b.removeAllListeners();
                DocScanScanningView.this.f49611b.removeAllUpdateListeners();
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
                DocScanScanningView.this.f = false;
                int a2 = DocScanScanningView.a(DocScanScanningView.this);
                if (DocScanScanningView.this.h == null || !DocScanScanningView.this.h.a(a2)) {
                    return;
                }
                animator.cancel();
            }
        });
    }

    public void b() {
        this.f49611b.cancel();
        this.f49611b.removeAllListeners();
    }

    @Override
    public void onAnimationUpdate(ValueAnimator valueAnimator) {
        if (valueAnimator.isRunning() && getWidth() > 0.0f) {
            int s = MttResources.s(this.e ? 160 : 3);
            int height = getHeight();
            int paddingTop = getPaddingTop();
            int paddingBottom = getPaddingBottom();
            int i2 = (height - paddingTop) - paddingBottom;
            int round = Math.round((height + s) * ((Float) valueAnimator.getAnimatedValue()).floatValue()) - s;
            boolean z = this.f;
            int i3 = z ? round + s : round;
            if (i3 < paddingTop) {
                i2 = 0;
            } else if (i3 < height - paddingBottom) {
                i2 = i3 - paddingTop;
            }
            this.f49610a.setBounds(0, round, getWidth(), s + round);
            IScanningAnimUpdateListener iScanningAnimUpdateListener = this.h;
            int i4 = this.g;
            if (iScanningAnimUpdateListener != null) {
                iScanningAnimUpdateListener.a(i2, z, i4);
            }
            invalidate();
        }
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.f49611b.isRunning()) {
            int paddingLeft = getPaddingLeft();
            int paddingTop = getPaddingTop();
            int paddingRight = getPaddingRight();
            int paddingBottom = getPaddingBottom();
            int width = (getWidth() - paddingRight) - paddingLeft;
            int height = (getHeight() - paddingBottom) - paddingTop;
            int save = canvas.save();
            int i2 = j / 2;
            canvas.translate(paddingLeft, paddingTop);
            this.f49613d.reset();
            this.f49613d.moveTo(0.0f, i);
            this.f49613d.lineTo(0.0f, 0.0f);
            this.f49613d.lineTo(i, 0.0f);
            float f = -i2;
            this.f49613d.offset(f, f);
            canvas.drawPath(this.f49613d, this.f49612c);
            this.f49613d.reset();
            this.f49613d.moveTo(width - i, 0.0f);
            float f2 = width;
            this.f49613d.lineTo(f2, 0.0f);
            this.f49613d.lineTo(f2, i);
            float f3 = i2;
            this.f49613d.offset(f3, f);
            canvas.drawPath(this.f49613d, this.f49612c);
            this.f49613d.reset();
            this.f49613d.moveTo(f2, height - i);
            float f4 = height;
            this.f49613d.lineTo(f2, f4);
            this.f49613d.lineTo(width - i, f4);
            this.f49613d.offset(f3, f3);
            canvas.drawPath(this.f49613d, this.f49612c);
            this.f49613d.reset();
            this.f49613d.moveTo(i, f4);
            this.f49613d.lineTo(0.0f, f4);
            this.f49613d.lineTo(0.0f, height - i);
            this.f49613d.offset(f, f3);
            canvas.drawPath(this.f49613d, this.f49612c);
            canvas.restoreToCount(save);
            int save2 = canvas.save();
            Rect bounds = this.f49610a.getBounds();
            if (!this.f) {
                canvas.rotate(180.0f, bounds.centerX(), bounds.centerY());
            }
            this.f49610a.draw(canvas);
            canvas.restoreToCount(save2);
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent motionEvent) {
        return false;
    }

    public void setAnimUpdateListener(IScanningAnimUpdateListener iScanningAnimUpdateListener) {
        this.h = iScanningAnimUpdateListener;
    }
}