package ඓ.㸾.K;

import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.widget.FrameLayout;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import com.gyf.immersionbar.BarHide;

/* renamed from: ඓ.㸾.K.㴹  reason: contains not printable characters */
/* compiled from: FitsKeyboard */
public class ViewTreeObserver$OnGlobalLayoutListenerC1385 implements ViewTreeObserver.OnGlobalLayoutListener {

    /* renamed from: ʬ  reason: contains not printable characters */
    public Window f5293;

    /* renamed from: ඓ  reason: contains not printable characters */
    public View f5294;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public int f5295;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public int f5296 = 0;

    /* renamed from: ῲ  reason: contains not printable characters */
    public C1387 f5297;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public int f5298 = 0;

    /* renamed from: 㑃  reason: contains not printable characters */
    public boolean f5299;

    /* renamed from: 㳳  reason: contains not printable characters */
    public int f5300 = 0;

    /* renamed from: 㴹  reason: contains not printable characters */
    public View f5301;

    /* renamed from: 㸾  reason: contains not printable characters */
    public View f5302;

    /* renamed from: 㿎  reason: contains not printable characters */
    public int f5303 = 0;

    public ViewTreeObserver$OnGlobalLayoutListenerC1385(C1387 r4) {
        this.f5297 = r4;
        this.f5293 = r4.f5325;
        this.f5302 = this.f5293.getDecorView();
        FrameLayout frameLayout = (FrameLayout) this.f5302.findViewById(16908290);
        if (r4.f5315) {
            Fragment fragment = r4.f5306;
            if (fragment != null) {
                this.f5301 = fragment.getView();
            } else {
                android.app.Fragment fragment2 = r4.f5327;
                if (fragment2 != null) {
                    this.f5301 = fragment2.getView();
                }
            }
        } else {
            this.f5301 = frameLayout.getChildAt(0);
            View view = this.f5301;
            if (view != null && (view instanceof DrawerLayout)) {
                this.f5301 = ((DrawerLayout) view).getChildAt(0);
            }
        }
        View view2 = this.f5301;
        if (view2 != null) {
            this.f5298 = view2.getPaddingLeft();
            this.f5303 = this.f5301.getPaddingTop();
            this.f5296 = this.f5301.getPaddingRight();
            this.f5300 = this.f5301.getPaddingBottom();
        }
        View view3 = this.f5301;
        this.f5294 = view3 == null ? frameLayout : view3;
    }

    public void onGlobalLayout() {
        C1378 r1;
        int i;
        int i2;
        C1387 r0 = this.f5297;
        if (r0 != null && (r1 = r0.f5330) != null && r1.f5256) {
            if (r0.f5307 == null) {
                r0.f5307 = new C1380(r0.f5317);
            }
            C1380 k = r0.f5307;
            if (k.m3572()) {
                i = k.f5287;
            } else {
                i = k.f5282;
            }
            Rect rect = new Rect();
            this.f5302.getWindowVisibleDisplayFrame(rect);
            int height = this.f5294.getHeight() - rect.bottom;
            if (height != this.f5295) {
                this.f5295 = height;
                boolean z = true;
                if (C1387.m3585(this.f5293.getDecorView().findViewById(16908290))) {
                    height -= i;
                    if (height <= i) {
                        z = false;
                    }
                } else if (this.f5301 != null) {
                    C1387 r2 = this.f5297;
                    if (r2.f5330.f5276) {
                        height += r2.f5314 + k.f5285;
                    }
                    if (this.f5297.f5330.f5253) {
                        height += k.f5285;
                    }
                    if (height > i) {
                        i2 = this.f5300 + height;
                    } else {
                        i2 = 0;
                        z = false;
                    }
                    this.f5294.setPadding(this.f5298, this.f5303, this.f5296, i2);
                } else {
                    int i3 = this.f5297.f5319;
                    height -= i;
                    if (height > i) {
                        i3 = height + i;
                    } else {
                        z = false;
                    }
                    View view = this.f5294;
                    C1387 r22 = this.f5297;
                    view.setPadding(r22.f5313, r22.f5324, r22.f5312, i3);
                }
                if (height < 0) {
                    height = 0;
                }
                AbstractC1388 r02 = this.f5297.f5330.f5267;
                if (r02 != null) {
                    r02.m3598(z, height);
                }
                if (!z) {
                    C1387 r03 = this.f5297;
                    if (r03.f5330.f5255 != BarHide.FLAG_SHOW_BAR) {
                        r03.m3596();
                    }
                }
            }
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m3580() {
        int i = Build.VERSION.SDK_INT;
        if (!this.f5299) {
            return;
        }
        if (this.f5301 != null) {
            this.f5294.setPadding(this.f5298, this.f5303, this.f5296, this.f5300);
            return;
        }
        View view = this.f5294;
        C1387 r1 = this.f5297;
        view.setPadding(r1.f5313, r1.f5324, r1.f5312, r1.f5319);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m3582(int i) {
        int i2 = Build.VERSION.SDK_INT;
        this.f5293.setSoftInputMode(i);
        if (!this.f5299) {
            this.f5302.getViewTreeObserver().addOnGlobalLayoutListener(this);
            this.f5299 = true;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m3581() {
        int i = Build.VERSION.SDK_INT;
        if (this.f5299) {
            this.f5302.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            this.f5299 = false;
        }
    }
}
