正在查看: Pulsar v1.0.0 应用的 ScreenStackFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Pulsar v1.0.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.ScreenStackHeaderSubview;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.p1;
import org.jetbrains.annotations.NotNull;
@p1({"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,285:1\n1#2:286\n*E\n"})
@Metadata(d1 = {"\u0000p\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0007\u0018\u00002\u00020\u00012\u00020\u0002:\u0002IJB\u0011\b\u0017\u0012\u0006\u0010E\u001a\u00020D¢\u0006\u0004\bF\u0010GB\t\b\u0016¢\u0006\u0004\bF\u0010HJ\b\u0010\u0004\u001a\u00020\u0003H\u0002J\b\u0010\u0006\u001a\u00020\u0005H\u0002J\u0010\u0010\t\u001a\u00020\u00032\u0006\u0010\b\u001a\u00020\u0007H\u0002J\n\u0010\u000b\u001a\u0004\u0018\u00010\nH\u0002J\b\u0010\f\u001a\u00020\u0003H\u0016J\u0010\u0010\u000f\u001a\u00020\u00032\u0006\u0010\u000e\u001a\u00020\rH\u0016J\u0010\u0010\u0011\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u0005H\u0016J\u0010\u0010\u0013\u001a\u00020\u00032\u0006\u0010\u0012\u001a\u00020\u0005H\u0016J\b\u0010\u0014\u001a\u00020\u0003H\u0016J\b\u0010\u0015\u001a\u00020\u0003H\u0016J\b\u0010\u0016\u001a\u00020\u0003H\u0016J&\u0010\u001d\u001a\u0004\u0018\u00010\n2\u0006\u0010\u0018\u001a\u00020\u00172\b\u0010\u001a\u001a\u0004\u0018\u00010\u00192\b\u0010\u001c\u001a\u0004\u0018\u00010\u001bH\u0016J\b\u0010\u001e\u001a\u00020\u0003H\u0016J\u0010\u0010\u001f\u001a\u00020\u00032\u0006\u0010\b\u001a\u00020\u0007H\u0016J\u0018\u0010!\u001a\u00020\u00032\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\u0018\u001a\u00020 H\u0016J\b\u0010\"\u001a\u00020\u0005H\u0016J\b\u0010#\u001a\u00020\u0003H\u0016R\u0018\u0010'\u001a\u0004\u0018\u00010$8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b%\u0010&R\u0018\u0010\u000e\u001a\u0004\u0018\u00010\r8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b(\u0010)R\u0016\u0010,\u001a\u00020\u00058\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b*\u0010+R\u0016\u0010.\u001a\u00020\u00058\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b-\u0010+R\u0018\u00101\u001a\u0004\u0018\u00010\n8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b/\u00100R$\u00109\u001a\u0004\u0018\u0001028\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b3\u00104\u001a\u0004\b5\u00106\"\u0004\b7\u00108R?\u0010C\u001a\u001f\u0012\u0013\u0012\u001102¢\u0006\f\b;\u0012\b\b<\u0012\u0004\b\b(9\u0012\u0004\u0012\u00020\u0003\u0018\u00010:8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b=\u0010>\u001a\u0004\b?\u0010@\"\u0004\bA\u0010B¨\u0006K"}, d2 = {"Lcom/swmansion/rnscreens/ScreenStackFragment;", "Lcom/swmansion/rnscreens/ScreenFragment;", "Lcom/swmansion/rnscreens/m;", "", "k", "", "l", "Landroid/view/Menu;", "menu", "m", "Landroid/view/View;", "j", "removeToolbar", "Landroidx/appcompat/widget/Toolbar;", "toolbar", "setToolbar", "hidden", "setToolbarShadowHidden", "translucent", "setToolbarTranslucent", "onContainerUpdate", "onViewAnimationEnd", "onStart", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "onCreateView", "onStop", "onPrepareOptionsMenu", "Landroid/view/MenuInflater;", "onCreateOptionsMenu", "canNavigateBack", "dismiss", "Lcom/google/android/material/appbar/AppBarLayout;", "n", "Lcom/google/android/material/appbar/AppBarLayout;", "appBarLayout", "s", "Landroidx/appcompat/widget/Toolbar;", "t", "Z", "isToolbarShadowHidden", "u", "isToolbarTranslucent", "v", "Landroid/view/View;", "lastFocusedChild", "Lcom/swmansion/rnscreens/CustomSearchView;", "w", "Lcom/swmansion/rnscreens/CustomSearchView;", "getSearchView", "()Lcom/swmansion/rnscreens/CustomSearchView;", "setSearchView", "(Lcom/swmansion/rnscreens/CustomSearchView;)V", "searchView", "Lkotlin/Function1;", "Lkotlin/t0;", "name", "X", "Lkotlin/jvm/functions/Function1;", "getOnSearchViewCreate", "()Lkotlin/jvm/functions/Function1;", "setOnSearchViewCreate", "(Lkotlin/jvm/functions/Function1;)V", "onSearchViewCreate", "Lcom/swmansion/rnscreens/Screen;", "screenView", "<init>", "(Lcom/swmansion/rnscreens/Screen;)V", "()V", "a", "ScreensCoordinatorLayout", "react-native-screens_release"}, k = 1, mv = {1, 9, 0})
public final class ScreenStackFragment extends ScreenFragment implements m {
@f8.d
private Function1<? super CustomSearchView, Unit> onSearchViewCreate;
@f8.d
private AppBarLayout appBarLayout;
@f8.d
private Toolbar toolbar;
private boolean isToolbarShadowHidden;
private boolean isToolbarTranslucent;
@f8.d
private View lastFocusedChild;
@f8.d
private CustomSearchView searchView;
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0002\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\u0010\u001a\u00020\u000f\u0012\u0006\u0010\n\u001a\u00020\u0007¢\u0006\u0004\b\u0011\u0010\u0012J\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\b\u0010\u0006\u001a\u00020\u0004H\u0016R\u0014\u0010\n\u001a\u00020\u00078\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\b\u0010\tR\u0014\u0010\u000e\u001a\u00020\u000b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\f\u0010\r¨\u0006\u0013"}, d2 = {"Lcom/swmansion/rnscreens/ScreenStackFragment$ScreensCoordinatorLayout;", "Landroidx/coordinatorlayout/widget/CoordinatorLayout;", "Landroid/view/animation/Animation;", "animation", "", "startAnimation", "clearFocus", "Lcom/swmansion/rnscreens/ScreenFragment;", "q0", "Lcom/swmansion/rnscreens/ScreenFragment;", "mFragment", "Landroid/view/animation/Animation$AnimationListener;", "r0", "Landroid/view/animation/Animation$AnimationListener;", "mAnimationListener", "Landroid/content/Context;", "context", "<init>", "(Landroid/content/Context;Lcom/swmansion/rnscreens/ScreenFragment;)V", "react-native-screens_release"}, k = 1, mv = {1, 9, 0})
@p1({"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,285:1\n1#2:286\n*E\n"})
private static final class ScreensCoordinatorLayout extends CoordinatorLayout {
@NotNull
private final ScreenFragment mFragment;
@NotNull
private final Animation.AnimationListener mAnimationListener;
public static final class a implements Animation.AnimationListener {
a() {
}
@Override
public void onAnimationEnd(@NotNull Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
ScreensCoordinatorLayout.this.mFragment.onViewAnimationEnd();
}
@Override
public void onAnimationRepeat(@NotNull Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
}
@Override
public void onAnimationStart(@NotNull Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
ScreensCoordinatorLayout.this.mFragment.onViewAnimationStart();
}
}
public ScreensCoordinatorLayout(@NotNull Context context, @NotNull ScreenFragment mFragment) {
super(context);
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(mFragment, "mFragment");
this.mFragment = mFragment;
this.mAnimationListener = new a();
}
public void clearFocus() {
if (getVisibility() != 4) {
super/*android.view.ViewGroup*/.clearFocus();
}
}
public void startAnimation(@NotNull Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
a aVar = new a(this.mFragment);
aVar.setDuration(animation.getDuration());
if ((animation instanceof AnimationSet) && !this.mFragment.isRemoving()) {
AnimationSet animationSet = (AnimationSet) animation;
animationSet.addAnimation(aVar);
animationSet.setAnimationListener(this.mAnimationListener);
super/*android.view.ViewGroup*/.startAnimation(animationSet);
return;
}
AnimationSet animationSet2 = new AnimationSet(true);
animationSet2.addAnimation(animation);
animationSet2.addAnimation(aVar);
animationSet2.setAnimationListener(this.mAnimationListener);
super/*android.view.ViewGroup*/.startAnimation(animationSet2);
}
}
private static final class a extends Animation {
@NotNull
private final ScreenFragment a;
public a(@NotNull ScreenFragment mFragment) {
Intrinsics.checkNotNullParameter(mFragment, "mFragment");
this.a = mFragment;
}
@Override
protected void applyTransformation(float f, @NotNull Transformation t) {
Intrinsics.checkNotNullParameter(t, "t");
super.applyTransformation(f, t);
this.a.dispatchTransitionProgressEvent(f, !r3.isResumed());
}
}
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.");
}
private final View j() {
View screen = getScreen();
while (screen != null) {
if (screen.isFocused()) {
return screen;
}
screen = screen instanceof ViewGroup ? ((ViewGroup) screen).getFocusedChild() : null;
}
return null;
}
private final void k() {
View view = getView();
ViewParent parent = view != null ? view.getParent() : null;
if (parent instanceof ScreenStack) {
((ScreenStack) parent).onViewAppearTransitionEnd();
}
}
private final boolean l() {
ScreenStackHeaderConfig headerConfig = getScreen().getHeaderConfig();
int configSubviewsCount = headerConfig != null ? headerConfig.getConfigSubviewsCount() : 0;
if (headerConfig != null && configSubviewsCount > 0) {
for (int i = 0; i < configSubviewsCount; i++) {
if (headerConfig.getConfigSubview(i).getType() == ScreenStackHeaderSubview.a.e) {
return true;
}
}
}
return false;
}
private final void m(Menu menu) {
menu.clear();
if (l()) {
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);
}
}
@Override
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;
}
@Override
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);
}
@f8.d
public final Function1<CustomSearchView, Unit> getOnSearchViewCreate() {
return this.onSearchViewCreate;
}
@f8.d
public final CustomSearchView getSearchView() {
return this.searchView;
}
@Override
public void onContainerUpdate() {
super.onContainerUpdate();
ScreenStackHeaderConfig headerConfig = getScreen().getHeaderConfig();
if (headerConfig != null) {
headerConfig.onUpdate();
}
}
public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater inflater) {
Intrinsics.checkNotNullParameter(menu, "menu");
Intrinsics.checkNotNullParameter(inflater, "inflater");
m(menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
@f8.d
public View onCreateView(@NotNull LayoutInflater inflater, @f8.d ViewGroup container, @f8.d Bundle savedInstanceState) {
AppBarLayout appBarLayout;
AppBarLayout appBarLayout2;
Intrinsics.checkNotNullParameter(inflater, "inflater");
Context context = getContext();
AppBarLayout appBarLayout3 = null;
CoordinatorLayout screensCoordinatorLayout = context != null ? new ScreensCoordinatorLayout(context, this) : null;
Screen screen = getScreen();
CoordinatorLayout.g gVar = new CoordinatorLayout.g(-1, -1);
gVar.setBehavior(this.isToolbarTranslucent ? null : new AppBarLayout.ScrollingViewBehavior());
screen.setLayoutParams(gVar);
if (screensCoordinatorLayout != null) {
screensCoordinatorLayout.addView(ScreenFragment.h(getScreen()));
}
Context context2 = getContext();
if (context2 != null) {
appBarLayout3 = new AppBarLayout(context2);
appBarLayout3.setBackgroundColor(0);
appBarLayout3.setLayoutParams(new AppBarLayout.f(-1, -2));
}
this.appBarLayout = appBarLayout3;
if (screensCoordinatorLayout != null) {
screensCoordinatorLayout.addView(appBarLayout3);
}
if (this.isToolbarShadowHidden && (appBarLayout2 = this.appBarLayout) != null) {
appBarLayout2.setElevation(0.0f);
}
Toolbar toolbar = this.toolbar;
if (toolbar != null && (appBarLayout = this.appBarLayout) != null) {
appBarLayout.addView(ScreenFragment.h(toolbar));
}
setHasOptionsMenu(true);
return screensCoordinatorLayout;
}
public void onPrepareOptionsMenu(@NotNull Menu menu) {
Intrinsics.checkNotNullParameter(menu, "menu");
m(menu);
super.onPrepareOptionsMenu(menu);
}
public void onStart() {
View view = this.lastFocusedChild;
if (view != null) {
view.requestFocus();
}
super.onStart();
}
public void onStop() {
if (p6.a.a.isPlatformAndroidTV(getContext())) {
this.lastFocusedChild = j();
}
super.onStop();
}
@Override
public void onViewAnimationEnd() {
super.onViewAnimationEnd();
k();
}
@Override
public void removeToolbar() {
Toolbar toolbar;
AppBarLayout appBarLayout = this.appBarLayout;
if (appBarLayout != null && (toolbar = this.toolbar) != null && toolbar.getParent() == appBarLayout) {
appBarLayout.removeView(toolbar);
}
this.toolbar = null;
}
public final void setOnSearchViewCreate(@f8.d Function1<? super CustomSearchView, Unit> function1) {
this.onSearchViewCreate = function1;
}
public final void setSearchView(@f8.d CustomSearchView customSearchView) {
this.searchView = customSearchView;
}
@Override
public void setToolbar(@NotNull Toolbar toolbar) {
Intrinsics.checkNotNullParameter(toolbar, "toolbar");
AppBarLayout appBarLayout = this.appBarLayout;
if (appBarLayout != null) {
appBarLayout.addView(toolbar);
}
AppBarLayout.f fVar = new AppBarLayout.f(-1, -2);
fVar.setScrollFlags(0);
toolbar.setLayoutParams(fVar);
this.toolbar = toolbar;
}
@Override
public void setToolbarShadowHidden(boolean hidden) {
if (this.isToolbarShadowHidden != hidden) {
AppBarLayout appBarLayout = this.appBarLayout;
if (appBarLayout != null) {
appBarLayout.setElevation(hidden ? 0.0f : PixelUtil.toPixelFromDIP(4.0f));
}
AppBarLayout appBarLayout2 = this.appBarLayout;
if (appBarLayout2 != null) {
appBarLayout2.setStateListAnimator(null);
}
this.isToolbarShadowHidden = hidden;
}
}
@Override
public void setToolbarTranslucent(boolean translucent) {
if (this.isToolbarTranslucent != translucent) {
CoordinatorLayout.g layoutParams = getScreen().getLayoutParams();
Intrinsics.checkNotNull(layoutParams, "null cannot be cast to non-null type androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams");
layoutParams.setBehavior(translucent ? null : new AppBarLayout.ScrollingViewBehavior());
this.isToolbarTranslucent = translucent;
}
}
@SuppressLint({"ValidFragment"})
public ScreenStackFragment(@NotNull Screen screenView) {
super(screenView);
Intrinsics.checkNotNullParameter(screenView, "screenView");
}
}