Removed Deprecated Code
This commit is contained in:
parent
21989d8dde
commit
603f4f8731
@ -7,6 +7,7 @@ import androidx.core.view.MenuHost
|
|||||||
import androidx.core.view.MenuProvider
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.todoapp.R
|
import com.example.todoapp.R
|
||||||
import com.example.todoapp.data.models.ToDoData
|
import com.example.todoapp.data.models.ToDoData
|
||||||
@ -46,10 +47,12 @@ class AddFragment : Fragment() {
|
|||||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
if (menuItem.itemId == R.id.menu_add) {
|
if (menuItem.itemId == R.id.menu_add) {
|
||||||
insertDataToDb()
|
insertDataToDb()
|
||||||
|
} else if (menuItem.itemId == android.R.id.home) {
|
||||||
|
requireActivity().onBackPressed()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun insertDataToDb() {
|
private fun insertDataToDb() {
|
||||||
|
@ -10,6 +10,7 @@ import androidx.core.view.MenuHost
|
|||||||
import androidx.core.view.MenuProvider
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||||
@ -82,10 +83,11 @@ class ListFragment : Fragment(), SearchView.OnQueryTextListener {
|
|||||||
mToDoViewModel.sortByLowPriority.observe(viewLifecycleOwner) {
|
mToDoViewModel.sortByLowPriority.observe(viewLifecycleOwner) {
|
||||||
adapter.setData(it)
|
adapter.setData(it)
|
||||||
}
|
}
|
||||||
|
android.R.id.home -> requireActivity().onBackPressed()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import androidx.core.view.MenuHost
|
|||||||
import androidx.core.view.MenuProvider
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import com.example.todoapp.R
|
import com.example.todoapp.R
|
||||||
@ -52,10 +53,11 @@ class UpdateFragment : Fragment() {
|
|||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.menu_save -> updateItem()
|
R.id.menu_save -> updateItem()
|
||||||
R.id.menu_delete -> confirmItemRemoval()
|
R.id.menu_delete -> confirmItemRemoval()
|
||||||
|
android.R.id.home -> requireActivity().onBackPressed()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateItem() {
|
private fun updateItem() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user