正在查看: Vi App v10.18.0 应用的 ScreenStackFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Vi App v10.18.0 应用的 ScreenStackFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.swmansion.rnscreens;
import android.annotation.SuppressLint;
import android.content.Context;
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.facebook.react.uimanager.PixelUtil;
import com.google.android.material.appbar.AppBarLayout;
import com.swmansion.rnscreens.ScreenStackFragment;
import com.swmansion.rnscreens.ScreenStackHeaderSubview;
import com.swmansion.rnscreens.utils.DeviceUtils;
import in.juspay.hyper.constants.LogCategory;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@SourceDebugExtension({"SMAP\nScreenStackFragment.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ScreenStackFragment.kt\ncom/swmansion/rnscreens/ScreenStackFragment\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,283:1\n1#2:284\n*E\n"})
public final class ScreenStackFragment extends ScreenFragment implements ScreenStackFragmentWrapper {
@Nullable
private AppBarLayout mAppBarLayout;
private boolean mIsTranslucent;
@Nullable
private View mLastFocusedChild;
private boolean mShadowHidden;
@Nullable
private Toolbar mToolbar;
@Nullable
private Function1<? super CustomSearchView, Unit> onSearchViewCreate;
@Nullable
private CustomSearchView searchView;
public static final class ScreensAnimation extends Animation {
@NotNull
private final ScreenFragment mFragment;
public ScreensAnimation(@NotNull ScreenFragment screenFragment) {
Intrinsics.checkNotNullParameter(screenFragment, "mFragment");
this.mFragment = screenFragment;
}
@Override
public void applyTransformation(float f2, @NotNull Transformation transformation) {
Intrinsics.checkNotNullParameter(transformation, "t");
super.applyTransformation(f2, transformation);
this.mFragment.dispatchTransitionProgressEvent(f2, !r3.isResumed());
}
}
@SourceDebugExtension({"SMAP\nScreenStackFragment.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ScreenStackFragment.kt\ncom/swmansion/rnscreens/ScreenStackFragment$ScreensCoordinatorLayout\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,283:1\n1#2:284\n*E\n"})
public static final class ScreensCoordinatorLayout extends CoordinatorLayout {
@NotNull
private final Animation.AnimationListener mAnimationListener;
@NotNull
private final ScreenFragment mFragment;
public ScreensCoordinatorLayout(@NotNull Context context, @NotNull ScreenFragment screenFragment) {
super(context);
Intrinsics.checkNotNullParameter(context, LogCategory.CONTEXT);
Intrinsics.checkNotNullParameter(screenFragment, "mFragment");
this.mFragment = screenFragment;
this.mAnimationListener = new Animation.AnimationListener() {
@Override
public void onAnimationEnd(@NotNull Animation animation) {
ScreenFragment screenFragment2;
Intrinsics.checkNotNullParameter(animation, "animation");
screenFragment2 = ScreenStackFragment.ScreensCoordinatorLayout.this.mFragment;
screenFragment2.onViewAnimationEnd();
}
@Override
public void onAnimationRepeat(@NotNull Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
}
@Override
public void onAnimationStart(@NotNull Animation animation) {
ScreenFragment screenFragment2;
Intrinsics.checkNotNullParameter(animation, "animation");
screenFragment2 = ScreenStackFragment.ScreensCoordinatorLayout.this.mFragment;
screenFragment2.onViewAnimationStart();
}
};
}
public void clearFocus() {
if (getVisibility() != 4) {
super/*android.view.ViewGroup*/.clearFocus();
}
}
public void startAnimation(@NotNull Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
ScreensAnimation screensAnimation = new ScreensAnimation(this.mFragment);
screensAnimation.setDuration(animation.getDuration());
if ((animation instanceof AnimationSet) && !this.mFragment.isRemoving()) {
AnimationSet animationSet = (AnimationSet) animation;
animationSet.addAnimation(screensAnimation);
animationSet.setAnimationListener(this.mAnimationListener);
super/*android.view.ViewGroup*/.startAnimation(animationSet);
return;
}
AnimationSet animationSet2 = new AnimationSet(true);
animationSet2.addAnimation(animation);
animationSet2.addAnimation(screensAnimation);
animationSet2.setAnimationListener(this.mAnimationListener);
super/*android.view.ViewGroup*/.startAnimation(animationSet2);
}
}
@SuppressLint({"ValidFragment"})
public ScreenStackFragment(@NotNull Screen screen) {
super(screen);
Intrinsics.checkNotNullParameter(screen, "screenView");
}
private final View findLastFocusedChild() {
View screen = getScreen();
while (screen != null) {
if (screen.isFocused()) {
return screen;
}
screen = screen instanceof ViewGroup ? ((ViewGroup) screen).getFocusedChild() : null;
}
return null;
}
private final void notifyViewAppearTransitionEnd() {
View view = getView();
ViewParent parent = view != null ? view.getParent() : null;
if (parent instanceof ScreenStack) {
((ScreenStack) parent).onViewAppearTransitionEnd();
}
}
private final boolean shouldShowSearchBar() {
ScreenStackHeaderConfig headerConfig = getScreen().getHeaderConfig();
int configSubviewsCount = headerConfig != null ? headerConfig.getConfigSubviewsCount() : 0;
if (headerConfig != null && configSubviewsCount > 0) {
for (int i2 = 0; i2 < configSubviewsCount; i2++) {
if (headerConfig.getConfigSubview(i2).getType() == ScreenStackHeaderSubview.Type.SEARCH_BAR) {
return true;
}
}
}
return false;
}
private final void updateToolbarMenu(Menu menu) {
menu.clear();
if (shouldShowSearchBar()) {
Context context = getContext();
if (this.searchView == null && context != null) {
CustomSearchView customSearchView = new CustomSearchView(context, this);
this.searchView = customSearchView;
Function1<? super CustomSearchView, Unit> function1 = this.onSearchViewCreate;
if (function1 != null) {
function1.invoke(customSearchView);
}
}
MenuItem add = menu.add("");
add.setShowAsAction(2);
add.setActionView((View) this.searchView);
}
}
public boolean canNavigateBack() {
ScreenContainer container = getScreen().getContainer();
if (!(container instanceof ScreenStack)) {
throw new IllegalStateException("ScreenStackFragment added into a non-stack container".toString());
}
if (!Intrinsics.areEqual(((ScreenStack) container).getRootScreen(), getScreen())) {
return true;
}
Fragment parentFragment = getParentFragment();
if (parentFragment instanceof ScreenStackFragment) {
return ((ScreenStackFragment) parentFragment).canNavigateBack();
}
return false;
}
public void dismiss() {
ScreenContainer container = getScreen().getContainer();
if (!(container instanceof ScreenStack)) {
throw new IllegalStateException("ScreenStackFragment added into a non-stack container".toString());
}
((ScreenStack) container).dismiss(this);
}
@Nullable
public final CustomSearchView getSearchView() {
return this.searchView;
}
@Override
public void onContainerUpdate() {
ScreenStackHeaderConfig headerConfig = getScreen().getHeaderConfig();
if (headerConfig != null) {
headerConfig.onUpdate();
}
}
public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater menuInflater) {
Intrinsics.checkNotNullParameter(menu, "menu");
Intrinsics.checkNotNullParameter(menuInflater, "inflater");
updateToolbarMenu(menu);
super.onCreateOptionsMenu(menu, menuInflater);
}
@Override
@Nullable
public View onCreateView(@NotNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
AppBarLayout appBarLayout;
AppBarLayout appBarLayout2;
Intrinsics.checkNotNullParameter(layoutInflater, "inflater");
Context context = getContext();
View view = null;
CoordinatorLayout screensCoordinatorLayout = context != null ? new ScreensCoordinatorLayout(context, this) : null;
Screen screen = getScreen();
CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(-1, -1);
layoutParams.setBehavior(this.mIsTranslucent ? null : new AppBarLayout.ScrollingViewBehavior());
screen.setLayoutParams(layoutParams);
if (screensCoordinatorLayout != null) {
screensCoordinatorLayout.addView(ScreenFragment.recycleView(getScreen()));
}
Context context2 = getContext();
if (context2 != null) {
view = new AppBarLayout(context2);
view.setBackgroundColor(0);
view.setLayoutParams(new AppBarLayout.LayoutParams(-1, -2));
}
this.mAppBarLayout = view;
if (screensCoordinatorLayout != null) {
screensCoordinatorLayout.addView(view);
}
if (this.mShadowHidden && (appBarLayout2 = this.mAppBarLayout) != null) {
appBarLayout2.setTargetElevation(0.0f);
}
Toolbar toolbar = this.mToolbar;
if (toolbar != null && (appBarLayout = this.mAppBarLayout) != null) {
appBarLayout.addView(ScreenFragment.recycleView(toolbar));
}
setHasOptionsMenu(true);
return screensCoordinatorLayout;
}
public void onPrepareOptionsMenu(@NotNull Menu menu) {
Intrinsics.checkNotNullParameter(menu, "menu");
updateToolbarMenu(menu);
super.onPrepareOptionsMenu(menu);
}
public void onStart() {
View view = this.mLastFocusedChild;
if (view != null) {
view.requestFocus();
}
super.onStart();
}
public void onStop() {
if (DeviceUtils.INSTANCE.isPlatformAndroidTV(getContext())) {
this.mLastFocusedChild = findLastFocusedChild();
}
super.onStop();
}
@Override
public void onViewAnimationEnd() {
super.onViewAnimationEnd();
notifyViewAppearTransitionEnd();
}
public void removeToolbar() {
Toolbar toolbar;
AppBarLayout appBarLayout = this.mAppBarLayout;
if (appBarLayout != null && (toolbar = this.mToolbar) != null && toolbar.getParent() == appBarLayout) {
appBarLayout.removeView(toolbar);
}
this.mToolbar = null;
}
public final void setOnSearchViewCreate(@Nullable Function1<? super CustomSearchView, Unit> function1) {
this.onSearchViewCreate = function1;
}
public void setToolbar(@NotNull Toolbar toolbar) {
Intrinsics.checkNotNullParameter(toolbar, "toolbar");
AppBarLayout appBarLayout = this.mAppBarLayout;
if (appBarLayout != null) {
appBarLayout.addView(toolbar);
}
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(-1, -2);
layoutParams.setScrollFlags(0);
toolbar.setLayoutParams(layoutParams);
this.mToolbar = toolbar;
}
public void setToolbarShadowHidden(boolean z) {
if (this.mShadowHidden != z) {
AppBarLayout appBarLayout = this.mAppBarLayout;
if (appBarLayout != null) {
appBarLayout.setTargetElevation(z ? 0.0f : PixelUtil.toPixelFromDIP(4.0f));
}
this.mShadowHidden = z;
}
}
public void setToolbarTranslucent(boolean z) {
if (this.mIsTranslucent != z) {
CoordinatorLayout.LayoutParams layoutParams = getScreen().getLayoutParams();
Intrinsics.checkNotNull(layoutParams, "null cannot be cast to non-null type androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams");
layoutParams.setBehavior(z ? null : new AppBarLayout.ScrollingViewBehavior());
this.mIsTranslucent = z;
}
}
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.");
}
}