Repository navigation
Use view binding to get rid of findViewById - #3890
Merged
Merged
Conversation
maniac103
force-pushed
the
no-findviewbyid
branch
2 times, most recently
from
April 25, 2025 10:43
d81cad4 to
5f52963
Compare
Member
|
Nice work! This is something I also wanted to do at some point. I'll have a look at running the emulator in CI, but for now you can add the test case to the repo and execute it locally. |
Contributor
Author
|
Added the test, and it even found something ;-) Unfortunately it doesn't seem possible to exempt single views from being included in the binding. |
Merged
Contributor
Author
|
@mueller-ma This conflicts with #3898, I guess check that one first? I'll rebase and undraft this one afterwards. |
maniac103
force-pushed
the
no-findviewbyid
branch
from
July 16, 2025 13:02
d3dab3f to
dc05bd2
Compare
maniac103
marked this pull request as ready for review
July 16, 2025 13:02
mueller-ma
requested changes
Jul 19, 2025
Closed
5 of 10 tasks
maniac103
force-pushed
the
no-findviewbyid
branch
from
November 7, 2025 16:06
4262748 to
1bf7fc4
Compare
Member
Only exception is WidgetAdapter due to its internal complexity. Signed-off-by: Danny Baumann <dannybaumann@web.de>
Signed-off-by: Danny Baumann <dannybaumann@web.de>
Also fix the one incompatible layout spotted by the unit test. Signed-off-by: Danny Baumann <dannybaumann@web.de>
Signed-off-by: Danny Baumann <dannybaumann@web.de>
Contributor
Author
I don't think we can do much there:
I'll check this. |
Signed-off-by: Danny Baumann <dannybaumann@web.de>
maniac103
force-pushed
the
no-findviewbyid
branch
from
November 20, 2025 08:27
1bf7fc4 to
b760fa1
Compare
Signed-off-by: Danny Baumann <dannybaumann@web.de>
Contributor
Author
Fixed now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Using findViewById is somewhat error prone due to the lack of a direct relationship between the XML description and the usage in code. View binding automatically generates code for creating that relationship.
I've sat on this for quite some time now, for two reasons:
WidgetAdapter, which caused that class to even grow (other code paths became smaller due to less internal member variables andfindViewByIdcalls)For the latter point, writing a unit test should be easy in theory (have a list of widget-layout-binding to compact-widget-layout-binding, inflate the former, bind the latter to the root view of the former), but this needs to be an instrumented Android unit test, and I'm not sure if and how this can be run in GH actions.
@mueller-ma Please let me know your thoughts on this.
TODO:
PrimaryServerPreferencecurrently crashes on bind