0
    var list:ArrayList<ProfilePost> = ArrayList()
    GlobalScope.launch {
        list=  apiInterface.GetVideosByUser(ApiInterface.PublicationRequestBodyGet(id.toString()))
            .await().publications
    }

    runOnMainThread {
        adapter = ProfilePostAdapter(list, "mine")
        recylcerPost.adapter = adapter
        recylcerPost.layoutManager = GridLayoutManager(context, 3)
    }

In this code I can't get the value of the publications in list variable so list stays null. And I need to separate the creation of the recycler view from the GetVideosByUser function because it freezes my screen

1 Answers1

0

You need to create the RecyclerView with an empty list, and then update it when you have the list from your coroutine. More info here: How to update RecyclerView Adapter Data

DHoogerwaard
  • 296
  • 2
  • 4