From 3dace243e4b0fe1378e2d81c46fb70cb236e6ae5 Mon Sep 17 00:00:00 2001 From: Fabian Henneke Date: Thu, 6 Aug 2020 10:58:20 +0200 Subject: Refactor uses of applicationContext and startActivityForResult (#997) * Refactor uses of applicationContext and startActivityForResult This commit applies three types of refactoring: 1. Remove context argument from PasswordRepository companion functions by relying on Application.instance. 2. Introduce a sharedPrefs extension function on Context that returns the default SharedPreferences for the applicationContext. 3. Use OpenDocument() and OpenDocumentTree() contracts. * Drop toPasswordItem argument --- .../com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/ui') diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt index 4e153b88..9d5487ab 100644 --- a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt +++ b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt @@ -19,6 +19,7 @@ import com.zeapo.pwdstore.SearchableRepositoryAdapter import com.zeapo.pwdstore.stableId import com.zeapo.pwdstore.utils.PasswordItem import com.zeapo.pwdstore.utils.PreferenceKeys +import com.zeapo.pwdstore.utils.sharedPrefs import java.io.File open class PasswordItemRecyclerAdapter : @@ -49,8 +50,7 @@ open class PasswordItemRecyclerAdapter : lateinit var itemDetails: ItemDetailsLookup.ItemDetails fun bind(item: PasswordItem) { - val settings = - PreferenceManager.getDefaultSharedPreferences(itemView.context.applicationContext) + val settings = itemView.context.sharedPrefs val showHidden = settings.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false) val parentPath = item.fullPathToParent.replace("(^/)|(/$)".toRegex(), "") val source = if (parentPath.isNotEmpty()) { -- cgit v1.2.3