Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skeleton doesn't hide after API Call (Coroutine) #37

Open
billypap1 opened this issue Sep 9, 2021 · 3 comments
Open

Skeleton doesn't hide after API Call (Coroutine) #37

billypap1 opened this issue Sep 9, 2021 · 3 comments

Comments

@billypap1
Copy link

I have an issue with this library:
I call an external API via Coroutines and fetch the data. When I receive the data I want to hide the skeletons but it doesn't work. My code below:

CoroutineScope(Dispatchers.IO).launch {
                                              val response =
                                                  service.fetchResults(finalUrl)
                                              withContext(Dispatchers.Main) {
                                                  try {
                                                      if (response.isSuccessful) {
                                                          textViewTitle.hideSkeleton()

                                                      }
                                                 } catch (e: HttpException) {
                                                      Log.d("TAG", "error ")
                                                  } catch (e: Throwable) {
                                                      Log.d("TAG", "error" + e)
                                                  }
                                                  }

                                              }
                                          }

Any ideas?

@ericktijerou
Copy link
Owner

Hi @billypap1 👋 ,

I've tried hiding the skeleton from a coroutine and everything has worked well!.

private fun getJourneyDetail() {
    CoroutineScope(Dispatchers.IO).launch {
        delay(4000)
        withContext(Dispatchers.Main) {
            onSuccess()
        }
    }
    //handler.postDelayed({ onSuccess() }, DEFAULT_DELAY)
}

private fun onSuccess() {
    bodyBinding.clBody.visible()
    headerBinding.clHeader.hideSkeleton()
    showInformation(args.journey)
}

Can you provide more information about your code? please.

Make sure your response is successful and has no errors, btw.

@billypap1
Copy link
Author

Hello @ericktijerou , to reproduce better the error:

  1. Create a textview (exampleIDtextview),
  2. perform a CoroutineScope call
  3. append the result in this textview (exampleIDtextview.text = "test")
  4. hide the skeleton (exampleIDtextview.hideSkeleton())

The issue is happening when I add the result on textview and then hide the skeleton. If the element is static i don't have any issue.

@billypap1
Copy link
Author

@ericktijerou Any info?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants