导航菜单

页面标题

页面副标题

Oolka v2.4.42 - ScreenFragment.java 源代码

正在查看: Oolka v2.4.42 应用的 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.Fragment;
import androidx.fragment.app.FragmentActivity;
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 java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;

@Metadata
@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,332:1\n1#2:333\n766#3:334\n857#3,2:335\n1855#3,2:337\n*S KotlinDebug\n*F\n+ 1 ScreenFragment.kt\ncom/swmansion/rnscreens/ScreenFragment\n*L\n216#1:334\n216#1:335,2\n216#1:337,2\n*E\n"})
public class ScreenFragment extends Fragment implements n {

    @NotNull
    public static final a k = new a(null);
    public i d;

    @NotNull
    public final List<k> e;
    public boolean f;
    public float g;
    public boolean h;
    public boolean i;
    public boolean j;

    @Metadata
    public static final class a {
        public a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        @JvmStatic
        @NotNull
        public final View a(@NotNull View view) {
            Intrinsics.checkNotNullParameter(view, "view");
            ViewParent parent = view.getParent();
            if (parent != null) {
                ViewGroup viewGroup = (ViewGroup) parent;
                viewGroup.endViewTransition(view);
                viewGroup.removeView(view);
            }
            view.setVisibility(0);
            return view;
        }

        public a() {
        }
    }

    @Metadata
    public static final class b {
        private static final kotlin.enums.a $ENTRIES;
        private static final b[] $VALUES;
        public static final b Appear = new b("Appear", 0);
        public static final b WillAppear = new b("WillAppear", 1);
        public static final b Disappear = new b("Disappear", 2);
        public static final b WillDisappear = new b("WillDisappear", 3);

        private static final b[] $values() {
            return new b[]{Appear, WillAppear, Disappear, WillDisappear};
        }

        static {
            b[] $values = $values();
            $VALUES = $values;
            $ENTRIES = kotlin.enums.b.a($values);
        }

        private b(String str, int i) {
        }

        @NotNull
        public static kotlin.enums.a<b> getEntries() {
            return $ENTRIES;
        }

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

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

    @Metadata
    public static final class c extends FrameLayout {
        public c(@NotNull Context context) {
            super(context);
            Intrinsics.checkNotNullParameter(context, "context");
        }

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

    @Metadata
    public class d {
        public static final int[] a;

        static {
            int[] iArr = new int[b.values().length];
            try {
                iArr[b.WillAppear.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[b.Appear.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[b.WillDisappear.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[b.Disappear.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            a = iArr;
        }
    }

    public ScreenFragment() {
        this.e = new ArrayList();
        this.g = -1.0f;
        this.h = true;
        this.i = 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.");
    }

    @JvmStatic
    @NotNull
    public static final View C(@NotNull View view) {
        return k.a(view);
    }

    public static final void z(boolean z, ScreenFragment this$0) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        if (z) {
            this$0.t();
        } else {
            this$0.v();
        }
    }

    public void A() {
        y(true);
    }

    public void B() {
        y(false);
    }

    public void D(@NotNull i iVar) {
        Intrinsics.checkNotNullParameter(iVar, "<set-?>");
        this.d = iVar;
    }

    public final void E() {
        Activity activity = getActivity();
        if (activity == null) {
            this.f = true;
        } else {
            x.a.v(e(), activity, n());
        }
    }

    @Override
    @NotNull
    public Fragment c() {
        return this;
    }

    @Override
    @NotNull
    public i e() {
        i iVar = this.d;
        if (iVar != null) {
            return iVar;
        }
        Intrinsics.throwUninitializedPropertyAccessException("screen");
        return null;
    }

    @Override
    public Activity f() {
        Fragment fragment;
        FragmentActivity activity;
        FragmentActivity activity2 = getActivity();
        if (activity2 != null) {
            return activity2;
        }
        ReactContext context = e().getContext();
        if (context instanceof ReactContext) {
            ReactContext reactContext = context;
            if (reactContext.getCurrentActivity() != null) {
                return reactContext.getCurrentActivity();
            }
        }
        for (ViewParent container = e().getContainer(); container != null; container = container.getParent()) {
            if ((container instanceof i) && (fragment = ((i) container).getFragment()) != null && (activity = fragment.getActivity()) != null) {
                return activity;
            }
        }
        return null;
    }

    @Override
    public void g(@NotNull b event) {
        n fragmentWrapper;
        Intrinsics.checkNotNullParameter(event, "event");
        List<k> list = this.e;
        ArrayList arrayList = new ArrayList();
        for (Object obj : list) {
            if (((k) obj).getScreenCount() > 0) {
                arrayList.add(obj);
            }
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            i topScreen = ((k) it.next()).getTopScreen();
            if (topScreen != null && (fragmentWrapper = topScreen.getFragmentWrapper()) != null) {
                s(event, fragmentWrapper);
            }
        }
    }

    @Override
    @NotNull
    public List<k> h() {
        return this.e;
    }

    @Override
    public void i(@NotNull k container) {
        Intrinsics.checkNotNullParameter(container, "container");
        this.e.add(container);
    }

    @Override
    public void j() {
        E();
    }

    @Override
    public void k(@NotNull k container) {
        Intrinsics.checkNotNullParameter(container, "container");
        this.e.remove(container);
    }

    @Override
    public void l(@NotNull b event) {
        Intrinsics.checkNotNullParameter(event, "event");
        int i = d.a[event.ordinal()];
        if (i == 1) {
            this.h = false;
            return;
        }
        if (i == 2) {
            this.i = false;
        } else if (i == 3) {
            this.h = true;
        } else {
            if (i != 4) {
                return;
            }
            this.i = true;
        }
    }

    @Override
    public ReactContext n() {
        if (getContext() instanceof ReactContext) {
            ReactContext context = getContext();
            Intrinsics.checkNotNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
            return context;
        }
        if (e().getContext() instanceof ReactContext) {
            ReactContext context2 = e().getContext();
            Intrinsics.checkNotNull(context2, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
            return context2;
        }
        for (ViewParent container = e().getContainer(); container != null; container = container.getParent()) {
            if (container instanceof i) {
                i iVar = (i) container;
                if (iVar.getContext() instanceof ReactContext) {
                    ReactContext context3 = iVar.getContext();
                    Intrinsics.checkNotNull(context3, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
                    return context3;
                }
            }
        }
        return null;
    }

    public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
        Intrinsics.checkNotNullParameter(inflater, "inflater");
        e().setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        Context context = getContext();
        if (context == null) {
            return null;
        }
        c cVar = new c(context);
        cVar.addView(C(e()));
        return cVar;
    }

    public void onDestroy() {
        super.onDestroy();
        k container = e().getContainer();
        if (container == null || !container.l(this)) {
            ReactContext context = e().getContext();
            if (context instanceof ReactContext) {
                int surfaceId = UIManagerHelper.getSurfaceId(context);
                EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(context, e().getId());
                if (eventDispatcherForReactTag != null) {
                    eventDispatcherForReactTag.dispatchEvent(new com.swmansion.rnscreens.events.g(surfaceId, e().getId()));
                }
            }
        }
        this.e.clear();
    }

    public void onResume() {
        super.onResume();
        if (this.f) {
            this.f = false;
            x.a.v(e(), f(), n());
        }
    }

    public boolean q(@NotNull b event) {
        Intrinsics.checkNotNullParameter(event, "event");
        int i = d.a[event.ordinal()];
        if (i == 1) {
            return this.h;
        }
        if (i == 2) {
            return this.i;
        }
        if (i != 3) {
            if (i != 4) {
                throw new NoWhenBranchMatchedException();
            }
            if (!this.i) {
                return true;
            }
        } else if (!this.h) {
            return true;
        }
        return false;
    }

    public void r() {
        ReactContext context = e().getContext();
        Intrinsics.checkNotNull(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, e().getId());
        if (eventDispatcherForReactTag != null) {
            eventDispatcherForReactTag.dispatchEvent(new com.swmansion.rnscreens.events.b(surfaceId, e().getId()));
        }
    }

    public void s(@NotNull b event, @NotNull n fragmentWrapper) {
        Event iVar;
        Intrinsics.checkNotNullParameter(event, "event");
        Intrinsics.checkNotNullParameter(fragmentWrapper, "fragmentWrapper");
        Fragment c2 = fragmentWrapper.c();
        if (c2 instanceof ScreenStackFragment) {
            ScreenStackFragment screenStackFragment = (ScreenStackFragment) c2;
            if (screenStackFragment.q(event)) {
                i e = screenStackFragment.e();
                fragmentWrapper.l(event);
                int surfaceId = UIManagerHelper.getSurfaceId(e);
                int i = d.a[event.ordinal()];
                if (i == 1) {
                    iVar = new com.swmansion.rnscreens.events.i(surfaceId, e.getId());
                } else if (i == 2) {
                    iVar = new com.swmansion.rnscreens.events.e(surfaceId, e.getId());
                } else if (i == 3) {
                    iVar = new com.swmansion.rnscreens.events.j(surfaceId, e.getId());
                } else {
                    if (i != 4) {
                        throw new NoWhenBranchMatchedException();
                    }
                    iVar = new com.swmansion.rnscreens.events.f(surfaceId, e.getId());
                }
                ReactContext context = e().getContext();
                Intrinsics.checkNotNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
                EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(context, e().getId());
                if (eventDispatcherForReactTag != null) {
                    eventDispatcherForReactTag.dispatchEvent(iVar);
                }
                fragmentWrapper.g(event);
            }
        }
    }

    public final void t() {
        s(b.Appear, this);
        x(1.0f, false);
    }

    public final void u() {
        s(b.Disappear, this);
        x(1.0f, true);
    }

    public final void v() {
        s(b.WillAppear, this);
        x(0.0f, false);
    }

    public final void w() {
        s(b.WillDisappear, this);
        x(0.0f, true);
    }

    public void x(float f, boolean z) {
        if (this instanceof ScreenStackFragment) {
            if (this.g == f) {
                return;
            }
            float max = Math.max(0.0f, Math.min(1.0f, f));
            this.g = max;
            if (!(max == 0.0f)) {
                r1 = (max != 1.0f ? 0 : 1) != 0 ? 2 : 3;
            }
            short s = (short) r1;
            k container = e().getContainer();
            boolean goingForward = container instanceof p ? ((p) container).getGoingForward() : false;
            ReactContext context = e().getContext();
            Intrinsics.checkNotNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
            ReactContext reactContext = context;
            EventDispatcher eventDispatcherForReactTag = UIManagerHelper.getEventDispatcherForReactTag(reactContext, e().getId());
            if (eventDispatcherForReactTag != null) {
                eventDispatcherForReactTag.dispatchEvent(new com.swmansion.rnscreens.events.h(UIManagerHelper.getSurfaceId(reactContext), e().getId(), this.g, z, goingForward, s));
            }
        }
    }

    public final void y(final boolean z) {
        this.j = !z;
        Fragment parentFragment = getParentFragment();
        if (parentFragment == null || ((parentFragment instanceof ScreenFragment) && !((ScreenFragment) parentFragment).j)) {
            if (isResumed()) {
                UiThreadUtil.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        ScreenFragment.z(z, this);
                    }
                });
            } else if (z) {
                u();
            } else {
                w();
            }
        }
    }

    @SuppressLint({"ValidFragment"})
    public ScreenFragment(@NotNull i screenView) {
        Intrinsics.checkNotNullParameter(screenView, "screenView");
        this.e = new ArrayList();
        this.g = -1.0f;
        this.h = true;
        this.i = true;
        D(screenView);
    }
}