とりあえずUseCaseまでできたから通信確認したい
Retrofit2とgsonを使います
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation( "com.squareup.retrofit2:converter-gson:2.3.0")
//どこかのView,Screenに以下を設定
val retrofit = Retrofit.Builder()
.baseUrl("http://~~~~") //通信先
.addConverterFactory(GsonConverterFactory.create())
.build()
val apiClient = xxxApiClient(retrofit)
val dataSource = xxxDataSource(apiClient)
val repository = xxxRepositoryImpl(dataSource)
val useCase = GetxxxUseCase(repository)
val coroutine = rememberCoroutineScope()
//Viewのどこかのtextなりにclickable{}を設定し以下を書くとかする。別にclickableじゃなくてもよい
coroutine.launch {
useCase.execute()
}
AppInpectionの Network Inspectorで見ましょう
該当箇所をタップするなりするとinspectorに折れ線グラフが出てくるので、範囲を選択して中身を見ましょう。