Created
October 9, 2021 22:32
-
-
Save AdamMc331/955989a52429ab1f812a9ecf94d5b1d3 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
class DramaCategoryFragment : Fragment(R.layout.fragment_drama_category), | |
MovieListAdapter.FavouriteMovieListener { | |
// ... | |
private fun getDramaMovies() { | |
val movieAPI = MoviesData.defaultInstance() | |
// ... | |
val retrofitData = | |
movieAPI.getMoviesByCategory("39fd0a08c0cc7fd3041fc14605c22358", 18) | |
// ... | |
} | |
// ... | |
} |
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
interface MoviesData { | |
@GET("movie/now_playing") | |
fun getData(@Query("api_key") apiKey: String): Call<MovieResponse> | |
@GET("search/movie") | |
fun searchMovies(@Query("api_key") apiKey: String, @Query("query") movieName : String): Call<MovieResponse> | |
@GET("movie/{movie_id}") | |
fun getMovieDetails(@Path("movie_id") movieId : Int, @Query("api_key") apiKey: String) : Call<MovieDetails> | |
@GET("discover/movie") | |
fun getMoviesByCategory(@Query("api_key") apiKey : String, @Query("with_genres") genreId : Int) : Call<MovieResponse> | |
companion object { | |
private const val BASE_URL = "https://api.themoviedb.org/3/" | |
// Create a default instance here, make sure it's public. | |
fun defaultInstance(): MovieData { | |
return = Retrofit.Builder() | |
.addConverterFactory(GsonConverterFactory.create()) | |
.baseUrl(BASE_URL) | |
.build() | |
.create(MoviesData::class.java) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment