@@ -33,7 +33,7 @@ public final class TextEllipsizer {
3333 @ Nullable private StreamingService streamingService ;
3434 @ Nullable private String streamUrl ;
3535 private boolean isEllipsized = false ;
36- @ Nullable private Boolean caBeEllipsized = null ;
36+ @ Nullable private Boolean canBeEllipsized = null ;
3737
3838 @ NonNull private final Paint paintAtContentSize = new Paint ();
3939 private final float ellipsisWidthPx ;
@@ -45,6 +45,7 @@ public TextEllipsizer(@NonNull final TextView view,
4545 @ Nullable final StreamingService streamingService ) {
4646 this .view = view ;
4747 this .maxLines = maxLines ;
48+ this .content = Description .EMPTY_DESCRIPTION ;
4849 this .streamingService = streamingService ;
4950
5051 paintAtContentSize .setTextSize (view .getTextSize ());
@@ -57,14 +58,14 @@ public void setOnContentChanged(@Nullable final Consumer<Boolean> onContentChang
5758
5859 public void setContent (@ NonNull final Description content ) {
5960 this .content = content ;
60- caBeEllipsized = null ;
61+ canBeEllipsized = null ;
6162 linkifyContentView (v -> {
6263 final int currentMaxLines = view .getMaxLines ();
6364 view .setMaxLines (EXPANDED_LINES );
64- caBeEllipsized = view .getLineCount () > maxLines ;
65+ canBeEllipsized = view .getLineCount () > maxLines ;
6566 view .setMaxLines (currentMaxLines );
6667 if (onContentChanged != null ) {
67- onContentChanged .accept (caBeEllipsized );
68+ onContentChanged .accept (canBeEllipsized );
6869 }
6970 });
7071 }
@@ -135,7 +136,7 @@ public void ellipsize() {
135136 }
136137
137138 /**
138- * Toggle the view between the ellipsed and expanded state.
139+ * Toggle the view between the ellipsized and expanded state.
139140 */
140141 public void toggle () {
141142 if (isEllipsized ) {
@@ -146,16 +147,17 @@ public void toggle() {
146147 }
147148
148149 /**
149- * Whether the {@link view} can be ellipsized.
150- * This is only the case when the {@link content} has more lines
151- * than allowed via {@link maxLines}.
152- * @return {@code true} if the {@link content} has more lines than allowed via {@link maxLines}
153- * and thus can be shortened, {@code false} if the {@code content} fits into the {@link view}
154- * without being shortened and {@code null} if the initialization is not completed yet.
150+ * Whether the {@link #view} can be ellipsized.
151+ * This is only the case when the {@link #content} has more lines
152+ * than allowed via {@link #maxLines}.
153+ * @return {@code true} if the {@link #content} has more lines than allowed via
154+ * {@link #maxLines} and thus can be shortened, {@code false} if the {@code content} fits into
155+ * the {@link #view} without being shortened and {@code null} if the initialization is not
156+ * completed yet.
155157 */
156158 @ Nullable
157159 public Boolean canBeEllipsized () {
158- return caBeEllipsized ;
160+ return canBeEllipsized ;
159161 }
160162
161163 private void linkifyContentView (final Consumer <View > consumer ) {
@@ -173,19 +175,15 @@ private void linkifyContentView(final Consumer<View> consumer) {
173175 /**
174176 * Add a listener which is called when the given content is changed,
175177 * either from <em>ellipsized</em> to <em>full</em> or vice versa.
176- * @param listener The listener to be called.
178+ * @param listener The listener to be called, or {@code null} to remove it .
177179 * The Boolean parameter is the new state.
178180 * <em>Ellipsized</em> content is represented as {@code true},
179181 * normal or <em>full</em> content by {@code false}.
180182 */
181- public void setStateChangeListener (final Consumer <Boolean > listener ) {
183+ public void setStateChangeListener (@ Nullable final Consumer <Boolean > listener ) {
182184 this .stateChangeListener = listener ;
183185 }
184186
185- public void removeStateChangeListener () {
186- this .stateChangeListener = null ;
187- }
188-
189187 private void notifyStateChangeListener (final boolean oldState ) {
190188 if (oldState != isEllipsized && stateChangeListener != null ) {
191189 stateChangeListener .accept (isEllipsized );
0 commit comments