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

Commit c812449d authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Remove home blinking

parent 80fefa91
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -266,8 +266,6 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall
        appProgressViewModel.downloadProgress.observe(viewLifecycleOwner) {
            updateProgressOfDownloadingAppItemViews(homeParentRVAdapter, it)
        }

        homeViewModel.checkAnyChangeInAppStatus()
    }

    override fun onPause() {
+0 −35
Original line number Diff line number Diff line
@@ -181,39 +181,4 @@ class HomeViewModel @Inject constructor(

        return false
    }

    fun checkAnyChangeInAppStatus() {
        if (this.currentHomes == null) {
            return
        }

        val fusedHomes: MutableList<Home> = mutableListOf()
        checkForChangesInAppStatus(fusedHomes)

        if (fusedHomes.isNotEmpty() && hasAnyChange(fusedHomes)) {
            homeScreenData.value = ResultSupreme.Success(fusedHomes)
            currentHomes = fusedHomes
        }
    }

    private fun checkForChangesInAppStatus(fusedHomes: MutableList<Home>) {
        var home: Home? = null
        this.currentHomes?.forEach {

            it.list.forEach { application ->
                val status =
                    applicationRepository.getFusedAppInstallationStatus(application)

                if (application.status != status) {
                    application.status = status
                    home = it.copy()
                    // Setting a new id, so that recyclerview can find that this item is changed
                    home?.id = UUID.randomUUID().toString()
                }
            }

            fusedHomes.add(home ?: it)
            home = null
        }
    }
}