Attempt to prevent the deprecated warning/error about Provider usage.

This commit is contained in:
Michael Kaye 2022-03-08 10:38:23 +00:00
parent fb05731bb9
commit ab3f3fba68
2 changed files with 4 additions and 11 deletions

View File

@ -71,7 +71,7 @@ class CommonTestHelper(context: Context) {
)
)
}
matrix = TestMatrix.getInstance(context)
matrix = TestMatrix.getInstance()
}
fun createAccount(userNamePrefix: String, testParams: SessionTestParams): Session {

View File

@ -105,16 +105,9 @@ internal class TestMatrix constructor(context: Context, matrixConfiguration: Mat
}
}
fun getInstance(context: Context): TestMatrix {
if (isInit.compareAndSet(false, true)) {
val appContext = context.applicationContext
if (appContext is MatrixConfiguration.Provider) {
val matrixConfiguration = (appContext as MatrixConfiguration.Provider).providesMatrixConfiguration()
instance = TestMatrix(appContext, matrixConfiguration)
} else {
throw IllegalStateException("Matrix is not initialized properly." +
" You should call Matrix.initialize or let your application implements MatrixConfiguration.Provider.")
}
fun getInstance(): TestMatrix {
if (isInit.compareAndSet(false, false)) {
throw IllegalStateException("Matrix is not initialized properly. You should call TestMatrix.initialize first")
}
return instance
}