Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Fix an issue where message text occasionally becomes unselectable. #139

Merged
merged 1 commit into from Apr 17, 2016

Conversation

nolanlum
Copy link
Contributor

There's a full write-up in the commit message. This bug was a pain to track down.

(This is probably the only occasion when the excessive amount of logcat messages from the Android system libraries actually came in handy!)

… become unselectable.

Occasionally, message TextViews would, despite being marked selectable in the view XML, fail to allow selection (a warning gets printed to logcat when this occurs). The root cause of this issue seems the RecyclerView ViewHolder lifecycle, a part of which involves updating the text displayed in the message TextView before the view is attached to a window. This causes the TextView to internally cache the fact that its view hierarchy does not support selection handles, and therefore disallow selection.

The fix is to call setText to "update" the text after the TextView has been reattached to a window. This forces a call to android.widget.Editor#prepareCursorControllers, and re-allows selection.

The timestamp TextView is not affected due to an implementation detail in how the layout of the RecyclerView items are computed; since the message is marked as being to the right of the timestamp, the code path to calculate the width of the timestamp TextView calls prepareCursorControllers for us.
@LalitMaganti LalitMaganti merged commit 95a8aa3 into LalitMaganti:master Apr 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants