From 8597c2b9a2d99d5edcbf3fa2dd9ef89ba30f955e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sun, 22 Dec 2019 07:23:30 +0100 Subject: [PATCH] Improve API --- .../riotx/features/home/room/detail/AutoCompleter.kt | 12 ++++++------ .../features/home/room/detail/RoomDetailFragment.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/AutoCompleter.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/AutoCompleter.kt index ef7715f91a..ba643e2d7d 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/AutoCompleter.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/AutoCompleter.kt @@ -53,7 +53,7 @@ class AutoCompleter @Inject constructor( private val autocompleteRoomPresenter: AutocompleteRoomPresenter, private val autocompleteGroupPresenter: AutocompleteGroupPresenter ) { - private lateinit var fragment: Fragment + private lateinit var editText: EditText fun enterSpecialMode() { commandAutocompletePolicy.enabled = false @@ -64,13 +64,13 @@ class AutoCompleter @Inject constructor( } private val glideRequests by lazy { - GlideApp.with(fragment) + GlideApp.with(editText) } - fun setup(fragment: Fragment, editText: EditText, listener: AutoCompleterListener) { - this.fragment = fragment + fun setup(editText: EditText, listener: AutoCompleterListener) { + this.editText = editText - val backgroundDrawable = ColorDrawable(ThemeUtils.getColor(fragment.requireContext(), R.attr.riotx_background)) + val backgroundDrawable = ColorDrawable(ThemeUtils.getColor(editText.context, R.attr.riotx_background)) setupCommands(backgroundDrawable, editText) setupUsers(backgroundDrawable, editText, listener) @@ -185,7 +185,7 @@ class AutoCompleter @Inject constructor( val span = PillImageSpan( glideRequests, avatarRenderer, - fragment.requireContext(), + editText.context, matrixItem ) span.bind(editText) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index 4ae79e8215..4414c48205 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -559,7 +559,7 @@ class RoomDetailFragment @Inject constructor( } private fun setupComposer() { - autoCompleter.setup(this, composerLayout.composerEditText, this) + autoCompleter.setup(composerLayout.composerEditText, this) composerLayout.callback = object : TextComposerView.Callback { override fun onAddAttachment() {