Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SupportUtil.java « util « shared « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8bf80cb9f7fe4097047eaf0d38cedd16250f426a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package it.niedermann.owncloud.notes.shared.util;

import android.text.method.LinkMovementMethod;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.text.HtmlCompat;

/**
 * Some helper functionality in alike the Android support library.
 * Currently, it offers methods for working with HTML string resources.
 */
public class SupportUtil {

    private SupportUtil() {

    }

    /**
     * Fills a {@link TextView} with HTML content and activates links in that {@link TextView}.
     *
     * @param view       The {@link TextView} which should be filled.
     * @param stringId   The string resource containing HTML tags (escaped by <code>&lt;</code>)
     * @param formatArgs Arguments for the string resource.
     */
    public static void setHtml(@NonNull TextView view, int stringId, Object... formatArgs) {
        view.setText(HtmlCompat.fromHtml(
                view.getResources().getString(stringId, formatArgs), HtmlCompat.FROM_HTML_MODE_LEGACY));
        view.setMovementMethod(LinkMovementMethod.getInstance());
    }
}