AdGuard v3.6.45版本的 MD5 值为:ce30a13dcef92cf942973fffcc6d20fb

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


package com.adguard.kit.ui.behavior;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import ch.qos.logback.core.CoreConstants;
import com.adguard.kit.ui.R;
import com.adguard.kit.ui.b.a;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import kotlin.b.b.j;
import kotlin.b.b.k;
import kotlin.o;
import kotlin.r;
public final class SuperBottomSheetBehavior<V extends View, P extends View, C extends View> extends BottomSheetBehavior<V> {
    public static final a f = new a((byte) 0);
    private static final kotlin.e r = kotlin.f.a(b.f780a);
    kotlin.b.a.b<? super View, r> f778a;
    kotlin.b.a.b<? super P, r> b;
    kotlin.b.a.b<? super C, r> c;
    kotlin.b.a.b<? super P, r> d;
    kotlin.b.a.b<? super C, r> e;
    private int g;
    private int h;
    private int i;
    private boolean j;
    private Integer k;
    private float l;
    private View m;
    private boolean n;
    private P o;
    private C p;
    private final AttributeSet q;

    public static final class a {
        private a() {
        }

        public a(byte b) {
            this();
        }

        static org.slf4j.c a() {
            kotlin.e eVar = SuperBottomSheetBehavior.r;
            a aVar = SuperBottomSheetBehavior.f;
            return (org.slf4j.c) eVar.getValue();
        }
    }

    static final class b extends k implements kotlin.b.a.a<org.slf4j.c> {
        public static final b f780a = new b();

        b() {
            super(0);
        }

        @Override
        public final org.slf4j.c invoke() {
            return org.slf4j.d.a(SuperBottomSheetBehavior.class);
        }
    }

    public static final class c extends k implements kotlin.b.a.b<View, r> {
        final kotlin.b.a.b f781a;
        final kotlin.b.a.b b;

        c(kotlin.b.a.b bVar, kotlin.b.a.b bVar2) {
            super(1);
            this.f781a = bVar;
            this.b = bVar2;
        }

        @Override
        public final r invoke(View view) {
            View view2 = view;
            j.b(view2, "it");
            this.f781a.invoke(this.b.invoke(view2));
            return r.f1214a;
        }
    }

    static final class d extends k implements kotlin.b.a.b<Integer, r> {
        final CoordinatorLayout b;

        d(CoordinatorLayout coordinatorLayout) {
            super(1);
            this.b = coordinatorLayout;
        }

        @Override
        public final r invoke(Integer num) {
            SuperBottomSheetBehavior.a(SuperBottomSheetBehavior.this, num.intValue(), this.b.getHeight());
            return r.f1214a;
        }
    }

    static final class e extends k implements kotlin.b.a.b<View, Integer> {
        final View f783a;

        e(View view) {
            super(1);
            this.f783a = view;
        }

        @Override
        public final Integer invoke(View view) {
            j.b(view, "it");
            View view2 = this.f783a;
            j.a((Object) view2, "this");
            return Integer.valueOf(view2.getHeight());
        }
    }

    static final class f extends k implements kotlin.b.a.b<Integer, r> {
        final View f784a;
        final SuperBottomSheetBehavior b;

        f(View view, SuperBottomSheetBehavior superBottomSheetBehavior) {
            super(1);
            this.f784a = view;
            this.b = superBottomSheetBehavior;
        }

        @Override
        public final r invoke(Integer num) {
            int intValue = num.intValue();
            this.b.setPeekHeight(intValue);
            View view = this.f784a;
            j.a((Object) view, "this@preview");
            ViewParent parent = view.getParent();
            j.a((Object) parent, "this@preview.parent");
            ViewParent parent2 = parent.getParent();
            if (!(parent2 instanceof View)) {
                parent2 = null;
            }
            View view2 = (View) parent2;
            if (view2 != null) {
                this.b.setHalfExpandedRatio(intValue / view2.getHeight());
            }
            return r.f1214a;
        }
    }

    static final class g extends k implements kotlin.b.a.b<View, Integer> {
        public static final g f785a = new g();

        g() {
            super(1);
        }

        @Override
        public final Integer invoke(View view) {
            View view2 = view;
            j.b(view2, "it");
            return Integer.valueOf(view2.getHeight());
        }
    }

    public SuperBottomSheetBehavior(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        j.b(context, CoreConstants.CONTEXT_SCOPE_VALUE);
        this.q = attributeSet;
        this.l = 0.8f;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.f.SuperBottomSheetBehavior);
        this.g = obtainStyledAttributes.getResourceId(R.f.SuperBottomSheetBehavior_behavior_preview, 0);
        this.h = obtainStyledAttributes.getResourceId(R.f.SuperBottomSheetBehavior_behavior_content, 0);
        this.i = obtainStyledAttributes.getDimensionPixelOffset(R.f.SuperBottomSheetBehavior_behavior_marginTop, 0);
        this.j = obtainStyledAttributes.getBoolean(R.f.SuperBottomSheetBehavior_behavior_disableShadow, false);
        this.n = obtainStyledAttributes.getBoolean(R.f.SuperBottomSheetBehavior_behavior_expandToTopMargin, false);
        this.l = obtainStyledAttributes.getFloat(R.f.SuperBottomSheetBehavior_behavior_shadowAlphaFactor, 0.8f);
        int color = obtainStyledAttributes.getColor(R.f.SuperBottomSheetBehavior_behavior_shadowColor, 0);
        this.k = color == 0 ? null : Integer.valueOf(color);
        obtainStyledAttributes.recycle();
        setPeekHeight(0);
        setFitToContents(false);
        setHalfExpandedRatio(1.0E-4f);
        setHideable(false);
        addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public final void onSlide(View view, float f2) {
                j.b(view, "bottomSheet");
                SuperBottomSheetBehavior.a(SuperBottomSheetBehavior.this, f2);
            }

            @Override
            public final void onStateChanged(View view, int i) {
                View view2;
                j.b(view, "bottomSheet");
                boolean z = true | true;
                if (i != 3) {
                    if (i == 4) {
                        kotlin.b.a.b<? super P, r> bVar = SuperBottomSheetBehavior.this.d;
                        if (bVar != null) {
                            bVar.invoke(SuperBottomSheetBehavior.b(SuperBottomSheetBehavior.this));
                        }
                        kotlin.b.a.b<? super C, r> bVar2 = SuperBottomSheetBehavior.this.e;
                        if (bVar2 != null) {
                            bVar2.invoke(SuperBottomSheetBehavior.a(SuperBottomSheetBehavior.this));
                        }
                        View view3 = SuperBottomSheetBehavior.this.m;
                        if (view3 != null) {
                            view3.setOnClickListener(null);
                            view3.setClickable(false);
                        }
                    }
                    return;
                }
                kotlin.b.a.b<? super P, r> bVar3 = SuperBottomSheetBehavior.this.b;
                if (bVar3 != null) {
                    bVar3.invoke(SuperBottomSheetBehavior.b(SuperBottomSheetBehavior.this));
                }
                kotlin.b.a.b<? super C, r> bVar4 = SuperBottomSheetBehavior.this.c;
                if (bVar4 != null) {
                    bVar4.invoke(SuperBottomSheetBehavior.a(SuperBottomSheetBehavior.this));
                }
                if (SuperBottomSheetBehavior.this.f778a == null || (view2 = SuperBottomSheetBehavior.this.m) == null) {
                    return;
                }
                kotlin.b.a.b<? super View, r> bVar5 = SuperBottomSheetBehavior.this.f778a;
                if (bVar5 != null) {
                    bVar5 = new com.adguard.kit.ui.behavior.b(bVar5);
                }
                view2.setOnClickListener((View.OnClickListener) bVar5);
            }
        });
    }

    public static final View a(SuperBottomSheetBehavior superBottomSheetBehavior) {
        C c2 = superBottomSheetBehavior.p;
        if (c2 == null) {
            j.a("content");
        }
        return c2;
    }

    private static void a(View view, kotlin.b.a.b<? super View, Integer> bVar, kotlin.b.a.b<? super Integer, r> bVar2) {
        if (bVar.invoke(view).intValue() != 0) {
            bVar2.invoke(bVar.invoke(view));
            return;
        }
        a.C0066a c0066a = com.adguard.kit.ui.b.a.f775a;
        a.C0066a.a(view, new c(bVar2, bVar));
    }

    public static final void a(SuperBottomSheetBehavior superBottomSheetBehavior, float f2) {
        C c2 = superBottomSheetBehavior.p;
        if (c2 == null) {
            j.a("content");
        }
        P p = superBottomSheetBehavior.o;
        if (p == null) {
            j.a("preview");
        }
        c2.setTranslationY((-p.getHeight()) * f2);
        P p2 = superBottomSheetBehavior.o;
        if (p2 == null) {
            j.a("preview");
        }
        P p3 = superBottomSheetBehavior.o;
        if (p3 == null) {
            j.a("preview");
        }
        p2.setTranslationY((-p3.getHeight()) * f2);
        P p4 = superBottomSheetBehavior.o;
        if (p4 == null) {
            j.a("preview");
        }
        p4.setAlpha(1.0f - Math.abs(f2));
        C c3 = superBottomSheetBehavior.p;
        if (c3 == null) {
            j.a("content");
        }
        c3.setAlpha(Math.abs(f2));
    }

    public static final void a(SuperBottomSheetBehavior superBottomSheetBehavior, int i, int i2) {
        if (superBottomSheetBehavior.i + i < i2 && !superBottomSheetBehavior.n) {
            superBottomSheetBehavior.setExpandedOffset(i2 - i);
            return;
        }
        superBottomSheetBehavior.setExpandedOffset(superBottomSheetBehavior.i);
        C c2 = superBottomSheetBehavior.p;
        if (c2 == null) {
            j.a("content");
        }
        C c3 = superBottomSheetBehavior.p;
        if (c3 == null) {
            j.a("content");
        }
        int paddingLeft = c3.getPaddingLeft();
        C c4 = superBottomSheetBehavior.p;
        if (c4 == null) {
            j.a("content");
        }
        int paddingTop = c4.getPaddingTop();
        C c5 = superBottomSheetBehavior.p;
        if (c5 == null) {
            j.a("content");
        }
        int paddingRight = c5.getPaddingRight();
        C c6 = superBottomSheetBehavior.p;
        if (c6 == null) {
            j.a("content");
        }
        int paddingBottom = c6.getPaddingBottom() + superBottomSheetBehavior.i;
        P p = superBottomSheetBehavior.o;
        if (p == null) {
            j.a("preview");
        }
        c2.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom - p.getHeight());
    }

    public static final View b(SuperBottomSheetBehavior superBottomSheetBehavior) {
        P p = superBottomSheetBehavior.o;
        if (p == null) {
            j.a("preview");
        }
        return p;
    }

    @Override
    public final boolean onLayoutChild(CoordinatorLayout coordinatorLayout, V v, int i) {
        ShadowBehavior shadowBehavior;
        j.b(coordinatorLayout, "parent");
        j.b(v, "child");
        if (this.j) {
            a.a().debug("Shadow is disabled");
        } else {
            int i2 = 0;
            while (true) {
                if (i2 >= coordinatorLayout.getChildCount()) {
                    i2 = -1;
                    break;
                }
                try {
                    View childAt = coordinatorLayout.getChildAt(i2);
                    if (childAt == null) {
                        throw new o("null cannot be cast to non-null type V");
                    }
                    j.b(childAt, "view");
                    com.adguard.kit.ui.behavior.a.a(childAt);
                } catch (Throwable unused) {
                    i2++;
                }
            }
            if (i2 == -1) {
                a.a().debug("Failed to find current child idx");
            } else {
                if (i2 > 0) {
                    View childAt2 = coordinatorLayout.getChildAt(i2 - 1);
                    if (!(childAt2 instanceof FrameLayout)) {
                        childAt2 = null;
                    }
                    FrameLayout frameLayout = (FrameLayout) childAt2;
                    if (frameLayout != null) {
                        ViewGroup.LayoutParams layoutParams = frameLayout.getLayoutParams();
                        if (!(layoutParams instanceof CoordinatorLayout.LayoutParams)) {
                            layoutParams = null;
                        }
                        CoordinatorLayout.LayoutParams layoutParams2 = (CoordinatorLayout.LayoutParams) layoutParams;
                        if (layoutParams2 != null) {
                            CoordinatorLayout.Behavior behavior = layoutParams2.getBehavior();
                            if (!(behavior instanceof ShadowBehavior)) {
                                behavior = null;
                            }
                            shadowBehavior = (ShadowBehavior) behavior;
                            if (shadowBehavior != null) {
                                a.a().debug("Shadow has been added before");
                            }
                        }
                    }
                    shadowBehavior = null;
                    if (shadowBehavior != null) {
                    }
                }
                View inflate = LayoutInflater.from(coordinatorLayout.getContext()).inflate(R.e.module_behavior_shadow, (ViewGroup) null);
                inflate.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
                Integer num = this.k;
                if (num != null) {
                    inflate.setBackgroundColor(num.intValue());
                }
                coordinatorLayout.addView(inflate, i2);
                j.a((Object) inflate, "this");
                ViewGroup.LayoutParams layoutParams3 = inflate.getLayoutParams();
                CoordinatorLayout.LayoutParams layoutParams4 = layoutParams3 instanceof CoordinatorLayout.LayoutParams ? layoutParams3 : null;
                if (layoutParams4 != null) {
                    layoutParams4.setBehavior(new ShadowBehavior(this.l));
                }
                this.m = inflate;
            }
        }
        int i3 = this.g;
        if (i3 == 0) {
            a.a().debug("Preview ID has not been specified");
        } else if (this.o != null) {
            a.a().debug("Preview already has been initialized");
        } else {
            P p = (P) coordinatorLayout.findViewById(i3);
            a(p, g.f785a, new f(p, this));
            j.a((Object) p, "findViewById<P>(previewI…}\n            }\n        }");
            this.o = p;
        }
        int i4 = this.h;
        if (i4 == 0) {
            a.a().debug("Content ID has not been specified");
        } else if (this.p != null) {
            a.a().debug("Content already has been initialized");
        } else {
            C c2 = (C) coordinatorLayout.findViewById(i4);
            a(c2, new e(c2), new d(coordinatorLayout));
            j.a((Object) c2, "findViewById<C>(contentI…ntent.height) }\n        }");
            this.p = c2;
        }
        return super.onLayoutChild(coordinatorLayout, v, i);
    }
}