Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Re-use current Thread for @UiThread #604

Copy link
Copy link
@dkunzler

Description

@dkunzler
Issue body actions

This is not really a defect but an enhancement.

My suggestion is to check in which thread the method invocation is currently running for methods annotated with @UiThread (without delay). If the current thread is already the UI thread, there should be no handler.post of a Runnable but instead the method should be executed synchronously.
I encountered undesired side effects when being already in the UI thread an calling such a method because of the delay in the execution.

In the generated code it would roughly look like this:

if (delay == 0 && Looper.getMainLooper().getThread() == Thread.currentThread()) {
  // On UI thread.
  // execute method directly
} else {
  // Not on UI thread.
  // create runnable and do handler.post
}

http://stackoverflow.com/questions/2848575/how-to-detect-ui-thread-on-android

At the moment I don't have the time to look into it for myself, but if others are interested in this feature too but nobody wants to do it, I could try it for myself in the next weeks.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.