正在查看: Housing v14.7.8 应用的 ScreenDummyLayoutHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Housing v14.7.8 应用的 ScreenDummyLayoutHelper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.swmansion.rnscreens.utils;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.facebook.jni.annotations.DoNotStrip;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.PixelUtil;
import com.google.android.material.appbar.AppBarLayout;
import com.locon.reactapp.calculator.a;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.LogInstrumentation;
import com.swmansion.rnscreens.ScreenStackHeaderConfig;
import java.lang.ref.WeakReference;
import kotlin.Metadata;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.jvm.internal.r;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@DoNotStrip
@Metadata(d1 = {"\u0000z\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0001\u0018\u0000 82\u00020\u0001:\u00018B\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u0002H\u0002¢\u0006\u0004\b\u0007\u0010\bJ\u0017\u0010\f\u001a\u00020\u000b2\u0006\u0010\n\u001a\u00020\tH\u0002¢\u0006\u0004\b\f\u0010\rJ\u001f\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0010\u001a\u00020\u0006H\u0003¢\u0006\u0004\b\u0012\u0010\u0013J!\u0010\u0017\u001a\u00020\u00022\u0010\b\u0002\u0010\u0016\u001a\n\u0012\u0004\u0012\u00020\u0015\u0018\u00010\u0014H\u0002¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u001a\u001a\u00020\u0019H\u0002¢\u0006\u0004\b\u001a\u0010\u001bJ\u000f\u0010\u001c\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u001c\u0010\u001dJ\u000f\u0010\u001e\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u001e\u0010\u001dJ\u000f\u0010\u001f\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u001f\u0010\u001dR\u0016\u0010!\u001a\u00020 8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b!\u0010\"R\u0016\u0010$\u001a\u00020#8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b$\u0010%R\u0016\u0010'\u001a\u00020&8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b'\u0010(R\u0016\u0010*\u001a\u00020)8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b*\u0010+R\u0016\u0010,\u001a\u00020\u00118\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b,\u0010-R\u0016\u0010.\u001a\u00020\u000e8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b.\u0010/R\u0016\u00101\u001a\u0002008\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b1\u00102R\u001c\u00104\u001a\b\u0012\u0004\u0012\u00020\u0002038\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b4\u00105R\u0016\u00106\u001a\u00020\u00068\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b6\u00107¨\u00069"}, d2 = {"Lcom/swmansion/rnscreens/utils/ScreenDummyLayoutHelper;", "Lcom/facebook/react/bridge/LifecycleEventListener;", "Lcom/facebook/react/bridge/ReactApplicationContext;", "reactContext", "<init>", "(Lcom/facebook/react/bridge/ReactApplicationContext;)V", "", "maybeInitDummyLayoutWithHeader", "(Lcom/facebook/react/bridge/ReactApplicationContext;)Z", "Landroid/content/Context;", "contextWithTheme", "Lzp/j0;", "initDummyLayoutWithHeader", "(Landroid/content/Context;)V", "", "fontSize", "isTitleEmpty", "", "computeDummyLayout", "(IZ)F", "Lkotlin/Function0;", "", "lazyMessage", "requireReactContext", "(Lkq/a;)Lcom/facebook/react/bridge/ReactApplicationContext;", "Landroid/app/Activity;", "requireActivity", "()Landroid/app/Activity;", "onHostResume", "()V", "onHostPause", "onHostDestroy", "Landroidx/coordinatorlayout/widget/CoordinatorLayout;", "coordinatorLayout", "Landroidx/coordinatorlayout/widget/CoordinatorLayout;", "Lcom/google/android/material/appbar/AppBarLayout;", "appBarLayout", "Lcom/google/android/material/appbar/AppBarLayout;", "Landroid/view/View;", "dummyContentView", "Landroid/view/View;", "Landroidx/appcompat/widget/Toolbar;", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "defaultFontSize", "F", "defaultContentInsetStartWithNavigation", "I", "Lcom/swmansion/rnscreens/utils/CacheEntry;", "cache", "Lcom/swmansion/rnscreens/utils/CacheEntry;", "Ljava/lang/ref/WeakReference;", "reactContextRef", "Ljava/lang/ref/WeakReference;", "isLayoutInitialized", "Z", "Companion", "react-native-screens_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
@Instrumented
@SourceDebugExtension({"SMAP\nScreenDummyLayoutHelper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ScreenDummyLayoutHelper.kt\ncom/swmansion/rnscreens/utils/ScreenDummyLayoutHelper\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,286:1\n1#2:287\n*E\n"})
public final class ScreenDummyLayoutHelper implements LifecycleEventListener {
@NotNull
private static final String DEFAULT_HEADER_TITLE = "FontSize123!#$";
public static final int FONT_SIZE_UNSET = -1;
@NotNull
public static final String LIBRARY_NAME = "react_codegen_rnscreens";
@NotNull
public static final String TAG = "ScreenDummyLayoutHelper";
private AppBarLayout appBarLayout;
@NotNull
private CacheEntry cache;
private CoordinatorLayout coordinatorLayout;
private int defaultContentInsetStartWithNavigation;
private float defaultFontSize;
private View dummyContentView;
private volatile boolean isLayoutInitialized;
@NotNull
private WeakReference<ReactApplicationContext> reactContextRef;
private Toolbar toolbar;
@NotNull
public static final Companion INSTANCE = new Companion(null);
@NotNull
private static WeakReference<ScreenDummyLayoutHelper> weakInstance = new WeakReference<>(null);
@Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\n\u0010\r\u001a\u0004\u0018\u00010\fH\u0007R\u000e\u0010\u0004\u001a\u00020\u0005X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0005X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0005X\u0082T¢\u0006\u0002\n\u0000R\u0014\u0010\n\u001a\b\u0012\u0004\u0012\u00020\f0\u000bX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lcom/swmansion/rnscreens/utils/ScreenDummyLayoutHelper$Companion;", "", "<init>", "()V", "TAG", "", "LIBRARY_NAME", "FONT_SIZE_UNSET", "", "DEFAULT_HEADER_TITLE", "weakInstance", "Ljava/lang/ref/WeakReference;", "Lcom/swmansion/rnscreens/utils/ScreenDummyLayoutHelper;", "getInstance", "react-native-screens_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
@JvmStatic
@DoNotStrip
@Nullable
public final ScreenDummyLayoutHelper getInstance() {
return (ScreenDummyLayoutHelper) ScreenDummyLayoutHelper.weakInstance.get();
}
private Companion() {
}
}
public ScreenDummyLayoutHelper(@NotNull ReactApplicationContext reactContext) {
r.k(reactContext, "reactContext");
this.cache = CacheEntry.INSTANCE.getEMPTY();
this.reactContextRef = new WeakReference<>(reactContext);
try {
System.loadLibrary(LIBRARY_NAME);
} catch (UnsatisfiedLinkError unused) {
LogInstrumentation.w(TAG, "[RNScreens] Failed to load react_codegen_rnscreens library.");
}
weakInstance = new WeakReference<>(this);
if (reactContext.hasCurrentActivity() && maybeInitDummyLayoutWithHeader(reactContext)) {
return;
}
reactContext.addLifecycleEventListener(this);
}
@DoNotStrip
private final float computeDummyLayout(int fontSize, boolean isTitleEmpty) {
if (!this.isLayoutInitialized && !maybeInitDummyLayoutWithHeader(requireReactContext(new a(22)))) {
LogInstrumentation.e(TAG, "[RNScreens] Failed to late-init layout while computing header height. This is most likely a race-condition-bug in react-native-screens, please file an issue at https://github.com/software-mansion/react-native-screens/issues");
return 0.0f;
}
if (this.cache.hasKey(new CacheKey(fontSize, isTitleEmpty))) {
return this.cache.getHeaderHeight();
}
View decorView = requireActivity().getWindow().getDecorView();
r.j(decorView, "getDecorView(...)");
int width = decorView.getWidth();
int height = decorView.getHeight();
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, 1073741824);
int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(height, 1073741824);
if (isTitleEmpty) {
Toolbar toolbar = this.toolbar;
if (toolbar == null) {
r.o("toolbar");
throw null;
}
toolbar.setTitle("");
Toolbar toolbar2 = this.toolbar;
if (toolbar2 == null) {
r.o("toolbar");
throw null;
}
toolbar2.setContentInsetStartWithNavigation(0);
} else {
Toolbar toolbar3 = this.toolbar;
if (toolbar3 == null) {
r.o("toolbar");
throw null;
}
toolbar3.setTitle(DEFAULT_HEADER_TITLE);
Toolbar toolbar4 = this.toolbar;
if (toolbar4 == null) {
r.o("toolbar");
throw null;
}
toolbar4.setContentInsetStartWithNavigation(this.defaultContentInsetStartWithNavigation);
}
ScreenStackHeaderConfig.Companion companion = ScreenStackHeaderConfig.INSTANCE;
Toolbar toolbar5 = this.toolbar;
if (toolbar5 == null) {
r.o("toolbar");
throw null;
}
TextView findTitleTextViewInToolbar = companion.findTitleTextViewInToolbar(toolbar5);
if (findTitleTextViewInToolbar != null) {
findTitleTextViewInToolbar.setTextSize(fontSize != -1 ? fontSize : this.defaultFontSize);
}
CoordinatorLayout coordinatorLayout = this.coordinatorLayout;
if (coordinatorLayout == null) {
r.o("coordinatorLayout");
throw null;
}
coordinatorLayout.measure(makeMeasureSpec, makeMeasureSpec2);
CoordinatorLayout coordinatorLayout2 = this.coordinatorLayout;
if (coordinatorLayout2 == null) {
r.o("coordinatorLayout");
throw null;
}
coordinatorLayout2.layout(0, 0, width, height);
if (this.appBarLayout == null) {
r.o("appBarLayout");
throw null;
}
float dIPFromPixel = PixelUtil.toDIPFromPixel(r0.getHeight());
this.cache = new CacheEntry(new CacheKey(fontSize, isTitleEmpty), dIPFromPixel);
return dIPFromPixel;
}
public static final Object computeDummyLayout$lambda$7() {
return "[RNScreens] Context was null-ed before dummy layout was initialized";
}
@JvmStatic
@DoNotStrip
@Nullable
public static final ScreenDummyLayoutHelper getInstance() {
return INSTANCE.getInstance();
}
private final void initDummyLayoutWithHeader(Context contextWithTheme) {
this.coordinatorLayout = new CoordinatorLayout(contextWithTheme);
AppBarLayout appBarLayout = new AppBarLayout(contextWithTheme);
appBarLayout.setLayoutParams(new CoordinatorLayout.d(-1, -2));
this.appBarLayout = appBarLayout;
Toolbar toolbar = new Toolbar(contextWithTheme);
toolbar.setTitle(DEFAULT_HEADER_TITLE);
AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(-1, -2);
layoutParams.c(0);
toolbar.setLayoutParams(layoutParams);
this.toolbar = toolbar;
TextView findTitleTextViewInToolbar = ScreenStackHeaderConfig.INSTANCE.findTitleTextViewInToolbar(toolbar);
r.h(findTitleTextViewInToolbar);
this.defaultFontSize = findTitleTextViewInToolbar.getTextSize();
Toolbar toolbar2 = this.toolbar;
if (toolbar2 == null) {
r.o("toolbar");
throw null;
}
this.defaultContentInsetStartWithNavigation = toolbar2.getContentInsetStartWithNavigation();
AppBarLayout appBarLayout2 = this.appBarLayout;
if (appBarLayout2 == null) {
r.o("appBarLayout");
throw null;
}
Toolbar toolbar3 = this.toolbar;
if (toolbar3 == null) {
r.o("toolbar");
throw null;
}
appBarLayout2.addView(toolbar3);
View view = new View(contextWithTheme);
view.setLayoutParams(new CoordinatorLayout.d(-1, -1));
this.dummyContentView = view;
CoordinatorLayout coordinatorLayout = this.coordinatorLayout;
if (coordinatorLayout == null) {
r.o("coordinatorLayout");
throw null;
}
AppBarLayout appBarLayout3 = this.appBarLayout;
if (appBarLayout3 == null) {
r.o("appBarLayout");
throw null;
}
coordinatorLayout.addView(appBarLayout3);
View view2 = this.dummyContentView;
if (view2 == null) {
r.o("dummyContentView");
throw null;
}
coordinatorLayout.addView(view2);
this.isLayoutInitialized = true;
}
private final boolean maybeInitDummyLayoutWithHeader(ReactApplicationContext reactContext) {
if (this.isLayoutInitialized) {
return true;
}
if (!reactContext.hasCurrentActivity()) {
return false;
}
Activity currentActivity = reactContext.getCurrentActivity();
if (currentActivity == null) {
throw new IllegalArgumentException("[RNScreens] Attempt to use context detached from activity. This could happen only due to race-condition.");
}
synchronized (this) {
if (this.isLayoutInitialized) {
return true;
}
initDummyLayoutWithHeader(currentActivity);
return true;
}
}
public static final Object onHostResume$lambda$10() {
return "[RNScreens] ReactContext missing in onHostResume! This should not happen.";
}
private final Activity requireActivity() {
Activity currentActivity = requireReactContext$default(this, null, 1, null).getCurrentActivity();
if (currentActivity != null) {
return currentActivity;
}
throw new IllegalArgumentException("[RNScreens] Attempt to use context detached from activity");
}
private final ReactApplicationContext requireReactContext(kq.a<? extends Object> lazyMessage) {
ReactApplicationContext reactApplicationContext = this.reactContextRef.get();
if (lazyMessage == null) {
lazyMessage = new a<>(23);
}
if (reactApplicationContext != null) {
return reactApplicationContext;
}
throw new IllegalArgumentException(lazyMessage.invoke().toString());
}
public static ReactApplicationContext requireReactContext$default(ScreenDummyLayoutHelper screenDummyLayoutHelper, kq.a aVar, int i, Object obj) {
if ((i & 1) != 0) {
aVar = null;
}
return screenDummyLayoutHelper.requireReactContext(aVar);
}
public static final Object requireReactContext$lambda$8() {
return "[RNScreens] Attempt to require missing react context";
}
public void onHostDestroy() {
ReactApplicationContext reactApplicationContext = this.reactContextRef.get();
if (reactApplicationContext != null) {
reactApplicationContext.removeLifecycleEventListener(this);
}
}
public void onHostPause() {
}
public void onHostResume() {
ReactApplicationContext requireReactContext = requireReactContext(new a(24));
if (maybeInitDummyLayoutWithHeader(requireReactContext)) {
requireReactContext.removeLifecycleEventListener(this);
} else {
LogInstrumentation.w(TAG, "[RNScreens] Failed to initialise dummy layout in onHostResume.");
}
}
}