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

import android.content.Context;
import android.graphics.Point;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout.LayoutParams;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.bz.a;
import com.tencent.mm.plugin.mmsight.segment.VideoSegmentUI.b;
import com.tencent.mm.sdk.platformtools.ab;

class VideoSegmentUI$a implements Runnable {
    private Context context;
    private ViewGroup lYe;
    final /* synthetic */ VideoSegmentUI ozN;
    private int ozU;
    private int ozV;
    private int ozW;
    private b ozX;

    private VideoSegmentUI$a(VideoSegmentUI videoSegmentUI, ViewGroup viewGroup, int i, int i2, int i3, b bVar) {
        this.ozN = videoSegmentUI;
        AppMethodBeat.i(55045);
        this.ozU = i;
        this.ozV = i2;
        this.ozW = i3;
        this.context = viewGroup.getContext();
        this.lYe = viewGroup;
        this.ozX = bVar;
        AppMethodBeat.o(55045);
    }

    public final void run() {
        AppMethodBeat.i(55046);
        if (this.ozN.isFinishing()) {
            AppMethodBeat.o(55046);
            return;
        }
        float f;
        1 1 = new 1(this, this.context);
        int width = this.lYe.getWidth();
        int al = a.al(this.context, 2131428735);
        int top = ((View) VideoSegmentUI.j(this.ozN)).getTop() - (al * 2);
        int i = this.ozV;
        int i2 = this.ozU;
        Point point = new Point();
        if (((float) i2) / ((float) i) > ((float) top) / ((float) width)) {
            f = ((float) top) / ((float) i2);
        } else {
            f = ((float) width) / ((float) i);
        }
        point.x = (int) (((float) i) * f);
        point.y = (int) (f * ((float) i2));
        ab.i("MicroMsg.VideoSegmentUI", "rawWidth %d rawHeight %d  rawDegress %d padding %d validWidth %d validHeight %d scaled %s", new Object[]{Integer.valueOf(this.ozV), Integer.valueOf(this.ozU), Integer.valueOf(this.ozW), Integer.valueOf(al), Integer.valueOf(width), Integer.valueOf(top), point.toString()});
        if (point.x <= 0 || point.y <= 0) {
            ab.e("MicroMsg.VideoSegmentUI", "rawWidth %d rawHeight %d padding %d validWidth %d validHeight %d scaled %s", new Object[]{Integer.valueOf(this.ozV), Integer.valueOf(this.ozU), Integer.valueOf(al), Integer.valueOf(width), Integer.valueOf(top), point.toString()});
            if (this.ozX != null) {
                b bVar = this.ozX;
                ab.e("MicroMsg.VideoSegmentUI", "TextureViewCallback error");
                VideoSegmentUI.m(bVar.ozN);
                bVar.ozN.finish();
                VideoSegmentUI.b(bVar.ozN);
            }
            AppMethodBeat.o(55046);
            return;
        }
        LayoutParams layoutParams = new LayoutParams(point.x, point.y);
        al += (int) (((float) (top - point.y)) / 2.0f);
        layoutParams.topMargin = al;
        layoutParams.bottomMargin = al;
        width = (int) (((float) (width - point.x)) / 2.0f);
        layoutParams.leftMargin = width;
        layoutParams.rightMargin = width;
        1.setSurfaceTextureListener(this.ozX);
        this.lYe.addView(1, 0, layoutParams);
        AppMethodBeat.o(55046);
    }
}
