导航菜单

页面标题

页面副标题

Zepto v25.1.4 - ScreenStackFragment.java 源代码

正在查看: Zepto v25.1.4 应用的 ScreenStackFragment.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.swmansion.rnscreens;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.Transformation;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
import com.swmansion.rnscreens.ScreenStackFragment;
import com.swmansion.rnscreens.ScreenStackHeaderSubview;
import kotlin.Metadata;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;

@Metadata
@SourceDebugExtension
public final class ScreenStackFragment extends ScreenFragment implements ScreenStackFragmentWrapper {
    public AppBarLayout V;
    public Toolbar W;
    public boolean X;
    public boolean Y;
    public View Z;
    public CustomSearchView a0;
    public Function1 b0;

    @Metadata
    public static final class ScreensAnimation extends Animation {
        public final ScreenFragment a;

        public ScreensAnimation(ScreenFragment mFragment) {
            Intrinsics.checkNotNullParameter(mFragment, "mFragment");
            this.a = mFragment;
        }

        @Override
        public final void applyTransformation(float f2, Transformation t) {
            Intrinsics.checkNotNullParameter(t, "t");
            super.applyTransformation(f2, t);
            this.a.J(f2, !r3.isResumed());
        }
    }

    @Metadata
    @SourceDebugExtension
    public static final class ScreensCoordinatorLayout extends CoordinatorLayout {
        public final ScreenFragment x;
        public final ScreenStackFragment$ScreensCoordinatorLayout$mAnimationListener$1 y;

        public ScreensCoordinatorLayout(Context context, ScreenFragment mFragment) {
            super(context);
            Intrinsics.checkNotNullParameter(context, "context");
            Intrinsics.checkNotNullParameter(mFragment, "mFragment");
            this.x = mFragment;
            this.y = new Animation.AnimationListener() {
                @Override
                public final void onAnimationEnd(Animation animation) {
                    Intrinsics.checkNotNullParameter(animation, "animation");
                    ScreenStackFragment.ScreensCoordinatorLayout.this.x.L();
                }

                @Override
                public final void onAnimationRepeat(Animation animation) {
                    Intrinsics.checkNotNullParameter(animation, "animation");
                }

                @Override
                public final void onAnimationStart(Animation animation) {
                    Intrinsics.checkNotNullParameter(animation, "animation");
                    ScreenStackFragment.ScreensCoordinatorLayout.this.x.K(false);
                }
            };
        }

        public final void clearFocus() {
            if (getVisibility() != 4) {
                super/*android.view.ViewGroup*/.clearFocus();
            }
        }

        public final void startAnimation(Animation animation) {
            Intrinsics.checkNotNullParameter(animation, "animation");
            ScreenFragment screenFragment = this.x;
            ScreensAnimation screensAnimation = new ScreensAnimation(screenFragment);
            screensAnimation.setDuration(animation.getDuration());
            boolean z = animation instanceof AnimationSet;
            ScreenStackFragment$ScreensCoordinatorLayout$mAnimationListener$1 screenStackFragment$ScreensCoordinatorLayout$mAnimationListener$1 = this.y;
            if (z && !screenFragment.isRemoving()) {
                AnimationSet animationSet = (AnimationSet) animation;
                animationSet.addAnimation(screensAnimation);
                animationSet.setAnimationListener(screenStackFragment$ScreensCoordinatorLayout$mAnimationListener$1);
                super/*android.view.ViewGroup*/.startAnimation(animationSet);
                return;
            }
            AnimationSet animationSet2 = new AnimationSet(true);
            animationSet2.addAnimation(animation);
            animationSet2.addAnimation(screensAnimation);
            animationSet2.setAnimationListener(screenStackFragment$ScreensCoordinatorLayout$mAnimationListener$1);
            super/*android.view.ViewGroup*/.startAnimation(animationSet2);
        }
    }

    public ScreenStackFragment() {
        throw new IllegalStateException("ScreenStack fragments should never be restored. Follow instructions from https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067 to properly configure your main activity.");
    }

    @Override
    public final void L() {
        K(true);
        View view = getView();
        ViewParent parent = view != null ? view.getParent() : null;
        if (parent instanceof ScreenStack) {
            ScreenStack screenStack = (ScreenStack) parent;
            if (screenStack.f2766n) {
                return;
            }
            screenStack.k();
        }
    }

    public final boolean N() {
        ScreenContainer container = r().getContainer();
        if (!(container instanceof ScreenStack)) {
            throw new IllegalStateException("ScreenStackFragment added into a non-stack container".toString());
        }
        if (!Intrinsics.c(((ScreenStack) container).getRootScreen(), r())) {
            return true;
        }
        Fragment parentFragment = getParentFragment();
        if (parentFragment instanceof ScreenStackFragment) {
            return ((ScreenStackFragment) parentFragment).N();
        }
        return false;
    }

    public final void O(Menu menu) {
        menu.clear();
        ScreenStackHeaderConfig headerConfig = r().getHeaderConfig();
        int configSubviewsCount = headerConfig != null ? headerConfig.getConfigSubviewsCount() : 0;
        if (headerConfig == null || configSubviewsCount <= 0) {
            return;
        }
        for (int i2 = 0; i2 < configSubviewsCount; i2++) {
            Object obj = headerConfig.a.get(i2);
            Intrinsics.checkNotNullExpressionValue(obj, "configSubviews[index]");
            if (((ScreenStackHeaderSubview) obj).getType() == ScreenStackHeaderSubview.Type.f2780e) {
                Context context = getContext();
                if (this.a0 == null && context != null) {
                    CustomSearchView customSearchView = new CustomSearchView(context, this);
                    this.a0 = customSearchView;
                    Function1 function1 = this.b0;
                    if (function1 != null) {
                        function1.invoke(customSearchView);
                    }
                }
                MenuItem add = menu.add("");
                add.setShowAsAction(2);
                add.setActionView((View) this.a0);
                return;
            }
        }
    }

    public final void dismiss() {
        ScreenContainer container = r().getContainer();
        if (!(container instanceof ScreenStack)) {
            throw new IllegalStateException("ScreenStackFragment added into a non-stack container".toString());
        }
        ScreenStack screenStack = (ScreenStack) container;
        screenStack.getClass();
        Intrinsics.checkNotNullParameter(this, "screenFragment");
        screenStack.f2762j.add(this);
        screenStack.f2755d = true;
        screenStack.g();
    }

    public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        Intrinsics.checkNotNullParameter(menu, "menu");
        Intrinsics.checkNotNullParameter(inflater, "inflater");
        O(menu);
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public final View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
        AppBarLayout appBarLayout;
        AppBarLayout appBarLayout2;
        Intrinsics.checkNotNullParameter(inflater, "inflater");
        Context context = getContext();
        View view = null;
        CoordinatorLayout screensCoordinatorLayout = context != null ? new ScreensCoordinatorLayout(context, this) : null;
        Screen r = r();
        CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(-1, -1);
        layoutParams.b(this.Y ? null : new AppBarLayout.ScrollingViewBehavior());
        r.setLayoutParams(layoutParams);
        if (screensCoordinatorLayout != null) {
            Screen r2 = r();
            ScreenFragment.M(r2);
            screensCoordinatorLayout.addView(r2);
        }
        Context context2 = getContext();
        if (context2 != null) {
            view = new AppBarLayout(context2);
            view.setBackgroundColor(0);
            view.setLayoutParams(new AppBarLayout.LayoutParams());
        }
        this.V = view;
        if (screensCoordinatorLayout != null) {
            screensCoordinatorLayout.addView(view);
        }
        if (this.X && (appBarLayout2 = this.V) != null) {
            appBarLayout2.setTargetElevation(0.0f);
        }
        Toolbar toolbar = this.W;
        if (toolbar != null && (appBarLayout = this.V) != null) {
            ScreenFragment.M(toolbar);
            appBarLayout.addView(toolbar);
        }
        setHasOptionsMenu(true);
        return screensCoordinatorLayout;
    }

    public final void onPrepareOptionsMenu(Menu menu) {
        Intrinsics.checkNotNullParameter(menu, "menu");
        O(menu);
        super.onPrepareOptionsMenu(menu);
    }

    public final void onStart() {
        View view = this.Z;
        if (view != null) {
            view.requestFocus();
        }
        super.onStart();
    }

    public final void onStop() {
        PackageManager packageManager;
        Context context = getContext();
        if (context != null && (packageManager = context.getPackageManager()) != null && packageManager.hasSystemFeature("android.software.leanback")) {
            View r = r();
            while (true) {
                if (r == null) {
                    r = null;
                    break;
                } else if (r.isFocused()) {
                    break;
                } else {
                    r = r instanceof ViewGroup ? ((ViewGroup) r).getFocusedChild() : null;
                }
            }
            this.Z = r;
        }
        super.onStop();
    }

    @Override
    public final void y() {
        super.y();
        ScreenStackHeaderConfig headerConfig = r().getHeaderConfig();
        if (headerConfig != null) {
            headerConfig.b();
        }
    }
}