Commit aa98cc89 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Apps: Switch to viewLifecycleOwner instead of this

- Resolves mutiple lint errors

References:
- [1]: https://stackoverflow.com/questions/59521691/use-viewlifecycleowner-as-the-lifecycleowner

Signed-off-by: Aayush Gupta's avatarAayush Gupta <theimpulson@e.email>
parent f2ac21b4
......@@ -58,7 +58,7 @@ class ApplicationsFragment() : Fragment() {
}
// Bind to the list of applications categories
categoriesViewModel.getApplicationsCategories().observe(this, Observer {
categoriesViewModel.getApplicationsCategories().observe(viewLifecycleOwner, Observer {
if (it!!.isNotEmpty()) {
//Add New Category
if (!it.any { Category -> Category.id == "system_apps" })
......@@ -70,7 +70,7 @@ class ApplicationsFragment() : Fragment() {
})
// Bind to the screen error
categoriesViewModel.getScreenError().observe(this, Observer {
categoriesViewModel.getScreenError().observe(viewLifecycleOwner, Observer {
if (it != null) {
view.error_description.text = activity!!.getString(it.description)
view.error_container.visibility = View.VISIBLE
......
......@@ -57,7 +57,7 @@ class GamesFragment() : Fragment() {
// Bind to the list of games categories
categoriesViewModel.getGamesCategories().observe(this, Observer {
categoriesViewModel.getGamesCategories().observe(viewLifecycleOwner, Observer {
if (it!!.isNotEmpty()) {
view.categories_list.adapter = CategoriesListAdapter(it, color)
view.categories_list.visibility = View.VISIBLE
......@@ -66,7 +66,7 @@ class GamesFragment() : Fragment() {
})
// Bind to the screen error
categoriesViewModel.getScreenError().observe(this, Observer {
categoriesViewModel.getScreenError().observe(viewLifecycleOwner, Observer {
if (it != null) {
view.error_description.text = activity!!.getString(it.description)
view.error_container.visibility = View.VISIBLE
......
......@@ -49,7 +49,7 @@ class PwasFragment : Fragment() {
}
// Bind to the list of pwas categories
categoriesViewModel.getPwasCategories().observe(this, Observer {
categoriesViewModel.getPwasCategories().observe(viewLifecycleOwner, Observer {
if (it!!.isNotEmpty()) {
view.categories_list.adapter = CategoriesListAdapter(it, null)
view.categories_list.visibility = View.VISIBLE
......@@ -58,7 +58,7 @@ class PwasFragment : Fragment() {
})
// Bind to the screen error
categoriesViewModel.getScreenError().observe(this, Observer {
categoriesViewModel.getScreenError().observe(viewLifecycleOwner, Observer {
if (it != null) {
view.error_description.text = activity!!.getString(it.description)
view.error_container.visibility = View.VISIBLE
......
......@@ -93,7 +93,7 @@ class HomeFragment : Fragment() {
}
// Bind image carousel adapter to banner images in view model
homeViewModel.getBannerApplications().observe(this, Observer {
homeViewModel.getBannerApplications().observe(viewLifecycleOwner, Observer {
if (homeViewModel.getBannerApplications().value!!.isNotEmpty()) {
imageCarousel.adapter = ImageCarouselAdapter(activity!!, homeViewModel.getBannerApplications().value!!)
imageCarousel.clipToPadding = false;
......@@ -107,7 +107,7 @@ class HomeFragment : Fragment() {
})
// Bind categories adapter to categories in view model
homeViewModel.getCategories().observe(this, Observer {
homeViewModel.getCategories().observe(viewLifecycleOwner, Observer {
if (homeViewModel.getCategories().value!!.isNotEmpty()) {
showCategories(it!!)
categoryList.visibility = View.VISIBLE
......@@ -117,7 +117,7 @@ class HomeFragment : Fragment() {
})
// Bind to the screen error
homeViewModel.getScreenError().observe(this, Observer {
homeViewModel.getScreenError().observe(viewLifecycleOwner, Observer {
if (it != null) {
errorDescription.text = activity!!.getString(it.description)
errorContainer.visibility = View.VISIBLE
......
......@@ -131,12 +131,12 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On
})
// Bind search view suggestions adapter to search suggestions list in view model
searchViewModel.getSuggestions().observe(this, Observer {
searchViewModel.getSuggestions().observe(viewLifecycleOwner, Observer {
populateSuggestionsAdapter(it)
})
// Bind recycler view adapter to search results list in view model
searchViewModel.getApplications().observe(this, Observer {
searchViewModel.getApplications().observe(viewLifecycleOwner, Observer {
if (it != null) {
applicationList.clear()
applicationList.addAll(it)
......@@ -156,7 +156,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On
})
// Bind to the screen error
searchViewModel.getScreenError().observe(this, Observer {
searchViewModel.getScreenError().observe(viewLifecycleOwner, Observer {
if (it != null) {
if (!isLoadingMoreApplications) {
applicationList.clear()
......
......@@ -107,7 +107,7 @@ class UpdatesFragment() : Fragment() {
recyclerView.adapter = ApplicationListAdapter(activity!!, applicationList, accentColorOS)
// Bind recycler view adapter to outdated applications list in view model
updatesViewModel.getApplications().observe(this, Observer {
updatesViewModel.getApplications().observe(viewLifecycleOwner, Observer {
if (it != null) {
......@@ -130,7 +130,7 @@ class UpdatesFragment() : Fragment() {
})
// Bind to the screen error
updatesViewModel.getScreenError().observe(this, Observer {
updatesViewModel.getScreenError().observe(viewLifecycleOwner, Observer {
if (it != null) {
errorDescription.text = activity!!.getString(it.description)
errorContainer.visibility = View.VISIBLE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment