Removed Deprecated Code

This commit is contained in:
Stevdza-San 2022-07-28 13:06:50 +02:00
parent 21989d8dde
commit 603f4f8731
3 changed files with 10 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.navigation.fragment.findNavController
import com.example.todoapp.R
import com.example.todoapp.data.models.ToDoData
@ -46,10 +47,12 @@ class AddFragment : Fragment() {
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
if (menuItem.itemId == R.id.menu_add) {
insertDataToDb()
} else if (menuItem.itemId == android.R.id.home) {
requireActivity().onBackPressed()
}
return true
}
})
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
private fun insertDataToDb() {

View File

@ -10,6 +10,7 @@ import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
@ -82,10 +83,11 @@ class ListFragment : Fragment(), SearchView.OnQueryTextListener {
mToDoViewModel.sortByLowPriority.observe(viewLifecycleOwner) {
adapter.setData(it)
}
android.R.id.home -> requireActivity().onBackPressed()
}
return true
}
})
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}

View File

@ -8,6 +8,7 @@ import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.example.todoapp.R
@ -52,10 +53,11 @@ class UpdateFragment : Fragment() {
when (menuItem.itemId) {
R.id.menu_save -> updateItem()
R.id.menu_delete -> confirmItemRemoval()
android.R.id.home -> requireActivity().onBackPressed()
}
return true
}
})
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
private fun updateItem() {