Если коротко, то оборачиваешь вызов Retrofit в
suspendCancellableCoroutine { continuation
->override fun onResponse(...) {
continuation.
resume(...) или continuation.cancel(), или continuation.
resumeWithException()
}
override fun onFailure(...) {
continuation.
resumeWithException(throwable)
}
}
А gerRepFromServer делаешь suspend функцией и вызываешь так:
GlobalScope.launch(Dispatchers.Main) {
onShowProgressBar()
val repositories = withContext(
Dispatchers.IO) { gerRepFromServer() }
onUpdateUi(repositories)
onHideProgressBar()
}