-
Notifications
You must be signed in to change notification settings - Fork 80
Description
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