Skip to content

Commit 9f4ae66

Browse files
refactor(dashboard): Use TeamsRepository for team lookup
Replaces a direct Realm query in the dashboard's team click handler with an asynchronous call to `TeamsRepository`. To avoid dependency conflicts in the `lite` build flavor, this change uses a Hilt `@EntryPoint` to safely access the `TeamsRepository` from the `BellDashboardFragment` without requiring a direct `@Inject` in the shared fragment. This decouples the UI from the data layer, improves the architecture, and resolves a multi-flavor build issue.
1 parent 64aae12 commit 9f4ae66

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.ole.planet.myplanet.di
2+
3+
import dagger.hilt.EntryPoint
4+
import dagger.hilt.InstallIn
5+
import dagger.hilt.components.SingletonComponent
6+
import org.ole.planet.myplanet.repository.TeamsRepository
7+
8+
@EntryPoint
9+
@InstallIn(SingletonComponent::class)
10+
interface TeamsRepositoryEntryPoint {
11+
fun teamsRepository(): TeamsRepository
12+
}

app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,13 @@ import org.ole.planet.myplanet.ui.life.LifeFragment
3636
import org.ole.planet.myplanet.ui.resources.ResourcesFragment
3737
import org.ole.planet.myplanet.ui.submissions.SubmissionsAdapter
3838
import org.ole.planet.myplanet.ui.submissions.SubmissionsFragment
39-
import dagger.hilt.android.AndroidEntryPoint
40-
import javax.inject.Inject
41-
import org.ole/planet.myplanet.repository.TeamsRepository
4239
import org.ole.planet.myplanet.ui.teams.TeamFragment
4340
import org.ole.planet.myplanet.ui.teams.TeamDetailFragment
4441
import org.ole.planet.myplanet.utilities.DialogUtils.guestDialog
42+
import org.ole.planet.myplanet.di.TeamsRepositoryEntryPoint
43+
import dagger.hilt.android.EntryPointAccessors
4544

46-
@AndroidEntryPoint
4745
class BellDashboardFragment : BaseDashboardFragment() {
48-
@Inject
49-
lateinit var teamsRepository: TeamsRepository
5046
private var _binding: FragmentHomeBellBinding? = null
5147
private val binding get() = _binding!!
5248
private var networkStatusJob: Job? = null
@@ -451,6 +447,11 @@ class BellDashboardFragment : BaseDashboardFragment() {
451447

452448
override fun handleClick(id: String?, title: String?, f: Fragment, v: TextView) {
453449
if (f is TeamDetailFragment) {
450+
val hiltEntryPoint = EntryPointAccessors.fromApplication(
451+
requireContext(),
452+
TeamsRepositoryEntryPoint::class.java
453+
)
454+
val teamsRepository = hiltEntryPoint.teamsRepository()
454455
v.text = title
455456
v.setOnClickListener {
456457
lifecycleScope.launch {

0 commit comments

Comments
 (0)