Example usage for android.text Layout DIR_RIGHT_TO_LEFT

List of usage examples for android.text Layout DIR_RIGHT_TO_LEFT

Introduction

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

Prototype

int DIR_RIGHT_TO_LEFT

To view the source code for android.text Layout DIR_RIGHT_TO_LEFT.

Click Source Link

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  ww  w .j a  v  a2s.  c om
 */
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;
}