package com.tencent.mm.plugin.mmsight.segment;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.widget.Toast;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.mmsight.d;
import com.tencent.mm.pointers.PInt;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;

class VideoSegmentUI$7 implements Runnable {
    final /* synthetic */ VideoSegmentUI ozN;

    VideoSegmentUI$7(VideoSegmentUI videoSegmentUI) {
        this.ozN = videoSegmentUI;
    }

    public final void run() {
        boolean z = true;
        AppMethodBeat.i(55038);
        String str = null;
        try {
            VideoSegmentUI.d(this.ozN).stop();
            int e = VideoSegmentUI.e(this.ozN);
            long yz = bo.yz();
            VideoSegmentUI.i(this.ozN).b(VideoSegmentUI.f(this.ozN), VideoSegmentUI.g(this.ozN), VideoSegmentUI.h(this.ozN));
            if (VideoSegmentUI.i(this.ozN).O((long) (VideoSegmentUI.j(this.ozN).bQa() * ((float) e)), (long) (((float) e) * VideoSegmentUI.j(this.ozN).bQb())) < 0) {
                ab.i("MicroMsg.VideoSegmentUI", "clip failed! %s", new Object[]{Integer.valueOf(VideoSegmentUI.i(this.ozN).O((long) (VideoSegmentUI.j(this.ozN).bQa() * ((float) e)), (long) (((float) e) * VideoSegmentUI.j(this.ozN).bQb())))});
                al.d(new Runnable() {
                    public final void run() {
                        AppMethodBeat.i(55036);
                        if (VideoSegmentUI.k(VideoSegmentUI$7.this.ozN) != null) {
                            VideoSegmentUI.k(VideoSegmentUI$7.this.ozN).dismiss();
                        }
                        if (VideoSegmentUI.j(VideoSegmentUI$7.this.ozN) != null) {
                            VideoSegmentUI.j(VideoSegmentUI$7.this.ozN).iX(false);
                        }
                        Toast.makeText(VideoSegmentUI$7.this.ozN, 2131301447, 1).show();
                        AppMethodBeat.o(55036);
                    }
                });
                AppMethodBeat.o(55038);
                return;
            }
            Bitmap tv = d.tv(VideoSegmentUI.g(this.ozN));
            if (tv != null) {
                PInt pInt = new PInt();
                PInt pInt2 = new PInt();
                if (d.a(tv.getWidth(), tv.getHeight(), VideoSegmentUI.h(this.ozN).fAf, pInt, pInt2)) {
                    tv = Bitmap.createScaledBitmap(tv, pInt.value, pInt2.value, true);
                }
                ab.i("MicroMsg.VideoSegmentUI", "getBitmap size = [%d, %d]", new Object[]{Integer.valueOf(tv.getWidth()), Integer.valueOf(tv.getHeight())});
                com.tencent.mm.sdk.platformtools.d.a(tv, 80, CompressFormat.JPEG, VideoSegmentUI.l(this.ozN), true);
                ab.i("MicroMsg.VideoSegmentUI", "create video thumb. use %dms", new Object[]{Long.valueOf(bo.az(yz))});
            } else {
                ab.e("MicroMsg.VideoSegmentUI", "getVideoThumb failed!");
            }
            al.d(new Runnable() {
                public final void run() {
                    AppMethodBeat.i(55037);
                    if (VideoSegmentUI.k(VideoSegmentUI$7.this.ozN) != null) {
                        VideoSegmentUI.k(VideoSegmentUI$7.this.ozN).dismiss();
                    }
                    if (VideoSegmentUI.j(VideoSegmentUI$7.this.ozN) != null) {
                        VideoSegmentUI.j(VideoSegmentUI$7.this.ozN).iX(false);
                    }
                    VideoSegmentUI.a(VideoSegmentUI$7.this.ozN, z, str);
                    AppMethodBeat.o(55037);
                }
            });
            AppMethodBeat.o(55038);
        } catch (Exception e2) {
            Exception exception = e2;
            str = exception.getMessage();
            ab.printErrStackTrace("MicroMsg.VideoSegmentUI", exception, "UnexpectedException when clip : [%s]", new Object[]{exception.getMessage()});
            z = false;
        }
    }
}
