Kaydet (Commit) 9d0950d5 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

android: make invalidations more readable - extract to own methods

Change-Id: I676475c028d446ff5f31a11990a09da54245f9ef
üst fe4f1194
......@@ -398,28 +398,36 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
}
switch (signalNumber) {
case Document.CALLBACK_INVALIDATE_TILES: {
RectF rect = convertCallbackMessageStringToRectF(payload);
if (rect != null) {
tileInvalidationCallback.invalidate(rect);
}
case Document.CALLBACK_INVALIDATE_TILES:
invalidateTiles(payload);
break;
}
case Document.CALLBACK_INVALIDATE_VISIBLE_CURSOR: {
Log.i(LOGTAG, "Invalidate visible cursor: " + payload);
RectF rect = convertCallbackMessageStringToRectF(payload);
if (rect != null) {
RectF underSelection = new RectF(rect.centerX(), rect.bottom, rect.centerX(), rect.bottom);
TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection();
textSelection.positionHandle(TextSelectionHandle.HandleType.MIDDLE, underSelection);
textSelection.showHandle(TextSelectionHandle.HandleType.MIDDLE);
TextCursorLayer textCursorLayer = LibreOfficeMainActivity.mAppContext.getTextCursorLayer();
textCursorLayer.positionCursor(rect);
textCursorLayer.showCursor();
}
case Document.CALLBACK_INVALIDATE_VISIBLE_CURSOR:
invalidateCursor(payload);
break;
}
}
}
private void invalidateCursor(String payload) {
RectF rect = convertCallbackMessageStringToRectF(payload);
if (rect != null) {
RectF underSelection = new RectF(rect.centerX(), rect.bottom, rect.centerX(), rect.bottom);
TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection();
textSelection.positionHandle(TextSelectionHandle.HandleType.MIDDLE, underSelection);
textSelection.showHandle(TextSelectionHandle.HandleType.MIDDLE);
TextCursorLayer textCursorLayer = LibreOfficeMainActivity.mAppContext.getTextCursorLayer();
textCursorLayer.positionCursor(rect);
textCursorLayer.showCursor();
}
}
private void invalidateTiles(String payload) {
if (tileInvalidationCallback == null) {
return;
}
RectF rect = convertCallbackMessageStringToRectF(payload);
if (rect != null) {
tileInvalidationCallback.invalidate(rect);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment