From f95d21ef1754ac1e471082244319c64c9b054b27 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 23 Sep 2022 16:32:50 +0200 Subject: [PATCH] Inject member in VectorBaseActivity instead of using SingletonEntryPoint --- .../app/core/platform/VectorBaseActivity.kt | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index 7e61958565..413249e79c 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -105,7 +105,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver protected var analyticsScreenName: MobileScreen.ScreenName? = null - protected lateinit var analyticsTracker: AnalyticsTracker + @Inject lateinit var analyticsTracker: AnalyticsTracker /* ========================================================================================== * View @@ -149,26 +149,22 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver * ========================================================================================== */ private lateinit var configurationViewModel: ConfigurationViewModel - private lateinit var sessionListener: SessionListener - protected lateinit var bugReporter: BugReporter - private lateinit var pinLocker: PinLocker + @Inject lateinit var sessionListener: SessionListener + @Inject lateinit var bugReporter: BugReporter + @Inject lateinit var pinLocker: PinLocker @Inject lateinit var rageShake: RageShake @Inject lateinit var buildMeta: BuildMeta @Inject lateinit var fontScalePreferences: FontScalePreferences @Inject lateinit var vectorLocale: VectorLocaleProvider + @Inject lateinit var vectorFeatures: VectorFeatures + @Inject lateinit var navigator: Navigator + @Inject lateinit var activeSessionHolder: ActiveSessionHolder + @Inject lateinit var vectorPreferences: VectorPreferences // For debug only @Inject lateinit var debugReceiver: DebugReceiver - @Inject - lateinit var vectorFeatures: VectorFeatures - - lateinit var navigator: Navigator - private set - - private lateinit var activeSessionHolder: ActiveSessionHolder - private lateinit var vectorPreferences: VectorPreferences // Filter for multiple invalid token error private var mainActivityStarted = false @@ -205,7 +201,6 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver @CallSuper override fun onCreate(savedInstanceState: Bundle?) { Timber.i("onCreate Activity ${javaClass.simpleName}") - val singletonEntryPoint = singletonEntryPoint() val activityEntryPoint = EntryPointAccessors.fromActivity(this, ActivityEntryPoint::class.java) ThemeUtils.setActivityTheme(this, getOtherThemes()) viewModelFactory = activityEntryPoint.viewModelFactory() @@ -213,12 +208,6 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver addOnMultiWindowModeChangedListener(onMultiWindowModeChangedListener) setupMenu() configurationViewModel = viewModelProvider.get(ConfigurationViewModel::class.java) - bugReporter = singletonEntryPoint.bugReporter() - pinLocker = singletonEntryPoint.pinLocker() - analyticsTracker = singletonEntryPoint.analyticsTracker() - navigator = singletonEntryPoint.navigator() - activeSessionHolder = singletonEntryPoint.activeSessionHolder() - vectorPreferences = singletonEntryPoint.vectorPreferences() configurationViewModel.activityRestarter.observe(this) { if (!it.hasBeenHandled) { // Recreate the Activity because configuration has changed @@ -230,7 +219,6 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver navigator.openPinCode(this, pinStartForActivityResult, PinMode.AUTH) } } - sessionListener = singletonEntryPoint.sessionListener() sessionListener.globalErrorLiveData.observeEvent(this) { handleGlobalError(it) }