Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: correct result code on changes save #828

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.example.android.architecture.blueprints.todoapp.EventObserver
import com.example.android.architecture.blueprints.todoapp.R
import com.example.android.architecture.blueprints.todoapp.databinding.AddtaskFragBinding
import com.example.android.architecture.blueprints.todoapp.tasks.ADD_EDIT_RESULT_OK
import com.example.android.architecture.blueprints.todoapp.tasks.EDIT_RESULT_OK
import com.example.android.architecture.blueprints.todoapp.util.getViewModelFactory
import com.example.android.architecture.blueprints.todoapp.util.setupRefreshLayout
import com.example.android.architecture.blueprints.todoapp.util.setupSnackbar
Expand Down Expand Up @@ -73,8 +74,9 @@ class AddEditTaskFragment : Fragment() {
viewModel.taskUpdatedEvent.observe(
viewLifecycleOwner,
EventObserver {
val resultCode = if (viewModel.isNewTask) ADD_EDIT_RESULT_OK else EDIT_RESULT_OK
val action = AddEditTaskFragmentDirections
.actionAddEditTaskFragmentToTasksFragment(ADD_EDIT_RESULT_OK)
.actionAddEditTaskFragmentToTasksFragment(resultCode)
findNavController().navigate(action)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AddEditTaskViewModel(

private var taskId: String? = null

private var isNewTask: Boolean = false
var isNewTask: Boolean = false

private var isDataLoaded = false

Expand Down