Java Code Examples for android.support.v4.text.TextUtilsCompat#getLayoutDirectionFromLocale()
The following examples show how to use
android.support.v4.text.TextUtilsCompat#getLayoutDirectionFromLocale() .
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: GravitySnapHelper.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
@Override public void attachToRecyclerView(@Nullable RecyclerView recyclerView) throws IllegalStateException { if (this.recyclerView != null) { this.recyclerView.removeOnScrollListener(scrollListener); } if (recyclerView != null) { recyclerView.setOnFlingListener(null); if (gravity == Gravity.START || gravity == Gravity.END) { isRtl = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; } recyclerView.addOnScrollListener(scrollListener); this.recyclerView = recyclerView; } else { this.recyclerView = null; } super.attachToRecyclerView(recyclerView); }
Example 2
Source File: ListPopupWindow.java From MDPreference with Apache License 2.0 | 6 votes |
/** * Create a new, empty popup window capable of displaying items from a ListAdapter. * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. * @param defStyleAttr Default style attribute to use for popup content. * @param defStyleRes Default style to use for popup content. */ public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { mContext = context; final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPopupWindow, defStyleAttr, defStyleRes); mDropDownHorizontalOffset = a.getDimensionPixelOffset( R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0); mDropDownVerticalOffset = a.getDimensionPixelOffset( R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0); if (mDropDownVerticalOffset != 0) { mDropDownVerticalOffsetSet = true; } a.recycle(); mPopup = new PopupWindow(context, attrs, defStyleAttr); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); // Set the default layout direction to match the default locale one final Locale locale = mContext.getResources().getConfiguration().locale; mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(locale); }
Example 3
Source File: FlowLayout.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
public FlowLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TagFlowLayout); mGravity = ta.getInt(R.styleable.TagFlowLayout_tag_gravity, LEFT); int layoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()); if (layoutDirection == LayoutDirection.RTL) { if (mGravity == LEFT) { mGravity = RIGHT; } else { mGravity = LEFT; } } ta.recycle(); }
Example 4
Source File: LabelSpan.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
public LabelSpan(int color) { this(color, new SpanDimensions() { @Override public int getPadding() { return 6; } @Override public int getPaddingExtraWidth() { return 0; } @Override public int getPaddingAfter() { return 0; } @Override public int getMaxWidth() { return 1000;//random number } @Override public float getRoundedCornerRadius() { return 5; } @Override public int getMarginTop() { return 8; } @Override public boolean isRtl() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; } }); }
Example 5
Source File: ContextUtils.java From memetastic with GNU General Public License v3.0 | 5 votes |
/** * Try to make icons in Toolbar/ActionBars SubMenus visible * This may not work on some devices and it maybe won't work on future android updates */ public void setSubMenuIconsVisiblity(final Menu menu, final boolean visible) { if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) { return; } if (menu.getClass().getSimpleName().equals("MenuBuilder")) { try { @SuppressLint("PrivateApi") Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); m.setAccessible(true); m.invoke(menu, visible); } catch (Exception ignored) { Log.d(getClass().getName(), "Error: 'setSubMenuIconsVisiblity' not supported on this device"); } } }
Example 6
Source File: ContextUtils.java From openlauncher with Apache License 2.0 | 5 votes |
/** * Try to make icons in Toolbar/ActionBars SubMenus visible * This may not work on some devices and it maybe won't work on future android updates */ public void setSubMenuIconsVisiblity(final Menu menu, final boolean visible) { if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) { return; } if (menu.getClass().getSimpleName().equals("MenuBuilder")) { try { @SuppressLint("PrivateApi") Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); m.setAccessible(true); m.invoke(menu, visible); } catch (Exception ignored) { Log.d(getClass().getName(), "Error: 'setSubMenuIconsVisiblity' not supported on this device"); } } }
Example 7
Source File: ClearBrowsingDataTabsFragment.java From 365browser with Apache License 2.0 | 5 votes |
private static int adjustIndexForDirectionality(int index) { if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL) { return CBD_TAB_COUNT - 1 - index; } return index; }
Example 8
Source File: FlowLayout.java From FlowLayout with Apache License 2.0 | 5 votes |
public FlowLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TagFlowLayout); mGravity = ta.getInt(R.styleable.TagFlowLayout_tag_gravity, LEFT); int layoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()); if (layoutDirection == LayoutDirection.RTL) { if (mGravity == LEFT) { mGravity = RIGHT; } else { mGravity = LEFT; } } ta.recycle(); }
Example 9
Source File: LocalUtils.java From material-calendarview with MIT License | 4 votes |
static boolean isRTL() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 10
Source File: LocaleUtil.java From droidkaigi2016 with Apache License 2.0 | 4 votes |
public static boolean shouldRtl() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 11
Source File: RecyclerViewPager.java From RecyclerViewPager with Apache License 2.0 | 4 votes |
private boolean isLeftToRightMode(){ return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR; }
Example 12
Source File: TabularContextMenuPagerAdapter.java From 365browser with Apache License 2.0 | 4 votes |
/** * Used in combination of a TabLayout to create a multi view layout. * @param views Thew views to use in the pager Adapter. */ TabularContextMenuPagerAdapter(List<Pair<String, ViewGroup>> views) { mViewList = views; mIsRightToLeft = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 13
Source File: LocaleUtil.java From droidkaigi2016 with Apache License 2.0 | 4 votes |
public static boolean shouldRtl() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 14
Source File: Utils.java From FireFiles with Apache License 2.0 | 4 votes |
public static boolean isRTL() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 15
Source File: Utils.java From FireFiles with Apache License 2.0 | 4 votes |
public static boolean isRTL() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 16
Source File: Utils.java From FireFiles with Apache License 2.0 | 4 votes |
public static boolean isRTL() { return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == android.support.v4.view.ViewCompat.LAYOUT_DIRECTION_RTL; }
Example 17
Source File: I18nUtil.java From react-native-GPay with MIT License | 4 votes |
private boolean isDevicePreferredLanguageRTL() { final int directionality = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()); return directionality == ViewCompat.LAYOUT_DIRECTION_RTL; }