Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar's subtitle is cleared if subtitle set programmatically #63

Open
idunnololz opened this issue Dec 10, 2023 · 0 comments
Open

Toolbar's subtitle is cleared if subtitle set programmatically #63

idunnololz opened this issue Dec 10, 2023 · 0 comments

Comments

@idunnololz
Copy link

I have a toolbar whose subtitle is set programmatically based on arguments supplied to the fragment. If I use Calligraphy, the subtitle is cleared after it is set. The culprit is Calligraphy.

Calligraphy sets a ToolbarLayoutListener whenever a layout is inflated that contained a Toolbar. When this listener is registered, it immediately takes a snapshot of the value of the subtitle. On global layout, it then restores the value of the subtitle to the value it snapshotted. The issue is, if I set the subtitle of the Toolbar between these events (eg. in onViewCreated()), then that value is discarded.

I'm not certain why Calligraphy needs to snapshot the subtitle but this behavior is unintuitive and the only fix I can think of is registering my own GlobalLayoutListener and setting the subtitle after Calligraphy is done restoring the snapshotted subtitle.

Code where caligraphy registers the global layout listener: https://github.com/InflationX/Calligraphy/blob/master/calligraphy/src/main/java/io/github/inflationx/calligraphy3/Calligraphy.java#L158
Code where caligraphy is snapshotting the value of the subtitle: https://github.com/InflationX/Calligraphy/blob/master/calligraphy/src/main/java/io/github/inflationx/calligraphy3/Calligraphy.java#L230
Code where caligraphy restores the value of the subtitle: https://github.com/InflationX/Calligraphy/blob/master/calligraphy/src/main/java/io/github/inflationx/calligraphy3/Calligraphy.java#L253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant