-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Network 관련 코드 분리 및 레포지토리 이름 변경 (#45)
* refact: 네트워크 관련 코드 분리 History뿐 아니라 Todo에서도 네트워크를 사용해야 함으로 공통으로 쓸 수 있도록 분리 * refact: HistoryRepository를 공용으로 사용할 수 있도록 위치 및 파일명 변경
- Loading branch information
Showing
9 changed files
with
49 additions
and
41 deletions.
There are no files selected for viewing
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
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
2 changes: 1 addition & 1 deletion
2
.../java/com/example/todo_list/Repository.kt → .../com/example/todo_list/data/Repository.kt
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
13 changes: 13 additions & 0 deletions
13
Android/app/src/main/java/com/example/todo_list/data/TasksRepository.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.todo_list.data | ||
|
||
import com.example.todo_list.history.data.HistoryCard | ||
import com.example.todo_list.network.NetworkModule | ||
import retrofit2.Response | ||
|
||
class TasksRepository : Repository { | ||
private val network = NetworkModule.service | ||
|
||
override suspend fun getHistories(): Response<List<HistoryCard>> { | ||
return network.getHistories("histories") | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
Android/app/src/main/java/com/example/todo_list/history/HistoryReceive.kt
This file was deleted.
Oops, something went wrong.
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
13 changes: 0 additions & 13 deletions
13
Android/app/src/main/java/com/example/todo_list/history/data/HistoryRepository.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
Android/app/src/main/java/com/example/todo_list/network/NetworkModule.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.todo_list.network | ||
|
||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
|
||
class NetworkModule { | ||
companion object RetrofitApiObject { | ||
private const val BASE_URL = "https://f278a12c-c825-466b-aa01-65337bbdf28a.mock.pstmn.io/" | ||
|
||
private val retrofit = | ||
Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
val service: TodoService = retrofit.create(TodoService::class.java) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Android/app/src/main/java/com/example/todo_list/network/TodoService.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.todo_list.network | ||
|
||
import com.example.todo_list.history.data.HistoryCard | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface TodoService { | ||
|
||
@GET("api/{histories}") | ||
suspend fun getHistories( | ||
@Path("histories") variable: String | ||
): Response<List<HistoryCard>> | ||
} |