daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. val data = MutableLiveData<SearchResponse>()
  2.  
  3. tmdbApi.searchMovies(TMDBApi.TMDB_API_KEY, query, page).enqueue(object: Callback<SearchResponse>    {
  4.     override fun onFailure(call: Call<SearchResponse>?, t: Throwable?) {}
  5.     override fun onResponse(call: Call<SearchResponse>?, response: Response<SearchResponse>) {
  6.         data.value = response.body()
  7.         val resp = response.body()
  8.         resp!!.results.forEachIndexed { index, movie ->
  9.             tmdbApi.searchMovie(movie.id, TMDBApi.TMDB_API_KEY).enqueue(object: Callback<Movie> {
  10.                 override fun onFailure(call: Call<Movie>?, t: Throwable?) {}
  11.  
  12.                 override fun onResponse(call: Call<Movie>?, movieresp: Response<Movie>) {
  13.                     data.value!!.results[index] = movieresp.body()!!
  14.                     if(index == resp!!.results.size - 1) data.value = data.value
  15.                 }
  16.             })
  17.         }
  18.     }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top