导航菜单

页面标题

页面副标题

CityMall v1.42.1 - ScreenDummyLayoutHelper.java 源代码

正在查看: CityMall v1.42.1 应用的 ScreenDummyLayoutHelper.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.swmansion.rnscreens.utils;

import K6.A;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
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.c0;
import com.google.android.material.appbar.AppBarLayout;
import com.simpl.android.fingerprint.BuildConfig;
import com.swmansion.rnscreens.G;
import java.lang.ref.WeakReference;
import kotlin.Metadata;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.jvm.internal.j;
import kotlin.jvm.internal.k;
import org.jetbrains.annotations.Nullable;

@DoNotStrip
@Metadata
@SourceDebugExtension
public final class ScreenDummyLayoutHelper implements LifecycleEventListener {
    public static final a j = new a(null);
    private static WeakReference k = new WeakReference(null);
    private CoordinatorLayout a;
    private AppBarLayout b;
    private View c;
    private Toolbar d;
    private float e;
    private int f;
    private com.swmansion.rnscreens.utils.a g;
    private WeakReference h;
    private volatile boolean i;

    public static final class a {
        public a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        @JvmStatic
        @DoNotStrip
        @Nullable
        public final ScreenDummyLayoutHelper getInstance() {
            return (ScreenDummyLayoutHelper) ScreenDummyLayoutHelper.k.get();
        }

        private a() {
        }
    }

    static final class b extends k implements Function0 {
        public static final b i = new b();

        b() {
            super(0);
        }

        @Override
        public final Object invoke() {
            return "[RNScreens] Context was null-ed before dummy layout was initialized";
        }
    }

    static final class c extends k implements Function0 {
        public static final c i = new c();

        c() {
            super(0);
        }

        @Override
        public final Object invoke() {
            return "[RNScreens] ReactContext missing in onHostResume! This should not happen.";
        }
    }

    static final class d extends k implements Function0 {
        public static final d i = new d();

        d() {
            super(0);
        }

        @Override
        public final String invoke() {
            return "[RNScreens] Attempt to require missing react context";
        }
    }

    private final void b(Context context) {
        this.a = new CoordinatorLayout(context);
        AppBarLayout appBarLayout = new AppBarLayout(context);
        appBarLayout.setLayoutParams(new CoordinatorLayout.d(-1, -2));
        this.b = appBarLayout;
        Toolbar toolbar = new Toolbar(context);
        toolbar.setTitle("FontSize123!#$");
        AppBarLayout.LayoutParams layoutParams = new AppBarLayout.LayoutParams(-1, -2);
        layoutParams.g(0);
        toolbar.setLayoutParams(layoutParams);
        this.d = toolbar;
        TextView a2 = G.L.a(toolbar);
        j.f(a2);
        this.e = a2.getTextSize();
        Toolbar toolbar2 = this.d;
        View view = null;
        if (toolbar2 == null) {
            j.A("toolbar");
            toolbar2 = null;
        }
        this.f = toolbar2.getContentInsetStartWithNavigation();
        ViewGroup viewGroup = this.b;
        if (viewGroup == null) {
            j.A("appBarLayout");
            viewGroup = null;
        }
        View view2 = this.d;
        if (view2 == null) {
            j.A("toolbar");
            view2 = null;
        }
        viewGroup.addView(view2);
        View view3 = new View(context);
        view3.setLayoutParams(new CoordinatorLayout.d(-1, -1));
        this.c = view3;
        ViewGroup viewGroup2 = this.a;
        if (viewGroup2 == null) {
            j.A("coordinatorLayout");
            viewGroup2 = null;
        }
        View view4 = this.b;
        if (view4 == null) {
            j.A("appBarLayout");
            view4 = null;
        }
        viewGroup2.addView(view4);
        View view5 = this.c;
        if (view5 == null) {
            j.A("dummyContentView");
        } else {
            view = view5;
        }
        viewGroup2.addView(view);
        this.i = true;
    }

    private final boolean c(ReactApplicationContext reactApplicationContext) {
        if (this.i) {
            return true;
        }
        if (!reactApplicationContext.hasCurrentActivity()) {
            return false;
        }
        Activity currentActivity = reactApplicationContext.getCurrentActivity();
        if (currentActivity == null) {
            throw new IllegalArgumentException("[RNScreens] Attempt to use context detached from activity. This could happen only due to race-condition.");
        }
        j.h(currentActivity, "requireNotNull(...)");
        synchronized (this) {
            if (this.i) {
                return true;
            }
            b(currentActivity);
            A a2 = A.a;
            return true;
        }
    }

    @DoNotStrip
    private final float computeDummyLayout(int i, boolean z) {
        if (!this.i && !c(e(b.i))) {
            Log.e("ScreenDummyLayoutHelper", "[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.g.b(new com.swmansion.rnscreens.utils.b(i, z))) {
            return this.g.a();
        }
        View decorView = d().getWindow().getDecorView();
        j.h(decorView, "getDecorView(...)");
        int width = decorView.getWidth();
        int height = decorView.getHeight();
        int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, 1073741824);
        int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(height, 1073741824);
        View view = null;
        if (z) {
            Toolbar toolbar = this.d;
            if (toolbar == null) {
                j.A("toolbar");
                toolbar = null;
            }
            toolbar.setTitle(BuildConfig.FLAVOR);
            Toolbar toolbar2 = this.d;
            if (toolbar2 == null) {
                j.A("toolbar");
                toolbar2 = null;
            }
            toolbar2.setContentInsetStartWithNavigation(0);
        } else {
            Toolbar toolbar3 = this.d;
            if (toolbar3 == null) {
                j.A("toolbar");
                toolbar3 = null;
            }
            toolbar3.setTitle("FontSize123!#$");
            Toolbar toolbar4 = this.d;
            if (toolbar4 == null) {
                j.A("toolbar");
                toolbar4 = null;
            }
            toolbar4.setContentInsetStartWithNavigation(this.f);
        }
        G.a aVar = G.L;
        Toolbar toolbar5 = this.d;
        if (toolbar5 == null) {
            j.A("toolbar");
            toolbar5 = null;
        }
        TextView a2 = aVar.a(toolbar5);
        if (a2 != null) {
            a2.setTextSize(i != -1 ? i : this.e);
        }
        View view2 = this.a;
        if (view2 == null) {
            j.A("coordinatorLayout");
            view2 = null;
        }
        view2.measure(makeMeasureSpec, makeMeasureSpec2);
        View view3 = this.a;
        if (view3 == null) {
            j.A("coordinatorLayout");
            view3 = null;
        }
        view3.layout(0, 0, width, height);
        View view4 = this.b;
        if (view4 == null) {
            j.A("appBarLayout");
        } else {
            view = view4;
        }
        float e = c0.e(view.getHeight());
        this.g = new com.swmansion.rnscreens.utils.a(new com.swmansion.rnscreens.utils.b(i, z), e);
        return e;
    }

    private final Activity d() {
        Activity currentActivity = f(this, null, 1, null).getCurrentActivity();
        if (currentActivity != null) {
            return currentActivity;
        }
        throw new IllegalArgumentException("[RNScreens] Attempt to use context detached from activity");
    }

    private final ReactApplicationContext e(Function0 function0) {
        Object obj = this.h.get();
        if (function0 == null) {
            function0 = d.i;
        }
        if (obj != null) {
            return (ReactApplicationContext) obj;
        }
        throw new IllegalArgumentException(function0.invoke().toString());
    }

    static ReactApplicationContext f(ScreenDummyLayoutHelper screenDummyLayoutHelper, Function0 function0, int i, Object obj) {
        if ((i & 1) != 0) {
            function0 = null;
        }
        return screenDummyLayoutHelper.e(function0);
    }

    @JvmStatic
    @DoNotStrip
    @Nullable
    public static final ScreenDummyLayoutHelper getInstance() {
        return j.getInstance();
    }

    public void onHostDestroy() {
        ReactApplicationContext reactApplicationContext = (ReactApplicationContext) this.h.get();
        if (reactApplicationContext != null) {
            reactApplicationContext.removeLifecycleEventListener(this);
        }
    }

    public void onHostPause() {
    }

    public void onHostResume() {
        ReactApplicationContext e = e(c.i);
        if (c(e)) {
            e.removeLifecycleEventListener(this);
        } else {
            Log.w("ScreenDummyLayoutHelper", "[RNScreens] Failed to initialise dummy layout in onHostResume.");
        }
    }
}