allstraws
allstraws

Reputation: 129

Does findViewById has priority over ButterKnife's bind method call?

In my activity's onCreateView I have two different source views to inflate UI elements. So I am inflating all the UI elements that belong to one source view by findViewById() and those that belong to the other source view using ButterKnife's Bind method call.

But this will work only if findViewById has priority over ButterKnife, otherwise first set of elements would also get attached to the second source view.

So is it true that findViewById has priority over ButterKnife?

Upvotes: 1

Views: 294

Answers (2)

Saket Mittal
Saket Mittal

Reputation: 3906

Bas van Stein is right ButterKnife's Bind has no priority but you can use Android Priority Job Queue

Priority Job Queue is an implementation of a Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.

You define your background tasks as Jobs and enqueue them to your JobManager instance. Job Manager will take care of prioritization

Upvotes: 0

Niki van Stein
Niki van Stein

Reputation: 10734

Under the hood ButterKnife's Bind is being executed as findViewById with an integer value of the id, rather than the lookup R.id.something, this means that both methods are actually performing the same and have the same "priority", it just depends which one you execute first.

So the answer is "no, ButterKnife's Bind has no priority, though the execution can be a bit faster due to the lookup"

Upvotes: 3

Related Questions