正在查看: Life Church v15.20.21 应用的 ScreenFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Life Church v15.20.21 应用的 ScreenFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.swmansion.rnscreens;
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 com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher;
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.yalantis.ucrop.view.CropImageView;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u0000l\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010!\n\u0000\n\u0002\u0010\u0007\n\u0002\b\b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u000e\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\b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0016\u0018\u0000 @2\u00020\u0001:\u0003@ABB\u0007\b\u0016¢\u0006\u0002\u0010\u0002B\u000f\b\u0017\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005J\u0010\u0010\u0019\u001a\u00020\u00072\u0006\u0010\u001a\u001a\u00020\u001bH\u0002J\u0018\u0010\u001c\u001a\u00020\u001d2\u0006\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001e\u001a\u00020\u0000H\u0002J\u0010\u0010\u001f\u001a\u00020\u001d2\u0006\u0010\u001a\u001a\u00020\u001bH\u0002J\u0006\u0010 \u001a\u00020\u001dJ\b\u0010!\u001a\u00020\u001dH\u0002J\b\u0010\"\u001a\u00020\u001dH\u0002J\b\u0010#\u001a\u00020\u001dH\u0002J\b\u0010$\u001a\u00020\u001dH\u0002J\u0016\u0010%\u001a\u00020\u001d2\u0006\u0010&\u001a\u00020\u00122\u0006\u0010'\u001a\u00020\u0007J\u0010\u0010(\u001a\u00020\u001d2\u0006\u0010)\u001a\u00020\u0007H\u0002J\b\u0010*\u001a\u00020\u001dH\u0016J&\u0010+\u001a\u0004\u0018\u00010,2\u0006\u0010-\u001a\u00020.2\b\u0010/\u001a\u0004\u0018\u0001002\b\u00101\u001a\u0004\u0018\u000102H\u0016J\b\u00103\u001a\u00020\u001dH\u0016J\b\u00104\u001a\u00020\u001dH\u0016J\b\u00105\u001a\u00020\u001dH\u0016J\u0006\u00106\u001a\u00020\u001dJ\u0012\u00107\u001a\u00020\u001d2\n\u00108\u001a\u0006\u0012\u0002\b\u00030\u000bJ\u0010\u00109\u001a\u00020\u001d2\u0006\u0010\u001a\u001a\u00020\u001bH\u0002J\b\u0010:\u001a\u0004\u0018\u00010;J\b\u0010<\u001a\u0004\u0018\u00010=J\u0012\u0010>\u001a\u00020\u001d2\n\u00108\u001a\u0006\u0012\u0002\b\u00030\u000bJ\b\u0010?\u001a\u00020\u001dH\u0002R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\t\u001a\f\u0012\b\u0012\u0006\u0012\u0002\b\u00030\u000b0\n8F¢\u0006\u0006\u001a\u0004\b\f\u0010\rR\u000e\u0010\u000e\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0018\u0010\u000f\u001a\f\u0012\b\u0012\u0006\u0012\u0002\b\u00030\u000b0\u0010X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R \u0010\u0013\u001a\u00020\u0004X\u0086.¢\u0006\u0014\n\u0000\u0012\u0004\b\u0014\u0010\u0002\u001a\u0004\b\u0015\u0010\u0016\"\u0004\b\u0017\u0010\u0005R\u000e\u0010\u0018\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006C"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment;", "Landroidx/fragment/app/Fragment;", "()V", "screenView", "Lcom/swmansion/rnscreens/Screen;", "(Lcom/swmansion/rnscreens/Screen;)V", "canDispatchAppear", "", "canDispatchWillAppear", "childScreenContainers", "", "Lcom/swmansion/rnscreens/ScreenContainer;", "getChildScreenContainers", "()Ljava/util/List;", "isTransitioning", "mChildScreenContainers", "", "mProgress", "", "screen", "getScreen$annotations", "getScreen", "()Lcom/swmansion/rnscreens/Screen;", "setScreen", "shouldUpdateOnResume", "canDispatchEvent", "event", "Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;", "dispatchEvent", "", "fragment", "dispatchEventInChildContainers", "dispatchHeaderBackButtonClickedEvent", "dispatchOnAppear", "dispatchOnDisappear", "dispatchOnWillAppear", "dispatchOnWillDisappear", "dispatchTransitionProgress", "alpha", "closing", "dispatchViewAnimationEvent", "animationEnd", "onContainerUpdate", "onCreateView", "Landroid/view/View;", "inflater", "Landroid/view/LayoutInflater;", "container", "Landroid/view/ViewGroup;", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onResume", "onViewAnimationEnd", "onViewAnimationStart", "registerChildScreenContainer", "screenContainer", "setLastEventDispatched", "tryGetActivity", "Landroid/app/Activity;", "tryGetContext", "Lcom/facebook/react/bridge/ReactContext;", "unregisterChildScreenContainer", "updateWindowTraits", "Companion", "ScreenLifecycleEvent", "ScreensFrameLayout", "react-native-screens_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public class ScreenFragment extends Fragment {
public static final Companion INSTANCE = new Companion(null);
private boolean canDispatchAppear;
private boolean canDispatchWillAppear;
private boolean isTransitioning;
private final List<ScreenContainer<?>> mChildScreenContainers;
private float mProgress;
public Screen screen;
private boolean shouldUpdateOnResume;
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0006\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004j\u0002\b\u0005j\u0002\b\u0006¨\u0006\u0007"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment$ScreenLifecycleEvent;", "", "(Ljava/lang/String;I)V", "Appear", "WillAppear", "Disappear", "WillDisappear", "react-native-screens_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public enum ScreenLifecycleEvent {
Appear,
WillAppear,
Disappear,
WillDisappear
}
@Metadata(k = 3, mv = {1, 6, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[ScreenLifecycleEvent.values().length];
iArr[ScreenLifecycleEvent.WillAppear.ordinal()] = 1;
iArr[ScreenLifecycleEvent.Appear.ordinal()] = 2;
iArr[ScreenLifecycleEvent.WillDisappear.ordinal()] = 3;
iArr[ScreenLifecycleEvent.Disappear.ordinal()] = 4;
$EnumSwitchMapping$0 = iArr;
}
}
public static void getScreen$annotations() {
}
@JvmStatic
protected static final View recycleView(View view) {
return INSTANCE.recycleView(view);
}
public final Screen getScreen() {
Screen screen = this.screen;
if (screen != null) {
return screen;
}
Intrinsics.throwUninitializedPropertyAccessException("screen");
return null;
}
public final void setScreen(Screen screen) {
Intrinsics.checkNotNullParameter(screen, "<set-?>");
this.screen = screen;
}
public ScreenFragment() {
this.mChildScreenContainers = new ArrayList();
this.mProgress = -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.");
}
public ScreenFragment(Screen screenView) {
Intrinsics.checkNotNullParameter(screenView, "screenView");
this.mChildScreenContainers = new ArrayList();
this.mProgress = -1.0f;
this.canDispatchWillAppear = true;
this.canDispatchAppear = true;
setScreen(screenView);
}
public void onResume() {
super.onResume();
if (this.shouldUpdateOnResume) {
this.shouldUpdateOnResume = false;
ScreenWindowTraits.INSTANCE.trySetWindowTraits$react_native_screens_release(getScreen(), tryGetActivity(), tryGetContext());
}
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Intrinsics.checkNotNullParameter(inflater, "inflater");
Context context = getContext();
ScreensFrameLayout screensFrameLayout = context == null ? null : new ScreensFrameLayout(context);
getScreen().setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
if (screensFrameLayout != null) {
screensFrameLayout.addView(recycleView(getScreen()));
}
return screensFrameLayout;
}
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0005\u001a\u00020\u0006H\u0016¨\u0006\u0007"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment$ScreensFrameLayout;", "Landroid/widget/FrameLayout;", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "clearFocus", "", "react-native-screens_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
private static final class ScreensFrameLayout extends FrameLayout {
public ScreensFrameLayout(Context context) {
super(context);
Intrinsics.checkNotNullParameter(context, "context");
}
@Override
public void clearFocus() {
if (getVisibility() != 4) {
super.clearFocus();
}
}
}
public void onContainerUpdate() {
updateWindowTraits();
}
private final void updateWindowTraits() {
Activity activity = getActivity();
if (activity == null) {
this.shouldUpdateOnResume = true;
} else {
ScreenWindowTraits.INSTANCE.trySetWindowTraits$react_native_screens_release(getScreen(), activity, tryGetContext());
}
}
public final Activity tryGetActivity() {
ScreenFragment fragment;
Activity activity;
Activity 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 (ScreenContainer<?> 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;
}
public final ReactContext tryGetContext() {
if (getContext() instanceof ReactContext) {
ReactContext context = getContext();
Objects.requireNonNull(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();
Objects.requireNonNull(context2, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
return context2;
}
for (ScreenContainer<?> 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();
Objects.requireNonNull(context3, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
return context3;
}
}
}
return null;
}
public final List<ScreenContainer<?>> getChildScreenContainers() {
return this.mChildScreenContainers;
}
private final boolean canDispatchEvent(ScreenLifecycleEvent event) {
int i = WhenMappings.$EnumSwitchMapping$0[event.ordinal()];
if (i == 1) {
return this.canDispatchWillAppear;
}
if (i == 2) {
return this.canDispatchAppear;
}
if (i != 3) {
if (i != 4) {
throw new NoWhenBranchMatchedException();
}
if (this.canDispatchAppear) {
return false;
}
} else if (this.canDispatchWillAppear) {
return false;
}
return true;
}
private final void setLastEventDispatched(ScreenLifecycleEvent 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) {
return;
}
this.canDispatchAppear = true;
}
}
private final void dispatchOnWillAppear() {
dispatchEvent(ScreenLifecycleEvent.WillAppear, this);
dispatchTransitionProgress(CropImageView.DEFAULT_ASPECT_RATIO, false);
}
private final void dispatchOnAppear() {
dispatchEvent(ScreenLifecycleEvent.Appear, this);
dispatchTransitionProgress(1.0f, false);
}
private final void dispatchOnWillDisappear() {
dispatchEvent(ScreenLifecycleEvent.WillDisappear, this);
dispatchTransitionProgress(CropImageView.DEFAULT_ASPECT_RATIO, true);
}
private final void dispatchOnDisappear() {
dispatchEvent(ScreenLifecycleEvent.Disappear, this);
dispatchTransitionProgress(1.0f, true);
}
private final void dispatchEvent(ScreenLifecycleEvent event, ScreenFragment fragment) {
ScreenWillAppearEvent screenWillAppearEvent;
EventDispatcher eventDispatcher;
if ((fragment instanceof ScreenStackFragment) && fragment.canDispatchEvent(event)) {
Screen screen = fragment.getScreen();
fragment.setLastEventDispatched(event);
int i = WhenMappings.$EnumSwitchMapping$0[event.ordinal()];
if (i == 1) {
screenWillAppearEvent = new ScreenWillAppearEvent(screen.getId());
} else if (i == 2) {
screenWillAppearEvent = new ScreenAppearEvent(screen.getId());
} else if (i == 3) {
screenWillAppearEvent = new ScreenWillDisappearEvent(screen.getId());
} else {
if (i != 4) {
throw new NoWhenBranchMatchedException();
}
screenWillAppearEvent = new ScreenDisappearEvent(screen.getId());
}
ReactContext context = screen.getContext();
Objects.requireNonNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
UIManagerModule nativeModule = context.getNativeModule(UIManagerModule.class);
if (nativeModule != null && (eventDispatcher = nativeModule.getEventDispatcher()) != null) {
eventDispatcher.dispatchEvent(screenWillAppearEvent);
}
fragment.dispatchEventInChildContainers(event);
}
}
private final void dispatchEventInChildContainers(ScreenLifecycleEvent event) {
Screen topScreen;
ScreenFragment fragment;
for (ScreenContainer<?> screenContainer : this.mChildScreenContainers) {
if (screenContainer.getScreenCount() > 0 && screenContainer.getTopScreen() != null && (topScreen = screenContainer.getTopScreen()) != null && (fragment = topScreen.getFragment()) != null) {
dispatchEvent(event, fragment);
}
}
}
public final void dispatchHeaderBackButtonClickedEvent() {
EventDispatcher eventDispatcher;
ReactContext context = getScreen().getContext();
Objects.requireNonNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
UIManagerModule nativeModule = context.getNativeModule(UIManagerModule.class);
if (nativeModule == null || (eventDispatcher = nativeModule.getEventDispatcher()) == null) {
return;
}
eventDispatcher.dispatchEvent(new HeaderBackButtonClickedEvent(getScreen().getId()));
}
public final void dispatchTransitionProgress(float alpha, boolean closing) {
EventDispatcher eventDispatcher;
if (this instanceof ScreenStackFragment) {
if (this.mProgress == alpha) {
return;
}
float max = Math.max(CropImageView.DEFAULT_ASPECT_RATIO, Math.min(1.0f, alpha));
this.mProgress = max;
if (!(max == CropImageView.DEFAULT_ASPECT_RATIO)) {
r1 = (max != 1.0f ? 0 : 1) != 0 ? 2 : 3;
}
short s = (short) r1;
ScreenContainer<?> container = getScreen().getContainer();
boolean goingForward = container instanceof ScreenStack ? ((ScreenStack) container).getGoingForward() : false;
ReactContext context = getScreen().getContext();
Objects.requireNonNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
UIManagerModule nativeModule = context.getNativeModule(UIManagerModule.class);
if (nativeModule == null || (eventDispatcher = nativeModule.getEventDispatcher()) == null) {
return;
}
eventDispatcher.dispatchEvent(new ScreenTransitionProgressEvent(getScreen().getId(), this.mProgress, closing, goingForward, s));
}
}
public final void registerChildScreenContainer(ScreenContainer<?> screenContainer) {
Intrinsics.checkNotNullParameter(screenContainer, "screenContainer");
this.mChildScreenContainers.add(screenContainer);
}
public final void unregisterChildScreenContainer(ScreenContainer<?> screenContainer) {
Intrinsics.checkNotNullParameter(screenContainer, "screenContainer");
this.mChildScreenContainers.remove(screenContainer);
}
public final void onViewAnimationStart() {
dispatchViewAnimationEvent(false);
}
public void onViewAnimationEnd() {
dispatchViewAnimationEvent(true);
}
private final void dispatchViewAnimationEvent(final boolean animationEnd) {
this.isTransitioning = !animationEnd;
Fragment parentFragment = getParentFragment();
if (parentFragment == null || ((parentFragment instanceof ScreenFragment) && !((ScreenFragment) parentFragment).isTransitioning)) {
if (isResumed()) {
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public final void run() {
ScreenFragment.m39dispatchViewAnimationEvent$lambda6(animationEnd, this);
}
});
} else if (animationEnd) {
dispatchOnDisappear();
} else {
dispatchOnWillDisappear();
}
}
}
public static final void m39dispatchViewAnimationEvent$lambda6(boolean z, ScreenFragment this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (z) {
this$0.dispatchOnAppear();
} else {
this$0.dispatchOnWillAppear();
}
}
public void onDestroy() {
EventDispatcher eventDispatcher;
super.onDestroy();
ScreenContainer<?> container = getScreen().getContainer();
if ((container == null || !container.hasScreen(this)) && (getScreen().getContext() instanceof ReactContext)) {
ReactContext context = getScreen().getContext();
Objects.requireNonNull(context, "null cannot be cast to non-null type com.facebook.react.bridge.ReactContext");
UIManagerModule nativeModule = context.getNativeModule(UIManagerModule.class);
if (nativeModule != null && (eventDispatcher = nativeModule.getEventDispatcher()) != null) {
eventDispatcher.dispatchEvent(new ScreenDismissedEvent(getScreen().getId()));
}
}
this.mChildScreenContainers.clear();
}
@Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0004H\u0005¨\u0006\u0006"}, d2 = {"Lcom/swmansion/rnscreens/ScreenFragment$Companion;", "", "()V", "recycleView", "Landroid/view/View;", "view", "react-native-screens_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
@JvmStatic
protected final View recycleView(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;
}
}
}