diff options
-rw-r--r-- | src/com/android/ex/chips/DropdownChipLayouter.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java index 882cd9f..622dc25 100644 --- a/src/com/android/ex/chips/DropdownChipLayouter.java +++ b/src/com/android/ex/chips/DropdownChipLayouter.java @@ -28,6 +28,7 @@ import com.android.ex.chips.ResultAnimationDrawable.STATE; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * A class that inflates and binds the views in the dropdown list from @@ -222,6 +223,16 @@ public class DropdownChipLayouter { return bindView(convertView, parent, entry, position, type, constraint, null); } + public static boolean isRTL() { + return isRTL(Locale.getDefault()); + } + + public static boolean isRTL(Locale locale) { + final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0)); + return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT || + directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; + } + /** * See {@link #bindView(View, ViewGroup, RecipientEntry, int, AdapterType, String)} * @param deleteDrawable @@ -277,6 +288,16 @@ public class DropdownChipLayouter { destinationType = null; } + if (!TextUtils.isEmpty(destination)) { + if (isRTL()) { + if (destination.contains("+")) { + // Move the plus sign to the rear so it displays at the beginning + destination = destination.replace("+", ""); + destination = destination + "+"; + } + } + } + // Bind the information to the view bindTextToView(displayName, viewHolder.displayNameView); bindTextToView(destination, viewHolder.destinationView); |