deprecating the Matrix.initialize and Matrix.getInstance entry points in favour of clients controlling their own instances

This commit is contained in:
Adam Brown 2022-02-14 16:04:47 +00:00
parent d05af1cb04
commit 95df3e7e2b
3 changed files with 4 additions and 1 deletions

View file

@ -1 +1 @@
Avoids using Matrix.getInstance() within the SyncService and instead relies on the SDK client to provide the matrix instance
Deprecates Matrix.initialize and Matrix.getInstance in favour of the client providing its own singleton instance via Matrix.createInstance

View file

@ -111,6 +111,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
* Initializes a singleton instance of Matrix for the given MatrixConfiguration
* This instance will be returned by Matrix.getInstance(context)
*/
@Deprecated("Use Matrix.createInstance and manage the instance manually")
fun initialize(context: Context, matrixConfiguration: MatrixConfiguration) {
if (isInit.compareAndSet(false, true)) {
instance = Matrix(context.applicationContext, matrixConfiguration)
@ -121,6 +122,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
* Either provides an already initialized singleton Matrix instance or queries the application context for a MatrixConfiguration.Provider
* to lazily create and store the instance.
*/
@Deprecated("Use Matrix.createInstance and manage the instance manually")
fun getInstance(context: Context): Matrix {
if (isInit.compareAndSet(false, true)) {
val appContext = context.applicationContext

View file

@ -66,6 +66,7 @@ data class MatrixConfiguration(
/**
* Can be implemented by your Application class.
*/
@Deprecated("Use Matrix.createInstance and manage the instance manually instead of Matrix.getInstance")
interface Provider {
fun providesMatrixConfiguration(): MatrixConfiguration
}