mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-12-04 16:11:11 +01:00
Optimize handle view
This commit is contained in:
parent
937eb350b2
commit
fdb3764f5c
1 changed files with 9 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import android.graphics.Rect;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
@ -882,6 +883,8 @@ public final class TerminalView extends View {
|
||||||
public static final int RIGHT = 2;
|
public static final int RIGHT = 2;
|
||||||
private int mHandleHeight;
|
private int mHandleHeight;
|
||||||
|
|
||||||
|
private long mLastTime;
|
||||||
|
|
||||||
public HandleView(CursorController controller, int orientation) {
|
public HandleView(CursorController controller, int orientation) {
|
||||||
super(TerminalView.this.getContext());
|
super(TerminalView.this.getContext());
|
||||||
mController = controller;
|
mController = controller;
|
||||||
|
|
@ -983,6 +986,11 @@ public final class TerminalView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkChangedOrientation() {
|
private void checkChangedOrientation() {
|
||||||
|
long millis = SystemClock.currentThreadTimeMillis();
|
||||||
|
if (millis - mLastTime < 50) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLastTime = millis;
|
||||||
|
|
||||||
final TerminalView hostView = TerminalView.this;
|
final TerminalView hostView = TerminalView.this;
|
||||||
final int left = hostView.getLeft();
|
final int left = hostView.getLeft();
|
||||||
|
|
@ -1007,7 +1015,7 @@ public final class TerminalView extends View {
|
||||||
final int[] coords = mTempCoords;
|
final int[] coords = mTempCoords;
|
||||||
hostView.getLocationInWindow(coords);
|
hostView.getLocationInWindow(coords);
|
||||||
final int posX = coords[0] + mPointX;
|
final int posX = coords[0] + mPointX;
|
||||||
if (posX + (int) mHotspotX < clip.left) {
|
if (posX < clip.left) {
|
||||||
changeOrientation(RIGHT);
|
changeOrientation(RIGHT);
|
||||||
} else if (posX + mHandleWidth > clip.right) {
|
} else if (posX + mHandleWidth > clip.right) {
|
||||||
changeOrientation(LEFT);
|
changeOrientation(LEFT);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue