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 { 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 { fun getInstance(): TestMatrix {
if (isInit.compareAndSet(false, true)) { if (isInit.compareAndSet(false, false)) {
val appContext = context.applicationContext throw IllegalStateException("Matrix is not initialized properly. You should call TestMatrix.initialize first")
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.")
}
} }
return instance return instance
} }