Improve API

This commit is contained in:
Benoit Marty 2019-12-22 07:23:30 +01:00
parent d88e5d8af8
commit 8597c2b9a2
2 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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() {