添加任务删除确定对话框,简化对话框提示信息。

This commit is contained in:
2026-03-31 13:49:38 +08:00
parent f89dbede9c
commit c0084cd160
5 changed files with 400 additions and 559 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Tue Mar 31 05:26:19 GMT 2026 #Tue Mar 31 05:48:03 GMT 2026
stageCount=15 stageCount=15
libraryProject= libraryProject=
baseVersion=15.12 baseVersion=15.12
publishVersion=15.12.14 publishVersion=15.12.14
buildCount=4 buildCount=11
baseBetaVersion=15.12.15 baseBetaVersion=15.12.15

View File

@@ -230,7 +230,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
mPositionAdapter.setOnDeleteClickListener(new PositionAdapter.OnDeleteClickListener() { mPositionAdapter.setOnDeleteClickListener(new PositionAdapter.OnDeleteClickListener() {
@Override @Override
public void onDeleteClick(final int position) { public void onDeleteClick(final int position) {
YesNoAlertDialog.show(LocationActivity.this, "删除位置提示", "是否删除位置?", new YesNoAlertDialog.OnDialogResultListener(){ YesNoAlertDialog.show(LocationActivity.this, "删除位置提示", "是否删除此项锚点位置?", new YesNoAlertDialog.OnDialogResultListener(){
@Override @Override
public void onNo() { public void onNo() {

View File

@@ -230,24 +230,24 @@ public class MainService extends Service {
* 删除任务Adapter调用通过迭代器安全删除避免并发异常 * 删除任务Adapter调用通过迭代器安全删除避免并发异常
* @param taskId 待删除任务的ID * @param taskId 待删除任务的ID
*/ */
public void deleteTask(String taskId) { public void deleteTask(final String taskId) {
if (TextUtils.isEmpty(taskId) || mAllTasks.isEmpty()) { if (TextUtils.isEmpty(taskId) || mAllTasks.isEmpty()) {
LogUtils.w(TAG, "deletePositionTask任务ID为空或列表为空删除失败"); LogUtils.w(TAG, "deletePositionTask任务ID为空或列表为空删除失败");
return; return;
} }
// 迭代器删除Java 7 唯一安全删除集合元素的方式) // 迭代器删除Java 7 唯一安全删除集合元素的方式)
Iterator<PositionTaskModel> taskIter = mAllTasks.iterator(); Iterator<PositionTaskModel> taskIter = mAllTasks.iterator();
while (taskIter.hasNext()) { while (taskIter.hasNext()) {
PositionTaskModel task = taskIter.next(); PositionTaskModel task = taskIter.next();
if (taskId.equals(task.getTaskId())) { if (taskId.equals(task.getTaskId())) {
taskIter.remove(); // 迭代器安全删除无ConcurrentModificationException taskIter.remove(); // 迭代器安全删除无ConcurrentModificationException
saveAllTasks(); saveAllTasks();
notifyTaskUpdated(); notifyTaskUpdated();
LogUtils.d(TAG, "deletePositionTask成功任务ID=" + taskId + ""); LogUtils.d(TAG, "deletePositionTask成功任务ID=" + taskId + "");
break; break;
} }
} }
} }
/** /**

View File

@@ -23,6 +23,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.positions.R; import cc.winboll.studio.positions.R;
import cc.winboll.studio.positions.models.PositionTaskModel; import cc.winboll.studio.positions.models.PositionTaskModel;
@@ -354,28 +355,38 @@ public class PositionTaskListView extends LinearLayout {
holder.btnDeleteTask.setOnClickListener(new View.OnClickListener() { holder.btnDeleteTask.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
LogUtils.d(TAG, "删除按钮点击 position=" + position + " taskId=" + task.getTaskId()); YesNoAlertDialog.show(getContext(), "删除任务提示", "是否删除此项位置任务?", new YesNoAlertDialog.OnDialogResultListener(){
if (mMainService == null) { @Override
showToast("删除失败:服务未就绪"); public void onNo() {
LogUtils.e(TAG, "删除失败MainService为空"); }
return;
}
try {
mMainService.deleteTask(task.getTaskId());
LogUtils.d(TAG, "服务删除任务成功 taskId=" + task.getTaskId());
notifyItemRemoved(position);
notifyItemRangeChanged(position, mAdapterData.size());
if (mOnTaskUpdatedListener != null && mBindPositionId != null) { @Override
mOnTaskUpdatedListener.onTaskUpdated(mBindPositionId, new ArrayList<>(mAdapterData)); public void onYes() {
} LogUtils.d(TAG, "删除按钮点击 position=" + position + " taskId=" + task.getTaskId());
showToast("任务已删除"); if (mMainService == null) {
showToast("删除失败:服务未就绪");
LogUtils.e(TAG, "删除失败MainService为空");
return;
}
try {
mMainService.deleteTask(task.getTaskId());
LogUtils.d(TAG, "服务删除任务成功 taskId=" + task.getTaskId());
notifyItemRemoved(position);
notifyItemRangeChanged(position, mAdapterData.size());
} catch (Exception e) { if (mOnTaskUpdatedListener != null && mBindPositionId != null) {
LogUtils.e(TAG, "删除异常: " + e.getMessage(), e); mOnTaskUpdatedListener.onTaskUpdated(mBindPositionId, new ArrayList<>(mAdapterData));
showToast("删除失败,请重试"); }
syncTasksFromMainService(); showToast("任务已删除");
}
} catch (Exception e) {
LogUtils.e(TAG, "删除异常: " + e.getMessage(), e);
showToast("删除失败,请重试");
syncTasksFromMainService();
}
}
});
} }
}); });