Skip to content

GUI elements must not be accessed from non-main threads #94

@tmtron

Description

@tmtron

As far as I understand the following code from DebounceSearchEmitterFragment.java#L76:

_disposable = RxJavaInterop.toV2Observable(RxTextView.textChangeEvents(_inputSearchText))
              .debounce(400, TimeUnit.MILLISECONDS)// default Scheduler is Computation
              .filter(changes -> isNotNullOrEmpty(_inputSearchText.getText().toString()))
              .observeOn(AndroidSchedulers.mainThread())
              .subscribeWith(_getSearchObserver());

filter() accesses the GUI element _inputSearchText, which it must not do: see StackOverflow: Is it okay to read data from UI elements in another thread?

Instead the text should be read from the change-event like this:
.filter(changes -> isNotNullOrEmpty(changes.text().toString()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions