android / android/architecture-samples

[master] method never used: TasksViewModel.addNewTask()

Open
#671 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
45.8k
Forks
11.9k
PR merge metrics
No merged PRs in 30d

Description

The method `addNewTask()` in `TasksViewModel.kt` is never used. Though commented "Called by the Data Binding library and the FAB's click listener." The click listener of FAB is set in `TasksFragment.kt`, navigating to new page.

**TasksViewModel.kt**

```kotlin
/**
* Called by the Data Binding library and the FAB's click listener.
*/
fun addNewTask() {
_newTaskEvent.value = Event(Unit)
}
```

**TasksFragment.kt**
```kotlin
private fun setupFab() {
activity?.findViewById(R.id.add_task_fab)?.let {
it.setOnClickListener {
navigateToAddNewTask()
}
}
}

private fun navigateToAddNewTask() {
val action = TasksFragmentDirections
.actionTasksFragmentToAddEditTaskFragment(
null,
resources.getString(R.string.add_task)
)
findNavController().navigate(action)
}
```

Contributor guide

Open the contributing guide

Research direction

Start in TasksViewModel.kt and TasksFragment.kt, then search for references to addNewTask() and the Data Binding callback. Confirm that the FAB still navigates through setupFab() and navigateToAddNewTask(); done means the unused method and any obsolete reference are removed without changing that navigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.