正在查看: Bedrock Radio v1.1.1 应用的 ScreenStackFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Bedrock Radio v1.1.1 应用的 ScreenStackFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.swmansion.rnscreens;
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.ScreenFragment;
import com.swmansion.rnscreens.ScreenStackFragment;
import com.swmansion.rnscreens.ScreenStackHeaderSubview;
import com.swmansion.rnscreens.utils.DeviceUtils;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u0000j\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0007\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\u000f\u0018\u00002\u00020\u00012\u00020\u0002:\u0002;<B\u000f\b\u0017\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005B\u0007\b\u0016¢\u0006\u0002\u0010\u0006J\b\u0010\u001f\u001a\u00020\nH\u0016J\b\u0010 \u001a\u00020\u0014H\u0016J\n\u0010!\u001a\u0004\u0018\u00010\rH\u0002J\b\u0010\"\u001a\u00020\u0014H\u0002J\b\u0010#\u001a\u00020\u0014H\u0016J\u0018\u0010$\u001a\u00020\u00142\u0006\u0010%\u001a\u00020&2\u0006\u0010'\u001a\u00020(H\u0016J&\u0010)\u001a\u0004\u0018\u00010\r2\u0006\u0010'\u001a\u00020*2\b\u0010+\u001a\u0004\u0018\u00010,2\b\u0010-\u001a\u0004\u0018\u00010.H\u0016J\u0010\u0010/\u001a\u00020\u00142\u0006\u0010%\u001a\u00020&H\u0016J\b\u00100\u001a\u00020\u0014H\u0016J\b\u00101\u001a\u00020\u0014H\u0016J\b\u00102\u001a\u00020\u0014H\u0016J\b\u00103\u001a\u00020\u0014H\u0016J\u0010\u00104\u001a\u00020\u00142\u0006\u0010\u001d\u001a\u00020\u001eH\u0016J\u0010\u00105\u001a\u00020\u00142\u0006\u00106\u001a\u00020\nH\u0016J\u0010\u00107\u001a\u00020\u00142\u0006\u00108\u001a\u00020\nH\u0016J\b\u00109\u001a\u00020\nH\u0002J\u0010\u0010:\u001a\u00020\u00142\u0006\u0010%\u001a\u00020&H\u0002R\u0010\u0010\u0007\u001a\u0004\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R7\u0010\u000e\u001a\u001f\u0012\u0013\u0012\u00110\u0010¢\u0006\f\b\u0011\u0012\b\b\u0012\u0012\u0004\b\b(\u0013\u0012\u0004\u0012\u00020\u0014\u0018\u00010\u000fX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0015\u0010\u0016\"\u0004\b\u0017\u0010\u0018R\u001c\u0010\u0013\u001a\u0004\u0018\u00010\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\u0010\u0010\u001d\u001a\u0004\u0018\u00010\u001eX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006="}, d2 = {"Lcom/swmansion/rnscreens/ScreenStackFragment;", "Lcom/swmansion/rnscreens/ScreenFragment;", "Lcom/swmansion/rnscreens/ScreenStackFragmentWrapper;", "screenView", "Lcom/swmansion/rnscreens/Screen;", "(Lcom/swmansion/rnscreens/Screen;)V", "()V", "appBarLayout", "Lcom/google/android/material/appbar/AppBarLayout;", "isToolbarShadowHidden", "", "isToolbarTranslucent", "lastFocusedChild", "Landroid/view/View;", "onSearchViewCreate", "Lkotlin/Function1;", "Lcom/swmansion/rnscreens/CustomSearchView;", "Lkotlin/ParameterName;", "name", "searchView", "", "getOnSearchViewCreate", "()Lkotlin/jvm/functions/Function1;", "setOnSearchViewCreate", "(Lkotlin/jvm/functions/Function1;)V", "getSearchView", "()Lcom/swmansion/rnscreens/CustomSearchView;", "setSearchView", "(Lcom/swmansion/rnscreens/CustomSearchView;)V", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "canNavigateBack", "dismiss", "findLastFocusedChild", "notifyViewAppearTransitionEnd", "onContainerUpdate", "onCreateOptionsMenu", "menu", "Landroid/view/Menu;", "inflater", "Landroid/view/MenuInflater;", "onCreateView", "Landroid/view/LayoutInflater;", "container", "Landroid/view/ViewGroup;", "savedInstanceState", "Landroid/os/Bundle;", "onPrepareOptionsMenu", "onStart", "onStop", "onViewAnimationEnd", "removeToolbar", "setToolbar", "setToolbarShadowHidden", "hidden", "setToolbarTranslucent", "translucent", "shouldShowSearchBar", "updateToolbarMenu", "ScreensAnimation", "ScreensCoordinatorLayout", "react-native-screens_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class ScreenStackFragment extends ScreenFragment implements ScreenStackFragmentWrapper {
private AppBarLayout appBarLayout;
private boolean isToolbarShadowHidden;
private boolean isToolbarTranslucent;
private View lastFocusedChild;
private Function1<? super CustomSearchView, Unit> onSearchViewCreate;
private CustomSearchView searchView;
private Toolbar toolbar;
public final CustomSearchView getSearchView() {
return this.searchView;
}
public final void setSearchView(CustomSearchView customSearchView) {
this.searchView = customSearchView;
}
public final Function1<CustomSearchView, Unit> getOnSearchViewCreate() {
return this.onSearchViewCreate;
}
public final void setOnSearchViewCreate(Function1<? super CustomSearchView, Unit> function1) {
this.onSearchViewCreate = function1;
}
public ScreenStackFragment(Screen screenView) {
super(screenView);
Intrinsics.checkNotNullParameter(screenView, "screenView");
}
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.");
}
@Override
public void removeToolbar() {
Toolbar toolbar;
AppBarLayout appBarLayout = this.appBarLayout;
if (appBarLayout != null && (toolbar = this.toolbar) != null && toolbar.getParent() == appBarLayout) {
appBarLayout.removeView((View) toolbar);
}
this.toolbar = null;
}
@Override
public void setToolbar(Toolbar toolbar) {
Intrinsics.checkNotNullParameter(toolbar, "toolbar");
AppBarLayout appBarLayout = this.appBarLayout;
if (appBarLayout != null) {
appBarLayout.addView((View) toolbar);
}
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(-1, -2);
layoutParams.setScrollFlags(0);
toolbar.setLayoutParams(layoutParams);
this.toolbar = toolbar;
}
@Override
public void setToolbarShadowHidden(boolean hidden) {
if (this.isToolbarShadowHidden != hidden) {
AppBarLayout appBarLayout = this.appBarLayout;
if (appBarLayout != null) {
appBarLayout.setTargetElevation(hidden ? 0.0f : PixelUtil.toPixelFromDIP(4.0f));
}
this.isToolbarShadowHidden = hidden;
}
}
@Override
public void setToolbarTranslucent(boolean translucent) {
if (this.isToolbarTranslucent != translucent) {
CoordinatorLayout.LayoutParams 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;
}
}
@Override
public void onContainerUpdate() {
super.onContainerUpdate();
ScreenStackHeaderConfig headerConfig = getScreen().getHeaderConfig();
if (headerConfig != null) {
headerConfig.onUpdate();
}
}
@Override
public void onViewAnimationEnd() {
super.onViewAnimationEnd();
notifyViewAppearTransitionEnd();
}
private final void notifyViewAppearTransitionEnd() {
View view = getView();
ViewParent parent = view != null ? view.getParent() : null;
if (parent instanceof ScreenStack) {
((ScreenStack) parent).onViewAppearTransitionEnd();
}
}
public void onStart() {
View view = this.lastFocusedChild;
if (view != null) {
view.requestFocus();
}
super.onStart();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
AppBarLayout appBarLayout;
AppBarLayout appBarLayout2;
Intrinsics.checkNotNullParameter(inflater, "inflater");
Context context = getContext();
AppBarLayout appBarLayout3 = null;
ScreensCoordinatorLayout screensCoordinatorLayout = context != null ? new ScreensCoordinatorLayout(context, this) : 0;
Screen screen = getScreen();
CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(-1, -1);
layoutParams.setBehavior(this.isToolbarTranslucent ? null : new AppBarLayout.ScrollingViewBehavior());
screen.setLayoutParams((ViewGroup.LayoutParams) layoutParams);
if (screensCoordinatorLayout != 0) {
ScreenFragment.Companion companion = ScreenFragment.INSTANCE;
screensCoordinatorLayout.addView(ScreenFragment.recycleView(getScreen()));
}
Context context2 = getContext();
if (context2 != null) {
appBarLayout3 = new AppBarLayout(context2);
appBarLayout3.setBackgroundColor(0);
appBarLayout3.setLayoutParams(new AppBarLayout.LayoutParams(-1, -2));
}
this.appBarLayout = appBarLayout3;
if (screensCoordinatorLayout != 0) {
screensCoordinatorLayout.addView(appBarLayout3);
}
if (this.isToolbarShadowHidden && (appBarLayout2 = this.appBarLayout) != null) {
appBarLayout2.setTargetElevation(0.0f);
}
View view = this.toolbar;
if (view != null && (appBarLayout = this.appBarLayout) != null) {
ScreenFragment.Companion companion2 = ScreenFragment.INSTANCE;
appBarLayout.addView(ScreenFragment.recycleView(view));
}
setHasOptionsMenu(true);
return (View) screensCoordinatorLayout;
}
public void onStop() {
if (DeviceUtils.INSTANCE.isPlatformAndroidTV(getContext())) {
this.lastFocusedChild = findLastFocusedChild();
}
super.onStop();
}
public void onPrepareOptionsMenu(Menu menu) {
Intrinsics.checkNotNullParameter(menu, "menu");
updateToolbarMenu(menu);
super.onPrepareOptionsMenu(menu);
}
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Intrinsics.checkNotNullParameter(menu, "menu");
Intrinsics.checkNotNullParameter(inflater, "inflater");
updateToolbarMenu(menu);
super.onCreateOptionsMenu(menu, inflater);
}
private final boolean shouldShowSearchBar() {
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.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);
}
}
private final View findLastFocusedChild() {
Screen screen = getScreen();
while (screen != null) {
if (screen.isFocused()) {
return screen;
}
screen = screen instanceof ViewGroup ? ((ViewGroup) screen).getFocusedChild() : null;
}
return null;
}
@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);
}
@Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\b\u0010\t\u001a\u00020\nH\u0016J\u0010\u0010\u000b\u001a\u00020\n2\u0006\u0010\f\u001a\u00020\rH\u0016R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lcom/swmansion/rnscreens/ScreenStackFragment$ScreensCoordinatorLayout;", "Landroidx/coordinatorlayout/widget/CoordinatorLayout;", "context", "Landroid/content/Context;", "mFragment", "Lcom/swmansion/rnscreens/ScreenFragment;", "(Landroid/content/Context;Lcom/swmansion/rnscreens/ScreenFragment;)V", "mAnimationListener", "Landroid/view/animation/Animation$AnimationListener;", "clearFocus", "", "startAnimation", "animation", "Landroid/view/animation/Animation;", "react-native-screens_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
static final class ScreensCoordinatorLayout extends CoordinatorLayout {
private final Animation.AnimationListener mAnimationListener;
private final ScreenFragment mFragment;
public ScreensCoordinatorLayout(Context context, ScreenFragment mFragment) {
super(context);
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(mFragment, "mFragment");
this.mFragment = mFragment;
this.mAnimationListener = new Animation.AnimationListener() {
@Override
public void onAnimationRepeat(Animation animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
}
@Override
public void onAnimationStart(Animation animation) {
ScreenFragment screenFragment;
Intrinsics.checkNotNullParameter(animation, "animation");
screenFragment = ScreenStackFragment.ScreensCoordinatorLayout.this.mFragment;
screenFragment.onViewAnimationStart();
}
@Override
public void onAnimationEnd(Animation animation) {
ScreenFragment screenFragment;
Intrinsics.checkNotNullParameter(animation, "animation");
screenFragment = ScreenStackFragment.ScreensCoordinatorLayout.this.mFragment;
screenFragment.onViewAnimationEnd();
}
};
}
public void startAnimation(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.startAnimation(animationSet);
return;
}
AnimationSet animationSet2 = new AnimationSet(true);
animationSet2.addAnimation(animation);
animationSet2.addAnimation(screensAnimation);
animationSet2.setAnimationListener(this.mAnimationListener);
super.startAnimation(animationSet2);
}
public void clearFocus() {
if (getVisibility() != 4) {
super.clearFocus();
}
}
}
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0007\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u0018\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0014R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000b"}, d2 = {"Lcom/swmansion/rnscreens/ScreenStackFragment$ScreensAnimation;", "Landroid/view/animation/Animation;", "mFragment", "Lcom/swmansion/rnscreens/ScreenFragment;", "(Lcom/swmansion/rnscreens/ScreenFragment;)V", "applyTransformation", "", "interpolatedTime", "", "t", "Landroid/view/animation/Transformation;", "react-native-screens_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
private static final class ScreensAnimation extends Animation {
private final ScreenFragment mFragment;
public ScreensAnimation(ScreenFragment mFragment) {
Intrinsics.checkNotNullParameter(mFragment, "mFragment");
this.mFragment = mFragment;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
Intrinsics.checkNotNullParameter(t, "t");
super.applyTransformation(interpolatedTime, t);
this.mFragment.dispatchTransitionProgressEvent(interpolatedTime, !r3.isResumed());
}
}
}