功能优化

This commit is contained in:
lihongwei 2025-06-25 10:48:42 +08:00
parent add6f3d1e0
commit 30688c11c2
2 changed files with 89 additions and 66 deletions

View File

@ -91,22 +91,24 @@ public class FloatingTabDialogManager {
@Override
public void onComplete(Long solutionId) {
if (solutionId != -1) {
Toast.makeText(context, "方案 '" + solutionName + "' 保存成功!", Toast.LENGTH_SHORT).show();
showToastOnUi(context, "方案 '" + solutionName + "' 保存成功!");
removeFloatingTabDialog();
} else {
Toast.makeText(context, "保存方案失败。", Toast.LENGTH_SHORT).show();
showToastOnUi(context, "保存方案失败。");
}
}
@Override
public void onError(Exception e) {
Log.e(TAG, "保存方案失败: " + e.getMessage(), e);
Toast.makeText(context, "保存方案失败: " + e.getMessage(), Toast.LENGTH_SHORT).show();
showToastOnUi(context, "保存方案失败: " + e.getMessage());
}
});
// 只在验证通过时才显示
Toast.makeText(context, "正在保存方案...", Toast.LENGTH_SHORT).show();
// 这个可能也是在后台线程保险起见也用主线程
showToastOnUi(context, "正在保存方案...");
}
});
closeButton.setOnClickListener(v -> removeFloatingTabDialog());
@ -242,4 +244,11 @@ public class FloatingTabDialogManager {
}
}
}
public static void showToastOnUi(Context context, String msg) {
new Handler(Looper.getMainLooper()).post(() ->
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
);
}
}

View File

@ -11,6 +11,8 @@ import android.graphics.PixelFormat;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.text.InputType;
import android.util.Log;
@ -679,6 +681,11 @@ public class FloatingViewManager {
PointEvent end = slideEvent.getEndPoint();
ConnectingLineView lineView = slideEvent.getLineView();
if (lineView == null) {
Log.e(TAG, "updateLinePosition: lineView is null, cannot update line");
return;
}
float startCenterX = start.getX() + (float) TOUCH_POINT_SIZE / 2;
float startCenterY = start.getY() + (float) TOUCH_POINT_SIZE / 2;
float endCenterX = end.getX() + (float) TOUCH_POINT_SIZE / 2;
@ -862,6 +869,7 @@ public class FloatingViewManager {
eventRepository.getSolutionWithEventsAndPoints(solutionId, new EventRepository.RepositoryCallback<SolutionWithEventsAndPoints>() {
@Override
public void onComplete(SolutionWithEventsAndPoints solutionData) {
new Handler(Looper.getMainLooper()).post(() -> {
if (solutionData != null && solutionData.events != null) {
removeFloatingViews();
runtimeEvents.clear();
@ -908,6 +916,8 @@ public class FloatingViewManager {
WindowManager.LayoutParams lineParams = createLineViewParams();
SlideEvent slideEvent = new SlideEvent(eventEntity.orderInSolution, startPointEvent, endPointEvent);
slideEvent.setLineView(lineView);
slideEvent.setLineParams(lineParams);
setupDraggableSlidePoint(startPointView, startParams, startPointEvent, slideEvent);
setupDraggableSlidePoint(endPointView, endParams, endPointEvent, slideEvent);
@ -920,6 +930,7 @@ public class FloatingViewManager {
runtimeEvents.add(new EventWrapper(type, slideEvent, slideEvent.getId()));
}
}
if (eventEntity.orderInSolution >= eventOrderCounter) {
eventOrderCounter = eventEntity.orderInSolution + 1;
}
@ -929,12 +940,15 @@ public class FloatingViewManager {
} else {
Toast.makeText(context, "加载方案失败或方案不存在。", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onError(Exception e) {
Log.e(TAG, "加载方案失败: " + e.getMessage(), e);
Toast.makeText(context, "加载方案失败: " + e.getMessage(), Toast.LENGTH_SHORT).show();
new Handler(Looper.getMainLooper()).post(() ->
Toast.makeText(context, "加载方案失败: " + e.getMessage(), Toast.LENGTH_SHORT).show()
);
}
});
}