MCPcopy Create free account
hub / github.com/Snapchat/Valdi / ValdiRuntimeManager

Class ValdiRuntimeManager

valdi/src/java/com/snap/valdi/ValdiViewLoaderManager.kt:82–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80import java.lang.ref.WeakReference
81import java.util.concurrent.atomic.AtomicBoolean
82
83class ValdiRuntimeManager(context: Context,
84 customLogger: Logger? = null,
85 val tweaks: ValdiTweaks? = null,
86 val requestManager: HTTPRequestManager? = null,
87 executorFactory: ExecutorFactory? = null,
88 typefaceResLoader: TypefaceResLoader? = null,
89 hostUncaughtExceptionHandler: HostUncaughtExceptionHandler? = null,
90 tracer: Tracer? = null,
91 val customModuleProvider: IValdiCustomModuleProvider? = null
92) : LifecycleObserver, ComponentCallbacks, FontManager.Listener {
93
94 val logger: Logger
95
96 val nativeHandle: Long
97 get() = handle.nativeHandle
98
99 private val nativeBridge = NativeBridge()
100 private val viewManager: ValdiViewManager
101 private val contextManager: ContextManager
102
103 private val handle: NativeHandleWrapper
104
105 private var observingProcessLifecycle = false
106
107 private var mainRuntimeHolder: ValdiRuntime? = null
108
109 private val mainRuntimeLazy = lazy {
110 synchronized(mainRuntimeListeners) {
111 mainRuntimeHolder = doCreateRuntime(customModuleProvider, true)
112 mainRuntimeHolder!!.also { notifyMainRuntimeListeners(it) }
113 }
114 }
115
116 private var forceDarkMode = false
117
118 private var isIntegrationTestEnvironment = false
119
120 /**
121 * `baseContext` will be a ContextWrapper if context passed to the constructor is a ContextWrapper.
122 * `context` will always be the Application context.
123 * Ideally `baseContext` is the only Context reference. However, it's unclear if there are any
124 * call sites that require the Application context specifically, so we provide both for now.
125 */
126 val baseContext: Context = context
127 val context: Context = context.applicationContext
128
129 val mainRuntime: ValdiRuntime by mainRuntimeLazy
130
131 val fontManager = FontManager(context, typefaceResLoader ?: DefaultTypefaceResLoader())
132
133 val snapDrawingRuntime: SnapDrawingRuntime?
134 get() = snapDrawingRuntimeField
135
136 private val snapDrawingMaxRenderTargetSizeLazy = lazy {
137 if (tweaks?.enableHardwareLayerWorkaround == true) {
138 snapDrawingRuntime?.getMaxRenderTargetSize() ?: -1
139 } else {

Callers 1

createWithSupportLibsMethod · 0.85

Calls 15

DefaultLoggerClass · 0.85
OSTracerClass · 0.85
asyncTraceBeginFunction · 0.85
BitmapPoolClass · 0.85
ViewRefSupportClass · 0.85
ValdiViewManagerClass · 0.85
FileInterface · 0.85
KeychainUtilsClass · 0.85
ResourceResolverClass · 0.85

Tested by

no test coverage detected