Skip to content
Permalink
Browse files

Make APIService an object

  • Loading branch information
zsmb13 committed Jan 7, 2020
1 parent 5c3dca5 commit 0f4d3ff29e4c6d08c8c81be6ae812d51836b192b
@@ -2,15 +2,13 @@ package dev.marcosfarias.pokedex.repository

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create

class APIService {

object APIService {
private val retrofit = Retrofit.Builder()
.baseUrl("https://gist.githubusercontent.com/mrcsxsiq/b94dbe9ab67147b642baa9109ce16e44/raw/97811a5df2df7304b5bc4fbb9ee018a0339b8a38/")
.addConverterFactory(GsonConverterFactory.create())
.build()

fun pokemonService(): PokemonService {
return retrofit.create(PokemonService::class.java)
}
}
val pokemonService: PokemonService = retrofit.create()
}
@@ -19,7 +19,7 @@ class PokedexViewModel : ViewModel() {
}

private fun initNetworkRequest() {
val call = APIService().pokemonService().get()
val call = APIService.pokemonService.get()
call.enqueue(object : Callback<List<Pokemon>?> {
override fun onResponse(
call: Call<List<Pokemon>?>?,

0 comments on commit 0f4d3ff

Please sign in to comment.
You can’t perform that action at this time.