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

Commit 62bbb1a3 authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch '2109-fix_scroll_homepage' into 'main'

fixed: scroll to middle of the homepage

See merge request !437
parents 9cf391a4 0c4775ee
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment
import foundation.e.apps.ui.home.model.HomeChildRVAdapter
import foundation.e.apps.ui.home.model.HomeParentRVAdapter
import foundation.e.apps.ui.parentFragment.TimeoutFragment
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import javax.inject.Inject

@@ -68,6 +69,10 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall
    @Inject
    lateinit var pwaManager: PWAManager

    companion object {
        private const val SCROLL_DELAY_IN_MILLIS = 500L
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        _binding = FragmentHomeBinding.bind(view)
@@ -92,6 +97,12 @@ class HomeFragment : TimeoutFragment(R.layout.fragment_home), ApplicationInstall
            }

            homeParentRVAdapter?.setData(it.data!!)

            // scrolling to top 500 ms later to give time UI elements to be rendered
            viewLifecycleOwner.lifecycleScope.launch {
                delay(SCROLL_DELAY_IN_MILLIS)
                binding.parentRV.scrollToPosition(0)
            }
        }
    }