import android.annotation.Nullable;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.text.style.ParagraphStyle;
import android.util.Log;
import com.android.internal.util.ArrayUtils;
if (adjustSelection) {
boolean changed = false;
if (selectionStart > start && selectionStart < end) {
- final int offset = (selectionStart - start) * newLen / origLen;
+ final long diff = selectionStart - start;
+ final int offset = Math.toIntExact(diff * newLen / origLen);
selectionStart = start + offset;
changed = true;
Spanned.SPAN_POINT_POINT);
}
if (selectionEnd > start && selectionEnd < end) {
- final int offset = (selectionEnd - start) * newLen / origLen;
+ final long diff = selectionEnd - start;
+ final int offset = Math.toIntExact(diff * newLen / origLen);
selectionEnd = start + offset;
changed = true;