Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- ...
- CoroutineScope(Dispatchers.Main).launch {
- newTask.forEach { valueTask ->
- masterQuestionRepository.getMasterQuestionByFormCode(
- valueTask.FORM_CODE
- ).observeOnce(androidx.lifecycle.Observer { valueGetTask ->
- valueGetTask.forEach {
- if ((it.ANSWER_TYPE_ID == AnswerTypeEnum.CAMERA.code
- || it.ANSWER_TYPE_ID == AnswerTypeEnum.SELFIE.code)
- && it.DEFAULT_VALUE_Q?.isNotEmpty() == true
- ) {
- val splitingValue =
- it.DEFAULT_VALUE_Q?.split(
- "|"
- )
- CoroutineScope(Dispatchers.IO).launch{
- splitingValue?.forEach { dsa ->
- getValue(dsa, valueTask.APPLICATION_ID)
- }
- }
- }
- }
- })
- }
- }
- // CONTINUATION
- suspend fun getValue(flag: String, appId: String?): String = suspendCoroutine { cont ->
- HttpRequest(application.applicationContext).httpHandler(
- Request.Method.GET,
- "${ServiceUrl.URL_GET_PHOTO}/$appId/$flag",
- JSONObject(),
- object : HttpRequest.Callback {
- override fun onHttpPostSuccess(result: String) {
- val type = object :
- TypeToken<ResponseModel<String>>() {}.type
- val data: ResponseModel<String> =
- Gson().fromJson(result, type)
- if (data.isSuccess()) {
- if (data.contents?.isNotEmpty() == true) {
- Log.d(
- "GetPhotoSuccess",
- cont.resume(data.contents).toString()
- )
- return
- }
- } else {
- Log.d("GetPhotoFailed",
- cont.resume(data.contents.toString()).toString()
- )
- }
- }
- override fun onHttpPostError(error: String) {
- Log.d("GetPhotoError",
- error
- )
- cont.resume(error)
- }
- }
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement