-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd31228
commit a9b3caf
Showing
6 changed files
with
196 additions
and
28 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...c/main/java/com/red_velvet_cake/dailytodo/ui/team_todo_details/TeamTODOStatusPresenter.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,44 @@ | ||
package com.red_velvet_cake.dailytodo.ui.team_todo_details | ||
|
||
import com.red_velvet_cake.dailytodo.data.model.UpdateTeamTodoStatusResponse | ||
import com.red_velvet_cake.dailytodo.data.remote.TodoServiceImpl | ||
import com.red_velvet_cake.dailytodo.utils.Constants | ||
import com.red_velvet_cake.dailytodo.utils.TodoStatus | ||
import java.io.IOException | ||
|
||
class TeamTODOStatusPresenter( | ||
private val view: TeamTodoDetailsView, | ||
) { | ||
private val todoServiceImpl = TodoServiceImpl() | ||
|
||
fun setTodoStatus(status: TodoStatus, todoId: String) { | ||
view.showTodoStatusUpdatedLoading(true) | ||
when (status) { | ||
TodoStatus.Todo -> updateTeamTODOStatus(Constants.TODO, todoId) | ||
TodoStatus.InProgress -> updateTeamTODOStatus(Constants.IN_PROGRESS, todoId) | ||
TodoStatus.Done -> updateTeamTODOStatus(Constants.DONE, todoId) | ||
} | ||
} | ||
|
||
private fun updateTeamTODOStatus( | ||
newTodoStatus: Int, | ||
todoId: String, | ||
) { | ||
todoServiceImpl.updateTeamTodoStatus( | ||
todoId, | ||
newTodoStatus, | ||
::onUpdateTeamTodoStatusSuccess, | ||
::onUpdateTeamTodoStatusFailure | ||
) | ||
} | ||
|
||
private fun onUpdateTeamTodoStatusSuccess(updateTeamStatusResponse: UpdateTeamTodoStatusResponse) { | ||
view.showTodoStatusUpdatedLoading(!updateTeamStatusResponse.isSuccess) | ||
view.showTodoStatusUpdatedSuccessfully() | ||
} | ||
|
||
private fun onUpdateTeamTodoStatusFailure(exception: IOException) { | ||
view.showTodoStatusUpdatedLoading(false) | ||
view.showTodoStatusUpdatedFailure(exception) | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/red_velvet_cake/dailytodo/ui/team_todo_details/TeamTodoDetailsView.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,9 @@ | ||
package com.red_velvet_cake.dailytodo.ui.team_todo_details | ||
|
||
import java.io.IOException | ||
|
||
interface TeamTodoDetailsView { | ||
fun showTodoStatusUpdatedLoading(isLoading:Boolean) | ||
fun showTodoStatusUpdatedSuccessfully() | ||
fun showTodoStatusUpdatedFailure(exception: IOException) | ||
} |
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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/red_velvet_cake/dailytodo/utils/TodoStatus.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,5 @@ | ||
package com.red_velvet_cake.dailytodo.utils | ||
|
||
enum class TodoStatus { | ||
Done, InProgress, Todo | ||
} |
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