package com.ss.android.ugc.aweme.shortvideo.cut.gif;

import X.70i;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import com.bytedance.covode.number.Covode;

public class Video2GifCutFragment$3 implements ViewTreeObserver.OnGlobalLayoutListener {
    public final /* synthetic */ Video2GifCutFragment LIZ;

    static {
        Covode.recordClassIndex(108524);
    }

    public final void onGlobalLayout() {
        int i;
        if (this.LIZ.LJIIIZ != null) {
            this.LIZ.LIZJ.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            int height = this.LIZ.LIZJ.getHeight();
            int width = this.LIZ.LIZJ.getWidth();
            int[] LIZIZ = 70i.LIZIZ(this.LIZ.LJIIIZ.LIZ);
            if (LIZIZ[0] == 0) {
                int i2 = LIZIZ[2];
                int i3 = LIZIZ[3];
                this.LIZ.LJIIIZ.LJI = i2;
                this.LIZ.LJIIIZ.LJII = i3;
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
                if (i2 < i3) {
                    layoutParams.width = (i2 * height) / i3;
                    layoutParams.height = height;
                    layoutParams.leftMargin = (width - layoutParams.width) / 2;
                    layoutParams.topMargin = 0;
                } else {
                    layoutParams.width = width;
                    layoutParams.height = (i3 * width) / i2;
                    layoutParams.topMargin = (height - layoutParams.height) / 2;
                    if (layoutParams.topMargin >= 0) {
                        i = layoutParams.topMargin;
                    } else {
                        i = 0;
                    }
                    layoutParams.topMargin = i;
                    layoutParams.leftMargin = 0;
                }
                layoutParams.setMarginStart(layoutParams.leftMargin);
                this.LIZ.LJIIIZ.LJIIIIZZ = layoutParams.width;
                this.LIZ.LJIIIZ.LJIIIZ = layoutParams.height;
                this.LIZ.LIZJ.setLayoutParams(layoutParams);
            }
        }
    }

    public Video2GifCutFragment$3(Video2GifCutFragment video2GifCutFragment) {
        this.LIZ = video2GifCutFragment;
    }
}
