-
-
Save wellbranding/5557c920e28b11097f6d163272aa7cbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Called in VM: | |
private fun uploadPhoto(bitmap: Bitmap, isImageUploaded: Boolean) { | |
launch { | |
prepareDataForUploadingUseCase.execute(viewModelScope,bitmap, isImageUploaded) | |
} | |
} | |
//called in UseCase | |
suspend fun execute(applicationScope: CoroutineScope, bitmap: Bitmap, isImageUploaded: Boolean) { | |
val currentStep = "TEST" | |
val resizedBitmap = withContext(Dispatchers.IO) { | |
imagesPreparingForUploadUseCase.getResizedBitmap(bitmap, MAX_SIZE) | |
} | |
val bitmapCopy = resizedBitmap.copy(bitmap.config, true) | |
applicationScope.launch { | |
val deferredBase64 = async(Dispatchers.IO) { | |
imagesPreparingForUploadUseCase.getBase64ForImageUploading(bitmapCopy) | |
} | |
val deferredFile = async(Dispatchers.IO) { | |
imagesPreparingForUploadUseCase.getFileForImageUploading(bitmap) | |
} | |
val result = async(Dispatchers.IO) { | |
prepareBackgroundZipForUploadingUseCase.execute(currentStep) | |
} | |
val file = deferredFile.await() | |
val base64 = deferredBase64.await() | |
uploadPhotoUseCase.execute(file, currentStep, base64, isImageUploaded) | |
} | |
repository.updateCurrentStepsUploadingData(currentStep) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment