Skip to content

Commit 86925c2

Browse files
committed
Add support to set movement method for HTML text
1 parent 1c09aa4 commit 86925c2

File tree

1 file changed

+21
-1
lines changed
  • dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support

1 file changed

+21
-1
lines changed

dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/Dynamic.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import android.os.Bundle;
3131
import android.text.TextUtils;
3232
import android.text.TextWatcher;
33+
import android.text.method.MovementMethod;
3334
import android.view.Menu;
3435
import android.view.View;
3536
import android.view.Window;
@@ -1634,7 +1635,9 @@ public static <T> void setShowDividersNoInspection(@Nullable T view, int showDiv
16341635
((LinearLayoutCompat) view).setShowDividers(showDividers);
16351636
}
16361637
} else if (view instanceof Menu) {
1638+
if (DynamicSdkUtils.is28()) {
16371639
((Menu) view).setGroupDividerEnabled(true);
1640+
}
16381641
}
16391642
}
16401643

@@ -2035,21 +2038,38 @@ public static void set(@Nullable RatingBar ratingBar, float rating) {
20352038
*
20362039
* @param textView The text view to set the text.
20372040
* @param text The text to be set.
2041+
* @param movement The optional movement method to be set.
20382042
*/
2039-
public static void setHtml(@Nullable TextView textView, @Nullable CharSequence text) {
2043+
public static void setHtml(@Nullable TextView textView,
2044+
@Nullable CharSequence text, @Nullable MovementMethod movement) {
20402045
if (textView == null) {
20412046
return;
20422047
}
20432048

20442049
if (text != null && !TextUtils.isEmpty(text)) {
20452050
textView.setText(HtmlCompat.fromHtml(text.toString(),
20462051
HtmlCompat.FROM_HTML_MODE_COMPACT));
2052+
if (movement != null) {
2053+
textView.setMovementMethod(movement);
2054+
}
20472055
textView.setVisibility(View.VISIBLE);
20482056
} else {
20492057
textView.setVisibility(View.GONE);
20502058
}
20512059
}
20522060

2061+
/**
2062+
* Set {@code HTML} text for the text view and manage its visibility according to the data.
2063+
*
2064+
* @param textView The text view to set the text.
2065+
* @param text The text to be set.
2066+
*
2067+
* @see #setHtml(TextView, CharSequence, MovementMethod)
2068+
*/
2069+
public static void setHtml(@Nullable TextView textView, @Nullable CharSequence text) {
2070+
setHtml(textView, text, null);
2071+
}
2072+
20532073
/**
20542074
* Set drawable for the image view and manage its visibility according to the data.
20552075
*

0 commit comments

Comments
 (0)