Java Code Examples for android.text.TextDirectionHeuristics#FIRSTSTRONG_RTL
The following examples show how to use
android.text.TextDirectionHeuristics#FIRSTSTRONG_RTL .
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: StaticLayoutProxy.java From TextLayoutBuilder with Apache License 2.0 | 6 votes |
public static TextDirectionHeuristic fromTextDirectionHeuristicCompat( TextDirectionHeuristicCompat textDirection) { if (textDirection == TextDirectionHeuristicsCompat.LTR) { return TextDirectionHeuristics.LTR; } else if (textDirection == TextDirectionHeuristicsCompat.RTL) { return TextDirectionHeuristics.RTL; } else if (textDirection == TextDirectionHeuristicsCompat.FIRSTSTRONG_LTR) { return TextDirectionHeuristics.FIRSTSTRONG_LTR; } else if (textDirection == TextDirectionHeuristicsCompat.FIRSTSTRONG_RTL) { return TextDirectionHeuristics.FIRSTSTRONG_RTL; } else if (textDirection == TextDirectionHeuristicsCompat.ANYRTL_LTR) { return TextDirectionHeuristics.ANYRTL_LTR; } else if (textDirection == TextDirectionHeuristicsCompat.LOCALE) { return TextDirectionHeuristics.LOCALE; } else { return TextDirectionHeuristics.FIRSTSTRONG_LTR; } }
Example 2
Source File: CustomTypefaceSpan.java From edx-app-android with Apache License 2.0 | 4 votes |
@TargetApi(JELLY_BEAN_MR1) @CheckResult private boolean needMirroring() { if (!mirrorable) return false; // Passwords fields should be LTR if (view.getTransformationMethod() instanceof PasswordTransformationMethod) { return false; } // Always need to resolve layout direction first final boolean defaultIsRtl = view.getLayoutDirection() == LAYOUT_DIRECTION_RTL; if (SDK_INT < JELLY_BEAN_MR2) { return defaultIsRtl; } // Select the text direction heuristic according to the // package-private getTextDirectionHeuristic() method in TextView TextDirectionHeuristic textDirectionHeuristic; switch (view.getTextDirection()) { default: case TEXT_DIRECTION_FIRST_STRONG: textDirectionHeuristic = defaultIsRtl ? TextDirectionHeuristics.FIRSTSTRONG_RTL : TextDirectionHeuristics.FIRSTSTRONG_LTR; break; case TEXT_DIRECTION_ANY_RTL: textDirectionHeuristic = TextDirectionHeuristics.ANYRTL_LTR; break; case TEXT_DIRECTION_LTR: textDirectionHeuristic = TextDirectionHeuristics.LTR; break; case TEXT_DIRECTION_RTL: textDirectionHeuristic = TextDirectionHeuristics.RTL; break; case TEXT_DIRECTION_LOCALE: textDirectionHeuristic = TextDirectionHeuristics.LOCALE; break; case TEXT_DIRECTION_FIRST_STRONG_LTR: textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_LTR; break; case TEXT_DIRECTION_FIRST_STRONG_RTL: textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_RTL; break; } CharSequence text = view.getText(); return textDirectionHeuristic.isRtl(text, 0, text.length()); }