导航菜单

页面标题

页面副标题

Housing v14.7.8 - ScreenFragment.java 源代码

正在查看: Housing v14.7.8 应用的 ScreenFragment.java JAVA 源代码文件

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


package com.swmansion.rnscreens;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import androidx.fragment.app.p;
import androidx.fragment.app.u;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.newrelic.agent.android.api.v2.TraceFieldInterface;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.tracing.Trace;
import com.newrelic.agent.android.tracing.TraceMachine;
import com.swmansion.rnscreens.events.HeaderBackButtonClickedEvent;
import com.swmansion.rnscreens.events.ScreenAppearEvent;
import com.swmansion.rnscreens.events.ScreenDisappearEvent;
import com.swmansion.rnscreens.events.ScreenDismissedEvent;
import com.swmansion.rnscreens.events.ScreenTransitionProgressEvent;
import com.swmansion.rnscreens.events.ScreenWillAppearEvent;
import com.swmansion.rnscreens.events.ScreenWillDisappearEvent;
import com.swmansion.rnscreens.ext.ViewExtKt;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.enums.EnumEntries;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.jvm.internal.r;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import zp.q;

@Metadata(d1 = {"\u0000n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\t\n\u0002\u0010\u0007\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0014\n\u0002\u0010!\n\u0002\b\u0012\b\u0016\u0018\u0000 O2\u00020\u00012\u00020\u0002:\u0003PQOB\t\b\u0016¢\u0006\u0004\b\u0003\u0010\u0004B\u0011\b\u0017\u0012\u0006\u0010\u0006\u001a\u00020\u0005¢\u0006\u0004\b\u0003\u0010\u0007J\u000f\u0010\t\u001a\u00020\bH\u0016¢\u0006\u0004\b\t\u0010\u0004J-\u0010\u0011\u001a\u0004\u0018\u00010\u00102\u0006\u0010\u000b\u001a\u00020\n2\b\u0010\r\u001a\u0004\u0018\u00010\f2\b\u0010\u000f\u001a\u0004\u0018\u00010\u000eH\u0016¢\u0006\u0004\b\u0011\u0010\u0012J\u000f\u0010\u0013\u001a\u00020\bH\u0016¢\u0006\u0004\b\u0013\u0010\u0004J\u0011\u0010\u0015\u001a\u0004\u0018\u00010\u0014H\u0016¢\u0006\u0004\b\u0015\u0010\u0016J\u0011\u0010\u0018\u001a\u0004\u0018\u00010\u0017H\u0016¢\u0006\u0004\b\u0018\u0010\u0019J\u0017\u0010\u001d\u001a\u00020\u001c2\u0006\u0010\u001b\u001a\u00020\u001aH\u0016¢\u0006\u0004\b\u001d\u0010\u001eJ\u0017\u0010\u001f\u001a\u00020\b2\u0006\u0010\u001b\u001a\u00020\u001aH\u0016¢\u0006\u0004\b\u001f\u0010 J\u001f\u0010\"\u001a\u00020\b2\u0006\u0010\u001b\u001a\u00020\u001a2\u0006\u0010!\u001a\u00020\u0002H\u0016¢\u0006\u0004\b\"\u0010#J\u0017\u0010$\u001a\u00020\b2\u0006\u0010\u001b\u001a\u00020\u001aH\u0016¢\u0006\u0004\b$\u0010 J\u000f\u0010%\u001a\u00020\bH\u0016¢\u0006\u0004\b%\u0010\u0004J\u001f\u0010)\u001a\u00020\b2\u0006\u0010'\u001a\u00020&2\u0006\u0010(\u001a\u00020\u001cH\u0016¢\u0006\u0004\b)\u0010*J\u0017\u0010,\u001a\u00020\b2\u0006\u0010\r\u001a\u00020+H\u0016¢\u0006\u0004\b,\u0010-J\u0017\u0010.\u001a\u00020\b2\u0006\u0010\r\u001a\u00020+H\u0016¢\u0006\u0004\b.\u0010-J\u000f\u0010/\u001a\u00020\bH\u0016¢\u0006\u0004\b/\u0010\u0004J\u000f\u00100\u001a\u00020\bH\u0016¢\u0006\u0004\b0\u0010\u0004J\u000f\u00101\u001a\u00020\bH\u0016¢\u0006\u0004\b1\u0010\u0004J\u000f\u00102\u001a\u00020\bH\u0002¢\u0006\u0004\b2\u0010\u0004J\u000f\u00103\u001a\u00020\bH\u0002¢\u0006\u0004\b3\u0010\u0004J\u000f\u00104\u001a\u00020\bH\u0002¢\u0006\u0004\b4\u0010\u0004J\u000f\u00105\u001a\u00020\bH\u0002¢\u0006\u0004\b5\u0010\u0004J\u000f\u00106\u001a\u00020\bH\u0002¢\u0006\u0004\b6\u0010\u0004J\u0017\u00108\u001a\u00020\b2\u0006\u00107\u001a\u00020\u001cH\u0002¢\u0006\u0004\b8\u00109R(\u0010:\u001a\u00020\u00058\u0016@\u0016X\u0096.¢\u0006\u0018\n\u0004\b:\u0010;\u0012\u0004\b?\u0010\u0004\u001a\u0004\b<\u0010=\"\u0004\b>\u0010\u0007R \u0010A\u001a\b\u0012\u0004\u0012\u00020+0@8\u0016X\u0096\u0004¢\u0006\f\n\u0004\bA\u0010B\u001a\u0004\bC\u0010DR\u0016\u0010E\u001a\u00020\u001c8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bE\u0010FR\u0016\u0010G\u001a\u00020&8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bG\u0010HR\u0016\u0010I\u001a\u00020\u001c8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bI\u0010FR\u0016\u0010J\u001a\u00020\u001c8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bJ\u0010FR\u0016\u0010K\u001a\u00020\u001c8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bK\u0010FR\u0014\u0010N\u001a\u00020\u00018VX\u0096\u0004¢\u0006\u0006\u001a\u0004\bL\u0010M¨\u0006R"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment;", "Landroidx/fragment/app/p;", "Lcom/swmansion/rnscreens/ScreenFragmentWrapper;", "<init>", "()V", "Lcom/swmansion/rnscreens/Screen;", "screenView", "(Lcom/swmansion/rnscreens/Screen;)V", "Lzp/j0;", "onResume", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroid/view/View;", "onCreateView", "(Landroid/view/LayoutInflater;Landroid/view/ViewGroup;Landroid/os/Bundle;)Landroid/view/View;", "onContainerUpdate", "Landroid/app/Activity;", "tryGetActivity", "()Landroid/app/Activity;", "Lcom/facebook/react/bridge/ReactContext;", "tryGetContext", "()Lcom/facebook/react/bridge/ReactContext;", "Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;", "event", "", "canDispatchLifecycleEvent", "(Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;)Z", "updateLastEventDispatched", "(Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;)V", "fragmentWrapper", "dispatchLifecycleEvent", "(Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;Lcom/swmansion/rnscreens/ScreenFragmentWrapper;)V", "dispatchLifecycleEventInChildContainers", "dispatchHeaderBackButtonClickedEvent", "", "alpha", "closing", "dispatchTransitionProgressEvent", "(FZ)V", "Lcom/swmansion/rnscreens/ScreenContainer;", "addChildScreenContainer", "(Lcom/swmansion/rnscreens/ScreenContainer;)V", "removeChildScreenContainer", "onViewAnimationStart", "onViewAnimationEnd", "onDestroy", "updateWindowTraits", "dispatchOnWillAppear", "dispatchOnAppear", "dispatchOnWillDisappear", "dispatchOnDisappear", "animationEnd", "dispatchViewAnimationEvent", "(Z)V", "screen", "Lcom/swmansion/rnscreens/Screen;", "getScreen", "()Lcom/swmansion/rnscreens/Screen;", "setScreen", "getScreen$annotations", "", "childScreenContainers", "Ljava/util/List;", "getChildScreenContainers", "()Ljava/util/List;", "shouldUpdateOnResume", "Z", "transitionProgress", "F", "canDispatchWillAppear", "canDispatchAppear", "isTransitioning", "getFragment", "()Landroidx/fragment/app/p;", "fragment", "Companion", "ScreenLifecycleEvent", "ScreensFrameLayout", "react-native-screens_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
@Instrumented
@SourceDebugExtension({"SMAP\nScreenFragment.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ScreenFragment.kt\ncom/swmansion/rnscreens/ScreenFragment\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,350:1\n1#2:351\n774#3:352\n865#3,2:353\n1863#3,2:355\n*S KotlinDebug\n*F\n+ 1 ScreenFragment.kt\ncom/swmansion/rnscreens/ScreenFragment\n*L\n230#1:352\n230#1:353,2\n230#1:355,2\n*E\n"})
public class ScreenFragment extends p implements ScreenFragmentWrapper, TraceFieldInterface {

    @NotNull
    public static final Companion INSTANCE = new Companion(null);

    @NotNull
    public static final String TAG = "ScreenFragment";
    public Trace _nr_trace;
    private boolean canDispatchAppear;
    private boolean canDispatchWillAppear;

    @NotNull
    private final List<ScreenContainer> childScreenContainers;
    private boolean isTransitioning;
    public Screen screen;
    private boolean shouldUpdateOnResume;
    private float transitionProgress;

    @Metadata(d1 = {"\u0000\u001e\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\n\n\u0000\n\u0002\u0010\u0007\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u000e\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tR\u000e\u0010\u0004\u001a\u00020\u0005X\u0086T¢\u0006\u0002\n\u0000¨\u0006\n"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment$Companion;", "", "<init>", "()V", "TAG", "", "getCoalescingKey", "", "progress", "", "react-native-screens_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final short getCoalescingKey(float progress) {
            return (short) (progress == 0.0f ? 1 : progress == 1.0f ? 2 : 3);
        }

        private Companion() {
        }
    }

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0007\b\u0086\u0081\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003j\u0002\b\u0004j\u0002\b\u0005j\u0002\b\u0006j\u0002\b\u0007¨\u0006\b"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;", "", "<init>", "(Ljava/lang/String;I)V", "DID_APPEAR", "WILL_APPEAR", "DID_DISAPPEAR", "WILL_DISAPPEAR", "react-native-screens_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
    public static final class ScreenLifecycleEvent {
        private static final EnumEntries $ENTRIES;
        private static final ScreenLifecycleEvent[] $VALUES;
        public static final ScreenLifecycleEvent DID_APPEAR = new ScreenLifecycleEvent("DID_APPEAR", 0);
        public static final ScreenLifecycleEvent WILL_APPEAR = new ScreenLifecycleEvent("WILL_APPEAR", 1);
        public static final ScreenLifecycleEvent DID_DISAPPEAR = new ScreenLifecycleEvent("DID_DISAPPEAR", 2);
        public static final ScreenLifecycleEvent WILL_DISAPPEAR = new ScreenLifecycleEvent("WILL_DISAPPEAR", 3);

        private static final ScreenLifecycleEvent[] $values() {
            return new ScreenLifecycleEvent[]{DID_APPEAR, WILL_APPEAR, DID_DISAPPEAR, WILL_DISAPPEAR};
        }

        static {
            ScreenLifecycleEvent[] $values = $values();
            $VALUES = $values;
            $ENTRIES = fq.a.a($values);
        }

        private ScreenLifecycleEvent(String str, int i) {
        }

        @NotNull
        public static EnumEntries<ScreenLifecycleEvent> getEntries() {
            return $ENTRIES;
        }

        public static ScreenLifecycleEvent valueOf(String str) {
            return (ScreenLifecycleEvent) Enum.valueOf(ScreenLifecycleEvent.class, str);
        }

        public static ScreenLifecycleEvent[] values() {
            return (ScreenLifecycleEvent[]) $VALUES.clone();
        }
    }

    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0002\u0018\u00002\u00020\u0001B\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u000f\u0010\u0007\u001a\u00020\u0006H\u0016¢\u0006\u0004\b\u0007\u0010\b¨\u0006\t"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment$ScreensFrameLayout;", "Landroid/widget/FrameLayout;", "Landroid/content/Context;", "context", "<init>", "(Landroid/content/Context;)V", "Lzp/j0;", "clearFocus", "()V", "react-native-screens_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
    public static final class ScreensFrameLayout extends FrameLayout {
        public ScreensFrameLayout(@NotNull Context context) {
            super(context);
            r.k(context, "context");
        }

        @Override
        public void clearFocus() {
            if (getVisibility() != 4) {
                super.clearFocus();
            }
        }
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = 48)
    public class WhenMappings {
        public static final int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[ScreenLifecycleEvent.values().length];
            try {
                iArr[ScreenLifecycleEvent.WILL_APPEAR.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[ScreenLifecycleEvent.DID_APPEAR.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[ScreenLifecycleEvent.WILL_DISAPPEAR.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[ScreenLifecycleEvent.DID_DISAPPEAR.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

    public ScreenFragment() {
        this.childScreenContainers = new ArrayList();
        this.transitionProgress = -1.0f;
        this.canDispatchWillAppear = true;
        this.canDispatchAppear = true;
        throw new IllegalStateException("Screen 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.");
    }

    private final void dispatchOnAppear() {
        dispatchLifecycleEvent(ScreenLifecycleEvent.DID_APPEAR, this);
        dispatchTransitionProgressEvent(1.0f, false);
    }

    private final void dispatchOnDisappear() {
        dispatchLifecycleEvent(ScreenLifecycleEvent.DID_DISAPPEAR, this);
        dispatchTransitionProgressEvent(1.0f, true);
    }

    private final void dispatchOnWillAppear() {
        dispatchLifecycleEvent(ScreenLifecycleEvent.WILL_APPEAR, this);
        dispatchTransitionProgressEvent(0.0f, false);
    }

    private final void dispatchOnWillDisappear() {
        dispatchLifecycleEvent(ScreenLifecycleEvent.WILL_DISAPPEAR, this);
        dispatchTransitionProgressEvent(0.0f, true);
    }

    private final void dispatchViewAnimationEvent(boolean animationEnd) {
        this.isTransitioning = !animationEnd;
        p parentFragment = getParentFragment();
        if (parentFragment == null || ((parentFragment instanceof ScreenFragment) && !((ScreenFragment) parentFragment).isTransitioning)) {
            if (isResumed()) {
                UiThreadUtil.runOnUiThread(new androidx.camera.camera2.interop.b(animationEnd, this, 8));
            } else if (animationEnd) {
                dispatchOnDisappear();
            } else {
                dispatchOnWillDisappear();
            }
        }
    }

    public static final void dispatchViewAnimationEvent$lambda$8(boolean z, ScreenFragment screenFragment) {
        if (z) {
            screenFragment.dispatchOnAppear();
        } else {
            screenFragment.dispatchOnWillAppear();
        }
    }

    public static void getScreen$annotations() {
    }

    private final void updateWindowTraits() {
        Activity activity = getActivity();
        if (activity == null) {
            this.shouldUpdateOnResume = true;
        } else {
            ScreenWindowTraits.INSTANCE.trySetWindowTraits$react_native_screens_release(getScreen(), activity, tryGetContext());
        }
    }

    @Override
    public void addChildScreenContainer(@NotNull ScreenContainer container) {
        r.k(container, "container");
        getChildScreenContainers().add(container);
    }

    @Override
    public boolean canDispatchLifecycleEvent(@NotNull ScreenLifecycleEvent event) {
        r.k(event, "event");
        int i = WhenMappings.$EnumSwitchMapping$0[event.ordinal()];
        if (i == 1) {
            return this.canDispatchWillAppear;
        }
        if (i == 2) {
            return this.canDispatchAppear;
        }
        if (i == 3) {
            return !this.canDispatchWillAppear;
        }
        if (i == 4) {
            return !this.canDispatchAppear;
        }
        throw new q();
    }

    @Override
    public void dispatchHeaderBackButtonClickedEvent() {
        ReactContext context = getScreen().getContext();
        r.i(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
        ReactContext reactContext = context;
        int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
        EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(reactContext, getScreen().getId());
        if (eventDispatcherForReactTag != null) {
            eventDispatcherForReactTag.dispatchEvent(new HeaderBackButtonClickedEvent(surfaceId, getScreen().getId()));
        }
    }

    @Override
    public void dispatchLifecycleEvent(@NotNull ScreenLifecycleEvent event, @NotNull ScreenFragmentWrapper fragmentWrapper) {
        Event screenWillAppearEvent;
        r.k(event, "event");
        r.k(fragmentWrapper, "fragmentWrapper");
        p fragment = fragmentWrapper.getFragment();
        if (fragment instanceof ScreenStackFragment) {
            ScreenStackFragment screenStackFragment = (ScreenStackFragment) fragment;
            if (screenStackFragment.canDispatchLifecycleEvent(event)) {
                Screen screen = screenStackFragment.getScreen();
                fragmentWrapper.updateLastEventDispatched(event);
                int surfaceId = UIManagerHelper.getSurfaceId(screen);
                int i = WhenMappings.$EnumSwitchMapping$0[event.ordinal()];
                if (i == 1) {
                    screenWillAppearEvent = new ScreenWillAppearEvent(surfaceId, screen.getId());
                } else if (i == 2) {
                    screenWillAppearEvent = new ScreenAppearEvent(surfaceId, screen.getId());
                } else if (i == 3) {
                    screenWillAppearEvent = new ScreenWillDisappearEvent(surfaceId, screen.getId());
                } else {
                    if (i != 4) {
                        throw new q();
                    }
                    screenWillAppearEvent = new ScreenDisappearEvent(surfaceId, screen.getId());
                }
                ReactContext context = getScreen().getContext();
                r.i(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
                EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(context, getScreen().getId());
                if (eventDispatcherForReactTag != null) {
                    eventDispatcherForReactTag.dispatchEvent(screenWillAppearEvent);
                }
                fragmentWrapper.dispatchLifecycleEventInChildContainers(event);
            }
        }
    }

    @Override
    public void dispatchLifecycleEventInChildContainers(@NotNull ScreenLifecycleEvent event) {
        ScreenFragmentWrapper fragmentWrapper;
        r.k(event, "event");
        List<ScreenContainer> childScreenContainers = getChildScreenContainers();
        ArrayList arrayList = new ArrayList();
        for (Object obj : childScreenContainers) {
            if (((ScreenContainer) obj).getScreenCount() > 0) {
                arrayList.add(obj);
            }
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            Screen topScreen = ((ScreenContainer) it.next()).getTopScreen();
            if (topScreen != null && (fragmentWrapper = topScreen.getFragmentWrapper()) != null) {
                dispatchLifecycleEvent(event, fragmentWrapper);
            }
        }
    }

    @Override
    public void dispatchTransitionProgressEvent(float alpha, boolean closing) {
        if (!(this instanceof ScreenStackFragment) || this.transitionProgress == alpha) {
            return;
        }
        float max = Math.max(0.0f, Math.min(1.0f, alpha));
        this.transitionProgress = max;
        short coalescingKey = INSTANCE.getCoalescingKey(max);
        ScreenStackFragment screenStackFragment = (ScreenStackFragment) this;
        ScreenContainer container = screenStackFragment.getScreen().getContainer();
        boolean goingForward = container instanceof ScreenStack ? ((ScreenStack) container).getGoingForward() : false;
        ReactContext context = screenStackFragment.getScreen().getContext();
        r.i(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
        ReactContext reactContext = context;
        EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(reactContext, screenStackFragment.getScreen().getId());
        if (eventDispatcherForReactTag != null) {
            eventDispatcherForReactTag.dispatchEvent(new ScreenTransitionProgressEvent(UIManagerHelper.getSurfaceId(reactContext), screenStackFragment.getScreen().getId(), this.transitionProgress, closing, goingForward, coalescingKey));
        }
    }

    @Override
    @NotNull
    public List<ScreenContainer> getChildScreenContainers() {
        return this.childScreenContainers;
    }

    @Override
    @NotNull
    public p getFragment() {
        return this;
    }

    @Override
    @NotNull
    public Screen getScreen() {
        Screen screen = this.screen;
        if (screen != null) {
            return screen;
        }
        r.o("screen");
        throw null;
    }

    @Override
    public void onContainerUpdate() {
        updateWindowTraits();
    }

    @Nullable
    public View onCreateView(@NotNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        ScreensFrameLayout screensFrameLayout = null;
        try {
            TraceMachine.enterMethod(this._nr_trace, "ScreenFragment#onCreateView", (ArrayList) null);
        } catch (NoSuchFieldError unused) {
            TraceMachine.enterMethod((Trace) null, "ScreenFragment#onCreateView", (ArrayList) null);
        }
        r.k(inflater, "inflater");
        getScreen().setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        Context context = getContext();
        if (context != null) {
            screensFrameLayout = new ScreensFrameLayout(context);
            screensFrameLayout.addView(ViewExtKt.recycle(getScreen()));
        }
        TraceMachine.exitMethod();
        return screensFrameLayout;
    }

    public void onDestroy() {
        super.onDestroy();
        ScreenContainer container = getScreen().getContainer();
        if (container == null || !container.hasScreen(getScreen().getFragmentWrapper())) {
            ReactContext context = getScreen().getContext();
            if (context instanceof ReactContext) {
                int surfaceId = UIManagerHelper.getSurfaceId(context);
                EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(context, getScreen().getId());
                if (eventDispatcherForReactTag != null) {
                    eventDispatcherForReactTag.dispatchEvent(new ScreenDismissedEvent(surfaceId, getScreen().getId()));
                }
            }
        }
        getChildScreenContainers().clear();
    }

    public void onResume() {
        super.onResume();
        if (this.shouldUpdateOnResume) {
            this.shouldUpdateOnResume = false;
            ScreenWindowTraits.INSTANCE.trySetWindowTraits$react_native_screens_release(getScreen(), tryGetActivity(), tryGetContext());
        }
    }

    public void onStart() {
        super.onStart();
    }

    public void onStop() {
        super.onStop();
    }

    @Override
    public void onViewAnimationEnd() {
        dispatchViewAnimationEvent(true);
    }

    @Override
    public void onViewAnimationStart() {
        dispatchViewAnimationEvent(false);
    }

    @Override
    public void removeChildScreenContainer(@NotNull ScreenContainer container) {
        r.k(container, "container");
        getChildScreenContainers().remove(container);
    }

    @Override
    public void setScreen(@NotNull Screen screen) {
        r.k(screen, "<set-?>");
        this.screen = screen;
    }

    @Override
    @Nullable
    public Activity tryGetActivity() {
        p fragment;
        u activity;
        u activity2 = getActivity();
        if (activity2 != null) {
            return activity2;
        }
        ReactContext context = getScreen().getContext();
        if (context instanceof ReactContext) {
            ReactContext reactContext = context;
            if (reactContext.getCurrentActivity() != null) {
                return reactContext.getCurrentActivity();
            }
        }
        for (ViewParent container = getScreen().getContainer(); container != null; container = container.getParent()) {
            if ((container instanceof Screen) && (fragment = ((Screen) container).getFragment()) != null && (activity = fragment.getActivity()) != null) {
                return activity;
            }
        }
        return null;
    }

    @Override
    @Nullable
    public ReactContext tryGetContext() {
        if (getContext() instanceof ReactContext) {
            ReactContext context = getContext();
            r.i(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
            return context;
        }
        if (getScreen().getContext() instanceof ReactContext) {
            ReactContext context2 = getScreen().getContext();
            r.i(context2, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
            return context2;
        }
        for (ViewParent container = getScreen().getContainer(); container != null; container = container.getParent()) {
            if (container instanceof Screen) {
                Screen screen = (Screen) container;
                if (screen.getContext() instanceof ReactContext) {
                    ReactContext context3 = screen.getContext();
                    r.i(context3, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
                    return context3;
                }
            }
        }
        return null;
    }

    @Override
    public void updateLastEventDispatched(@NotNull ScreenLifecycleEvent event) {
        r.k(event, "event");
        int i = WhenMappings.$EnumSwitchMapping$0[event.ordinal()];
        if (i == 1) {
            this.canDispatchWillAppear = false;
            return;
        }
        if (i == 2) {
            this.canDispatchAppear = false;
        } else if (i == 3) {
            this.canDispatchWillAppear = true;
        } else {
            if (i != 4) {
                throw new q();
            }
            this.canDispatchAppear = true;
        }
    }

    @SuppressLint({"ValidFragment"})
    public ScreenFragment(@NotNull Screen screenView) {
        r.k(screenView, "screenView");
        this.childScreenContainers = new ArrayList();
        this.transitionProgress = -1.0f;
        this.canDispatchWillAppear = true;
        this.canDispatchAppear = true;
        setScreen(screenView);
    }
}