Example usage for android.text Layout getParagraphDirection

List of usage examples for android.text Layout getParagraphDirection

Introduction

In this page you can find the example usage for android.text Layout getParagraphDirection.

Prototype

public abstract int getParagraphDirection(int line);

Source Link

Document

Returns the primary directionality of the paragraph containing the specified line, either 1 for left-to-right lines, or -1 for right-to-left lines (see #DIR_LEFT_TO_RIGHT , #DIR_RIGHT_TO_LEFT ).

Usage

From source file:org.wikipedia.page.shareafact.SnippetImage.java

/**
 * Creates a card image usable for sharing and the preview of the same.
 * If we have a leadImageBitmap the use that as the background. If not then
 * just use a black background./*from   w w w .  ja  v a2 s  . c o  m*/
 */
public static Bitmap getSnippetImage(@NonNull Context context, @Nullable Bitmap leadImageBitmap,
        @NonNull String title, @Nullable String description, @NonNull CharSequence textSnippet,
        @NonNull ImageLicense license) {
    Bitmap resultBitmap = drawBackground(leadImageBitmap, license);
    Canvas canvas = new Canvas(resultBitmap);
    if (leadImageBitmap != null) {
        drawGradient(canvas);
    }

    Layout textLayout = drawTextSnippet(canvas, textSnippet);
    boolean isArticleRTL = textLayout.getParagraphDirection(0) == Layout.DIR_RIGHT_TO_LEFT;

    drawLicenseIcons(context, leadImageBitmap, license, canvas, isArticleRTL);
    int top = drawDescription(canvas, description, HEIGHT - BOTTOM_PADDING - ICONS_HEIGHT, isArticleRTL);
    drawTitle(canvas, title, top, isArticleRTL);
    if (L10nUtil.canLangUseImageForWikipediaWordmark(context)) {
        drawWordmarkFromStaticImage(context, canvas, isArticleRTL);
    } else {
        drawWordmarkFromText(context, canvas, isArticleRTL);
    }

    return resultBitmap;
}