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

Commit 9e45e5f0 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Fix application uses decrementing in fragments

parent 0dc66189
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -133,6 +133,9 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS

    override fun onDestroy() {
        super.onDestroy()
        homeFragment.decrementApplicationUses()
        searchFragment.decrementApplicationUses()
        updatesFragment.decrementApplicationUses()
        installManagerGetter.disconnect(this)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -121,8 +121,8 @@ class CategoryActivity : AppCompatActivity() {

    override fun onDestroy() {
        super.onDestroy()
        if (::recyclerView.isInitialized && recyclerView.adapter != null) {
            (recyclerView.adapter as ApplicationListAdapter).removeApplicationUses()
        applicationList.forEach {
            it.decrementUses()
        }
        installManagerGetter.disconnect(this)
    }
+0 −6
Original line number Diff line number Diff line
@@ -20,10 +20,4 @@ class ApplicationListAdapter(private val activity: Activity, private val applica
    }

    override fun getItemCount() = applicationList.size

    fun removeApplicationUses() {
        applicationList.forEach {
            it.decrementUses()
        }
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -132,8 +132,8 @@ class HomeFragment : Fragment() {
        }
    }

    override fun onDestroy() {
        if (::categoryList.isInitialized) {
    fun decrementApplicationUses() {
        if (::homeViewModel.isInitialized) {
            homeViewModel.getCategories().value!!.forEach {
                it.value.forEach { application ->
                    application.decrementUses()
@@ -143,6 +143,5 @@ class HomeFragment : Fragment() {
                it.application.decrementUses()
            }
        }
        super.onDestroy()
    }
}
+3 −4
Original line number Diff line number Diff line
@@ -182,10 +182,9 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On
        super.onResume()
    }

    override fun onDestroy() {
        if (::recyclerView.isInitialized && recyclerView.adapter != null) {
            (recyclerView.adapter as ApplicationListAdapter).removeApplicationUses()
    fun decrementApplicationUses() {
        applicationList.forEach {
            it.decrementUses()
        }
        super.onDestroy()
    }
}
Loading