summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-04-03 18:23:45 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-07 09:18:16 +0200
commit2bbf630d9669a9fd5f961a2a238b4e485975f437 (patch)
tree6d0e015a6ad9f20475296d3e71948dc91daf45ad /android
parent3dbb8ccb4a8b88472e0cb938a02318dc0c891ff6 (diff)
android: don't modify if the value is same - all in TextCursorView
Change-Id: Ia90458ca037959c07244673fc5521fb940737390
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java58
1 files changed, 40 insertions, 18 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
index 389cc3950856..74a0dc3f4107 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
@@ -113,6 +113,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
* @param position - new position of the cursor
*/
public void changeCursorPosition(RectF position) {
+ if (RectUtils.fuzzyEquals(mCursorPosition, position)) {
+ return;
+ }
mCursorPosition = position;
ImmutableViewportMetrics metrics = mLayerView.getViewportMetrics();
@@ -141,6 +144,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
* @param rectangle - new graphic selection rectangle
*/
public void changeGraphicSelection(RectF rectangle) {
+ if (RectUtils.fuzzyEquals(mGraphicSelection.mRectangle, rectangle)) {
+ return;
+ }
LayerView layerView = LOKitShell.getLayerView();
if (layerView == null) {
Log.e(LOGTAG, "Can't position selections because layerView is null");
@@ -228,50 +234,62 @@ public class TextCursorView extends View implements View.OnTouchListener {
* Show the cursor on the view.
*/
public void showCursor() {
- mCursorVisible = true;
- invalidate();
+ if (!mCursorVisible) {
+ mCursorVisible = true;
+ invalidate();
+ }
}
/**
* Hide the cursor.
*/
public void hideCursor() {
- mCursorVisible = false;
- invalidate();
+ if (mCursorVisible) {
+ mCursorVisible = false;
+ invalidate();
+ }
}
/**
* Show text selection rectangles.
*/
public void showSelections() {
- mSelectionsVisible = true;
- invalidate();
+ if (!mSelectionsVisible) {
+ mSelectionsVisible = true;
+ invalidate();
+ }
}
/**
* Hide text selection rectangles.
*/
public void hideSelections() {
- mSelectionsVisible = false;
- invalidate();
+ if (mSelectionsVisible) {
+ mSelectionsVisible = false;
+ invalidate();
+ }
}
/**
* Show the graphic selection on the view.
*/
public void showGraphicSelection() {
- mGraphicSelectionMove = false;
- mGraphicSelection.reset();
- mGraphicSelection.setVisible(true);
- invalidate();
+ if (!mGraphicSelection.isVisible()) {
+ mGraphicSelectionMove = false;
+ mGraphicSelection.reset();
+ mGraphicSelection.setVisible(true);
+ invalidate();
+ }
}
/**
* Hide the graphic selection.
*/
public void hideGraphicSelection() {
- mGraphicSelection.setVisible(false);
- invalidate();
+ if (mGraphicSelection.isVisible()) {
+ mGraphicSelection.setVisible(false);
+ invalidate();
+ }
}
/**
@@ -348,14 +366,18 @@ public class TextCursorView extends View implements View.OnTouchListener {
public void hideHandle(SelectionHandle.HandleType type) {
SelectionHandle handle = getHandleForType(type);
- handle.setVisible(false);
- invalidate();
+ if (handle.isVisible()) {
+ handle.setVisible(false);
+ invalidate();
+ }
}
public void showHandle(SelectionHandle.HandleType type) {
SelectionHandle handle = getHandleForType(type);
- handle.setVisible(true);
- invalidate();
+ if (!handle.isVisible()) {
+ handle.setVisible(true);
+ invalidate();
+ }
}
private SelectionHandle getHandleForType(SelectionHandle.HandleType type) {