功能优化
This commit is contained in:
parent
add6f3d1e0
commit
30688c11c2
@ -91,22 +91,24 @@ public class FloatingTabDialogManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete(Long solutionId) {
|
public void onComplete(Long solutionId) {
|
||||||
if (solutionId != -1) {
|
if (solutionId != -1) {
|
||||||
Toast.makeText(context, "方案 '" + solutionName + "' 保存成功!", Toast.LENGTH_SHORT).show();
|
showToastOnUi(context, "方案 '" + solutionName + "' 保存成功!");
|
||||||
removeFloatingTabDialog();
|
removeFloatingTabDialog();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, "保存方案失败。", Toast.LENGTH_SHORT).show();
|
showToastOnUi(context, "保存方案失败。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception e) {
|
public void onError(Exception e) {
|
||||||
Log.e(TAG, "保存方案失败: " + e.getMessage(), 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());
|
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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -11,6 +11,8 @@ import android.graphics.PixelFormat;
|
|||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -679,6 +681,11 @@ public class FloatingViewManager {
|
|||||||
PointEvent end = slideEvent.getEndPoint();
|
PointEvent end = slideEvent.getEndPoint();
|
||||||
ConnectingLineView lineView = slideEvent.getLineView();
|
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 startCenterX = start.getX() + (float) TOUCH_POINT_SIZE / 2;
|
||||||
float startCenterY = start.getY() + (float) TOUCH_POINT_SIZE / 2;
|
float startCenterY = start.getY() + (float) TOUCH_POINT_SIZE / 2;
|
||||||
float endCenterX = end.getX() + (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>() {
|
eventRepository.getSolutionWithEventsAndPoints(solutionId, new EventRepository.RepositoryCallback<SolutionWithEventsAndPoints>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(SolutionWithEventsAndPoints solutionData) {
|
public void onComplete(SolutionWithEventsAndPoints solutionData) {
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
if (solutionData != null && solutionData.events != null) {
|
if (solutionData != null && solutionData.events != null) {
|
||||||
removeFloatingViews();
|
removeFloatingViews();
|
||||||
runtimeEvents.clear();
|
runtimeEvents.clear();
|
||||||
@ -908,6 +916,8 @@ public class FloatingViewManager {
|
|||||||
WindowManager.LayoutParams lineParams = createLineViewParams();
|
WindowManager.LayoutParams lineParams = createLineViewParams();
|
||||||
|
|
||||||
SlideEvent slideEvent = new SlideEvent(eventEntity.orderInSolution, startPointEvent, endPointEvent);
|
SlideEvent slideEvent = new SlideEvent(eventEntity.orderInSolution, startPointEvent, endPointEvent);
|
||||||
|
slideEvent.setLineView(lineView);
|
||||||
|
slideEvent.setLineParams(lineParams);
|
||||||
|
|
||||||
setupDraggableSlidePoint(startPointView, startParams, startPointEvent, slideEvent);
|
setupDraggableSlidePoint(startPointView, startParams, startPointEvent, slideEvent);
|
||||||
setupDraggableSlidePoint(endPointView, endParams, endPointEvent, slideEvent);
|
setupDraggableSlidePoint(endPointView, endParams, endPointEvent, slideEvent);
|
||||||
@ -920,6 +930,7 @@ public class FloatingViewManager {
|
|||||||
runtimeEvents.add(new EventWrapper(type, slideEvent, slideEvent.getId()));
|
runtimeEvents.add(new EventWrapper(type, slideEvent, slideEvent.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventEntity.orderInSolution >= eventOrderCounter) {
|
if (eventEntity.orderInSolution >= eventOrderCounter) {
|
||||||
eventOrderCounter = eventEntity.orderInSolution + 1;
|
eventOrderCounter = eventEntity.orderInSolution + 1;
|
||||||
}
|
}
|
||||||
@ -929,12 +940,15 @@ public class FloatingViewManager {
|
|||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, "加载方案失败或方案不存在。", Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, "加载方案失败或方案不存在。", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception e) {
|
public void onError(Exception e) {
|
||||||
Log.e(TAG, "加载方案失败: " + e.getMessage(), 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()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user