@@ -7,7 +7,6 @@ import android.view.LayoutInflater
77import android.view.View
88import android.view.ViewGroup
99import androidx.appcompat.widget.Toolbar
10- import androidx.compose.material3.MaterialTheme
1110import androidx.compose.ui.platform.ViewCompositionStrategy
1211import androidx.coordinatorlayout.widget.CoordinatorLayout
1312import androidx.fragment.app.Fragment
@@ -21,6 +20,7 @@ import com.pennapps.labs.pennmobile.MainActivity
2120import com.pennapps.labs.pennmobile.R
2221import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
2322import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior
23+ import com.pennapps.labs.pennmobile.compose.presentation.theme.AppTheme
2424import com.pennapps.labs.pennmobile.databinding.FragmentHomeBinding
2525import com.pennapps.labs.pennmobile.home.HomepageViewModel
2626import com.pennapps.labs.pennmobile.home.adapters.HomeAdapter
@@ -73,28 +73,6 @@ class HomeFragment : Fragment() {
7373 ) {
7474 super .onViewCreated(view, savedInstanceState)
7575
76- /* Mildly suspicious idea to hide the RecyclerView until blurviews (for news and posts) are
77- done processing. Processing the blurviews is slow and makes the app looks sloppy. Ideally
78- this is replaced by something less hacky (such as using a ListView instead) though perhaps
79- it is simpler to just remove the blur altogether.
80-
81- This takes advantage of a RecyclerView idiosyncracy: when a RecyclerView resides inside a
82- nested scrollview, all of the elements are inflated:
83- https://stackoverflow.com/questions/44453846/recyclerview-inside-nestedscrollview-causes-recyclerview-to-inflate-all-elements
84- https://www.reddit.com/r/androiddev/comments/d8gi9v/recyclerview_inside_nestedscrollview_causes/
85-
86- This is can be used to figure out when the blurviews are finished processing.
87-
88- Since when the adapter is set in getHomePage, onBindViewHolder() is called for each cell.
89- Thus, for the news and post cells which use blur, when the blur is finished processing,
90- the adapter notifies homepageViewModel. When both blurs are processed, the blurViewsLoaded
91- liveData in the ViewModel is toggled to true which HomeFragment observes.
92-
93- If in the future, the homepage is stuck on loading forever, this might be why. To remove
94- this functionality and stop waiting for the blur views to finish, just remove the observer
95- below and change getHomePage() so that when HomeAdapter is set, homeCellsRv.visibility is
96- set to View.VISIBLE instead of View.INVISIBLE and hide loadingPanel
97- */
9876 toolbar = mActivity.findViewById(R .id.toolbar)
9977 binding.homeCellsRv.layoutManager =
10078 LinearLayoutManager (
@@ -103,12 +81,10 @@ class HomeFragment : Fragment() {
10381 false ,
10482 )
10583
106- // Entry-point card for the Student Resources page. Tapping it pushes
107- // StudentResourcesFragment onto the back stack.
10884 binding.studentResourcesEntry.apply {
10985 setViewCompositionStrategy(ViewCompositionStrategy .DisposeOnViewTreeLifecycleDestroyed )
11086 setContent {
111- MaterialTheme {
87+ AppTheme {
11288 StudentResourcesEntryCard (
11389 onClick = { openStudentResources() },
11490 )
@@ -149,7 +125,11 @@ class HomeFragment : Fragment() {
149125 }
150126
151127 private fun openStudentResources () {
152- mActivity.fragmentTransact(StudentResourcesFragment (), false )
128+ mActivity.fragmentTransact(
129+ StudentResourcesFragment (),
130+ false ,
131+ backStackName = " student_resources" ,
132+ )
153133 }
154134
155135 private fun getOnline (): Boolean {
0 commit comments