Reputation: 215
Can somebody explain to me how it's works?
From (MainFragment) tap on FAB to create new fragment(HabitEditorScreenFragment) through navigation component. Applying to it Parcelable argument. In that fragment i'm going in new fragment(EditColorFragment) with new argument type of Int. In that fragment:
saving new int in sharable viewModel
i'm going back with findNavController().navigateUp()
and now is strange things. If i enter something in editfields that values will be in safeArgs value. But i haven't save it in there anywhere!
Update:
It happend riht in time when i type somthing in edit fields.
But:
private fun setDoAfterTextChanged() = with(binding) {
fhesHabitNameInput.doAfterTextChanged {
viewModel.editorHabit.name = fhesHabitNameInput.text.toString()
viewModel.canWeSave() //just cheking errors
checkName() // checking specific field
}
fhesHabitDescriptionInput.doAfterTextChanged {
viewModel.editorHabit.description = fhesHabitDescriptionInput.text.toString()
viewModel.canWeSave()
checkDescription()
}
fhesHabitFrequencyInput.doAfterTextChanged {
viewModel.editorHabit.frequency = fhesHabitFrequencyInput.text.toString()
viewModel.canWeSave()
checkFrequency()
}
}
Upvotes: 1
Views: 122
Reputation: 215
Ok, i'm figure it out what's happening. Dumb me. :D
viewModel.editorHabit = args.habitCharacteristics
this is changing link on viewModel.EditorHabit
not copying info from args. Really stupid :D Sorry for that.
Upvotes: 1