I have a problem with my MVVM structure. I create apps and pass data between fragments. Now it works fine, but I need to add this logic to my ViewModel.
This is my NotesClickFragment:
@AndroidEntryPoint
class NotesClickFragment : Fragment(R.layout.fragment_click_notes) {
private val args by navArgs<NotesClickFragmentArgs>()
private val viewModel: NotesClickViewModel by viewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val binding = FragmentClickNotesBinding.bind(view)
binding.apply {
textViewTitleClick.setText(args.notesClickArgs.titleNotes)
textViewContentNotesClick.setText(args.notesClickArgs.contentNotes)
textViewHistoryClick.setText(args.notesClickArgs.createdNotesDateFormat)
}
}
}
This is my NotesClickViewModel:
class NotesClickViewModel @ViewModelInject constructor(
private val notesDao: NotesDao
) : ViewModel() {
}
I'm trying to add a private argument val navArgs: NotesClickFragmentArgs
and create the other functions to set data from fragments but it doesn't work. What is good practice? Thanks in advance for your tips.