mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
Optimize handle view
This commit is contained in:
@@ -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);
|
||||||
|
Reference in New Issue
Block a user