diff options
-rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt | 8 | ||||
-rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt index 86b57533..d571d962 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/RepositorySettings.kt @@ -42,13 +42,12 @@ import dev.msfjarvis.aps.util.settings.PreferenceKeys class RepositorySettings(private val activity: FragmentActivity) : SettingsProvider { - private val hiltEntryPoint = + private val hiltEntryPoint by lazy(LazyThreadSafetyMode.NONE) { EntryPointAccessors.fromApplication( activity.applicationContext, RepositorySettingsEntryPoint::class.java, ) - private val encryptedPreferences = hiltEntryPoint.encryptedPreferences() - private val gitSettings = hiltEntryPoint.gitSettings() + } private fun <T : FragmentActivity> launchActivity(clazz: Class<T>) { activity.startActivity(Intent(activity, clazz)) @@ -66,6 +65,9 @@ class RepositorySettings(private val activity: FragmentActivity) : SettingsProvi } override fun provideSettings(builder: PreferenceScreen.Builder) { + val encryptedPreferences = hiltEntryPoint.encryptedPreferences() + val gitSettings = hiltEntryPoint.gitSettings() + builder.apply { checkBox(PreferenceKeys.REBASE_ON_PULL) { titleRes = R.string.pref_rebase_on_pull_title diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt index be0527a2..54e1e2e5 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/git/GitCommandExecutor.kt @@ -34,14 +34,14 @@ class GitCommandExecutor( private val operation: GitOperation, ) { - private val hiltEntryPoint = + private val hiltEntryPoint by lazy(LazyThreadSafetyMode.NONE) { EntryPointAccessors.fromApplication( activity.applicationContext, GitCommandExecutorEntryPoint::class.java ) - private val gitSettings = hiltEntryPoint.gitSettings() - + } suspend fun execute(): Result<Unit, Throwable> { + val gitSettings = hiltEntryPoint.gitSettings() val snackbar = activity.snackbar( message = activity.resources.getString(R.string.git_operation_running), @@ -126,6 +126,7 @@ class GitCommandExecutor( @EntryPoint @InstallIn(SingletonComponent::class) interface GitCommandExecutorEntryPoint { + fun gitSettings(): GitSettings } } |