LoginSignup
0
0

More than 1 year has passed since last update.

[Android][compose]api取得でとりあえずUseCaseまで実装できたから通信確認したい

Last updated at Posted at 2023-02-10

とりあえず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で見ましょう
スクリーンショット 2023-02-10 16.18.15.png

該当箇所をタップするなりするとinspectorに折れ線グラフが出てくるので、範囲を選択して中身を見ましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0