summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/TextView.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 34fe935b55a0..6c84f35f06f5 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11808,8 +11808,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
public boolean hasSelection() {
final int selectionStart = getSelectionStart();
final int selectionEnd = getSelectionEnd();
+ final int selectionMin;
+ final int selectionMax;
+ if (selectionStart < selectionEnd) {
+ selectionMin = selectionStart;
+ selectionMax = selectionEnd;
+ } else {
+ selectionMin = selectionEnd;
+ selectionMax = selectionStart;
+ }
- return selectionStart >= 0 && selectionEnd > 0 && selectionStart != selectionEnd;
+ return selectionMin >= 0 && selectionMax > 0 && selectionMin != selectionMax;
}
String getSelectedText() {