Java Code Examples for android.text.Layout#DIR_LEFT_TO_RIGHT
The following examples show how to use
android.text.Layout#DIR_LEFT_TO_RIGHT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HtmlCompat.java From HtmlCompat with Apache License 2.0 | 6 votes |
private static String getTextDirection(Spanned text, int start, int end) { // FIXME not supported int paraDir = Layout.DIR_LEFT_TO_RIGHT; // final int len = end - start; // final byte[] levels = ArrayUtils.newUnpaddedByteArray(len); // final char[] buffer = TextUtils.obtain(len); // TextUtils.getChars(text, start, end, buffer, 0); // int paraDir = AndroidBidi.bidi(Layout.DIR_REQUEST_DEFAULT_LTR, buffer, levels, len, // false /* no info */); switch (paraDir) { case Layout.DIR_RIGHT_TO_LEFT: return " dir=\"rtl\""; case Layout.DIR_LEFT_TO_RIGHT: default: return " dir=\"ltr\""; } }
Example 2
Source File: UrlBar.java From delion with Apache License 2.0 | 6 votes |
/** * If the direction of the URL has changed, update mUrlDirection and notify the * UrlDirectionListeners. */ private void updateUrlDirection() { Layout layout = getLayout(); if (layout == null) return; int urlDirection; if (length() == 0) { urlDirection = LAYOUT_DIRECTION_LOCALE; } else if (layout.getParagraphDirection(0) == Layout.DIR_LEFT_TO_RIGHT) { urlDirection = LAYOUT_DIRECTION_LTR; } else { urlDirection = LAYOUT_DIRECTION_RTL; } if (urlDirection != mUrlDirection) { mUrlDirection = urlDirection; if (mUrlDirectionListener != null) { mUrlDirectionListener.onUrlDirectionChanged(urlDirection); } } }
Example 3
Source File: Html.java From ForPDA with GNU General Public License v3.0 | 6 votes |
private static String getTextDirection(Spanned text, int start, int end) { /*final int len = end - start; final byte[] levels = ArrayUtils.newUnpaddedByteArray(len); final char[] buffer = TextUtils.obtain(len); TextUtils.getChars(text, start, end, buffer, 0); int paraDir = AndroidBidi.bidi(Layout.DIR_REQUEST_DEFAULT_LTR, buffer, levels, len, false *//* no info *//*);*/ int paraDir = Layout.DIR_LEFT_TO_RIGHT; switch (paraDir) { case Layout.DIR_RIGHT_TO_LEFT: return " dir=\"rtl\""; case Layout.DIR_LEFT_TO_RIGHT: default: return " dir=\"ltr\""; } }
Example 4
Source File: UrlBar.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * If the direction of the URL has changed, update mUrlDirection and notify the * UrlDirectionListeners. */ private void updateUrlDirection() { Layout layout = getLayout(); if (layout == null) return; int urlDirection; if (length() == 0) { urlDirection = LAYOUT_DIRECTION_LOCALE; } else if (layout.getParagraphDirection(0) == Layout.DIR_LEFT_TO_RIGHT) { urlDirection = LAYOUT_DIRECTION_LTR; } else { urlDirection = LAYOUT_DIRECTION_RTL; } if (urlDirection != mUrlDirection) { mUrlDirection = urlDirection; if (mUrlDirectionListener != null) { mUrlDirectionListener.onUrlDirectionChanged(urlDirection); } } }
Example 5
Source File: UrlBar.java From 365browser with Apache License 2.0 | 6 votes |
/** * If the direction of the URL has changed, update mUrlDirection and notify the * UrlDirectionListeners. */ private void updateUrlDirection() { Layout layout = getLayout(); if (layout == null) return; int urlDirection; if (length() == 0) { urlDirection = LAYOUT_DIRECTION_LOCALE; } else if (layout.getParagraphDirection(0) == Layout.DIR_LEFT_TO_RIGHT) { urlDirection = LAYOUT_DIRECTION_LTR; } else { urlDirection = LAYOUT_DIRECTION_RTL; } if (urlDirection != mUrlDirection) { mUrlDirection = urlDirection; if (mUrlDirectionListener != null) { mUrlDirectionListener.onUrlDirectionChanged(urlDirection); } } }
Example 6
Source File: ComposedFrame.java From Tehreer-Android with Apache License 2.0 | 4 votes |
/** * Draws this frame onto the given <code>canvas</code> using the given <code>renderer</code>. * * @param renderer The renderer to use for drawing this frame. * @param canvas The canvas onto which to draw this frame. * @param x The x- position at which to draw this frame. * @param y The y- position at which to draw this frame. */ public void draw(@NonNull Renderer renderer, @NonNull Canvas canvas, float x, float y) { canvas.translate(x, y); drawBackground(canvas); int lineCount = lineList.size(); for (int i = 0; i < lineCount; i++) { ComposedLine composedLine = lineList.get(i); Object[] lineSpans = composedLine.getSpans(); int lineLeft = 0; int lineRight = (int) (mWidth + 0.5f); // Draw leading margins of this line. for (Object style : lineSpans) { if (style instanceof LeadingMarginSpan) { LeadingMarginSpan span = (LeadingMarginSpan) style; byte paragraphLevel = composedLine.getParagraphLevel(); boolean isLTR = (paragraphLevel & 1) == 0; Paint paint = lazyPaint(); int margin = (isLTR ? lineLeft : lineRight); int direction = (isLTR ? Layout.DIR_LEFT_TO_RIGHT : Layout.DIR_RIGHT_TO_LEFT); int lineTop = (int) (composedLine.getTop() + 0.5f); int lineBaseline = (int) (composedLine.getOriginY() + 0.5f); int lineBottom = (int) (composedLine.getTop() + composedLine.getHeight() + 0.5f); Spanned sourceText = (Spanned) source; int lineStart = composedLine.getCharStart(); int lineEnd = composedLine.getCharEnd(); boolean isFirst = composedLine.isFirst(); span.drawLeadingMargin(canvas, paint, margin, direction, lineTop, lineBaseline, lineBottom, sourceText, lineStart, lineEnd, isFirst, null); if (isLTR) { lineLeft += span.getLeadingMargin(isFirst); } else { lineRight -= span.getLeadingMargin(isFirst); } } } composedLine.draw(renderer, canvas, composedLine.getOriginX(), composedLine.getOriginY()); } canvas.translate(-x, -y); }