Attempt to prevent the deprecated warning/error about Provider usage.
This commit is contained in:
parent
fb05731bb9
commit
ab3f3fba68
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue