static int GetSelectionEnd(AppCompatEditText editText, IEntry entry, int start)
        {
            int end             = start;
            int selectionLength = entry.SelectionLength;

            end = System.Math.Max(start, System.Math.Min(editText.Length(), start + selectionLength));
            int newSelectionLength = System.Math.Max(0, end - start);

            // Updating this property results in UpdateSelectionLength being called again messing things up
            if (newSelectionLength != selectionLength)
            {
                entry.SelectionLength = newSelectionLength;
            }
            return(end);
        }
        static int GetSelectionStart(AppCompatEditText editText, IEntry entry)
        {
            int start          = editText.Length();
            int cursorPosition = entry.CursorPosition;

            if (editText.Text != null)
            {
                // Capping cursorPosition to the end of the text if needed
                start = System.Math.Min(editText.Text.Length, cursorPosition);
            }

            if (start != cursorPosition)
            {
                // Update the interface if start was capped
                entry.CursorPosition = start;
            }

            return(start);
        }