mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: cache XmlRegistry instances
This commit is contained in:
+3
-1
@@ -43,10 +43,12 @@ interface ResourceTableRegistry : XmlRegistry<ResourceTable> {
|
||||
@JvmStatic
|
||||
val COMPLETION_MANIFEST_ATTR_RES = Lookup.Key<ResourceTable>()
|
||||
|
||||
private var sInstance: ResourceTableRegistry? = null
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(): ResourceTableRegistry {
|
||||
val klass = ResourceTableRegistry::class.java
|
||||
return ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
|
||||
return sInstance ?: ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow().also { sInstance = it }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -30,12 +30,17 @@ import com.itsaky.androidide.xml.registry.XmlRegistry
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
interface ApiVersionsRegistry : XmlRegistry<ApiVersions> {
|
||||
|
||||
companion object {
|
||||
|
||||
private var sInstance: ApiVersionsRegistry? = null
|
||||
|
||||
/** Get the default instance of [ApiVersionsRegistry]. */
|
||||
@JvmStatic fun getInstance(): ApiVersionsRegistry {
|
||||
@JvmStatic
|
||||
fun getInstance(): ApiVersionsRegistry {
|
||||
val klass = ApiVersionsRegistry::class.java
|
||||
return ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
|
||||
return sInstance ?: ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
|
||||
.also { sInstance = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -30,11 +30,14 @@ interface WidgetTableRegistry : XmlRegistry<WidgetTable> {
|
||||
|
||||
companion object {
|
||||
|
||||
private var sInstance: WidgetTableRegistry? = null
|
||||
|
||||
/** Get the default instance of [WidgetTableRegistry]. */
|
||||
@JvmStatic
|
||||
fun getInstance(): WidgetTableRegistry {
|
||||
val klass = WidgetTableRegistry::class.java
|
||||
return ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
|
||||
return sInstance ?: ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
|
||||
.also { sInstance = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user