Skip to content

Instantly share code, notes, and snippets.

@abbas-oveissi
Created February 28, 2020 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abbas-oveissi/43616c72637db17959e15b4508ccee20 to your computer and use it in GitHub Desktop.
Save abbas-oveissi/43616c72637db17959e15b4508ccee20 to your computer and use it in GitHub Desktop.
void drawCustomMethod(Canvas canvas) {
int startLine = getTouchedLine(startX, startY);
int startCharPos = getCharPositionByTouch(startX, startY, startLine);
int currentLine = getTouchedLine(currentX, currentY);
int currentCharPos = getCharPositionByTouch(currentX, currentY, currentLine);
if(startLine == currentLine) {
drawSelection(canvas,startCharPos,currentCharPos,startLine);
return;
}
for (int i = startLine; i <= currentLine; i++) {
if(startLine == i) {
drawSelection(canvas,startCharPos,getLayout().getLineEnd(i),i);
continue;
}
if(currentLine == i) {
drawSelection(canvas,getLayout().getLineStart(i),currentCharPos,i);
continue;
}
drawFullSelection(canvas,i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment