Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

Apps: Switch to viewLifecycleOwner instead of this

parent f2ac21b4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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()
Loading