class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val api = RetrofitInstance.getInstance().create(MyApi::class.java)
api.getPost().enqueue(object :Callback<Post> {
override fun onResponse(call: Call<Post>, response: Response<Post>) {
Thread.sleep(1000)
Log.d("MAIN", response.body().toString())
}
override fun onFailure(call: Call<Post>, t: Throwable) {
Log.d("MAIN", t.toString())
}
})
api.getPost2(2).enqueue(object :Callback<Post> {
override fun onResponse(call: Call<Post>, response: Response<Post>) {
Log.d("MAIN2", response.body().toString())
}
override fun onFailure(call: Call<Post>, t: Throwable) {
Log.d("MAIN2", t.toString())
}
})
api.getPost2(3).enqueue(object :Callback<Post> {
override fun onResponse(call: Call<Post>, response: Response<Post>) {
Log.d("MAIN3", response.body().toString())
}
override fun onFailure(call: Call<Post>, t: Throwable) {
Log.d("MAIN3", t.toString())
}
})
}
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val api = RetrofitInstance.getInstance().create(MyApi::class.java)
api.getPost().enqueue(object :Callback<Post> {
override fun onResponse(call: Call<Post>, response: Response<Post>) {
Thread.sleep(1000)
Log.d("MAIN", response.body().toString())
api.getPost2(2).enqueue(object :Callback<Post> {
override fun onResponse(call: Call<Post>, response: Response<Post>) {
Log.d("MAIN2", response.body().toString())
api.getPost2(3).enqueue(object :Callback<Post> {
override fun onResponse(call: Call<Post>, response: Response<Post>) {
Log.d("MAIN3", response.body().toString())
// SET TEXT를 해봐야함
}
override fun onFailure(call: Call<Post>, t: Throwable) {
Log.d("MAIN3", t.toString())
}
})
}
override fun onFailure(call: Call<Post>, t: Throwable) {
Log.d("MAIN2", t.toString())
}
})
}
override fun onFailure(call: Call<Post>, t: Throwable) {
Log.d("MAIN", t.toString())
}
})
}
}
'Android(Kotlin)' 카테고리의 다른 글
SaveFile Android kotlin (0) | 2022.05.02 |
---|---|
Android REQUEST_IGNORE_BATTERY_OPTIMIZATIONS (0) | 2022.04.29 |
Android PeriodicWorkRequest Memo (0) | 2022.04.07 |
WorkManager Chaining (0) | 2022.03.30 |
Android Log가 안뜰 때 (0) | 2022.03.18 |