添加任务删除确定对话框,简化对话框提示信息。
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#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
|
||||
libraryProject=
|
||||
baseVersion=15.12
|
||||
publishVersion=15.12.14
|
||||
buildCount=4
|
||||
buildCount=11
|
||||
baseBetaVersion=15.12.15
|
||||
|
||||
@@ -230,7 +230,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
mPositionAdapter.setOnDeleteClickListener(new PositionAdapter.OnDeleteClickListener() {
|
||||
@Override
|
||||
public void onDeleteClick(final int position) {
|
||||
YesNoAlertDialog.show(LocationActivity.this, "删除位置提示", "是否删除位置?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
YesNoAlertDialog.show(LocationActivity.this, "删除位置提示", "是否删除此项锚点位置?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
|
||||
@Override
|
||||
public void onNo() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -230,24 +230,24 @@ public class MainService extends Service {
|
||||
* 删除任务(Adapter调用,通过迭代器安全删除,避免并发异常)
|
||||
* @param taskId 待删除任务的ID
|
||||
*/
|
||||
public void deleteTask(String taskId) {
|
||||
public void deleteTask(final String taskId) {
|
||||
if (TextUtils.isEmpty(taskId) || mAllTasks.isEmpty()) {
|
||||
LogUtils.w(TAG, "deletePositionTask:任务ID为空或列表为空,删除失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 迭代器删除(Java 7 唯一安全删除集合元素的方式)
|
||||
Iterator<PositionTaskModel> taskIter = mAllTasks.iterator();
|
||||
while (taskIter.hasNext()) {
|
||||
PositionTaskModel task = taskIter.next();
|
||||
if (taskId.equals(task.getTaskId())) {
|
||||
taskIter.remove(); // 迭代器安全删除,无ConcurrentModificationException
|
||||
saveAllTasks();
|
||||
notifyTaskUpdated();
|
||||
LogUtils.d(TAG, "deletePositionTask:成功(任务ID=" + taskId + ")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 迭代器删除(Java 7 唯一安全删除集合元素的方式)
|
||||
Iterator<PositionTaskModel> taskIter = mAllTasks.iterator();
|
||||
while (taskIter.hasNext()) {
|
||||
PositionTaskModel task = taskIter.next();
|
||||
if (taskId.equals(task.getTaskId())) {
|
||||
taskIter.remove(); // 迭代器安全删除,无ConcurrentModificationException
|
||||
saveAllTasks();
|
||||
notifyTaskUpdated();
|
||||
LogUtils.d(TAG, "deletePositionTask:成功(任务ID=" + taskId + ")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.models.PositionTaskModel;
|
||||
@@ -354,28 +355,38 @@ public class PositionTaskListView extends LinearLayout {
|
||||
holder.btnDeleteTask.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "删除按钮点击 position=" + position + " taskId=" + task.getTaskId());
|
||||
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());
|
||||
YesNoAlertDialog.show(getContext(), "删除任务提示", "是否删除此项位置任务?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
@Override
|
||||
public void onNo() {
|
||||
}
|
||||
|
||||
if (mOnTaskUpdatedListener != null && mBindPositionId != null) {
|
||||
mOnTaskUpdatedListener.onTaskUpdated(mBindPositionId, new ArrayList<>(mAdapterData));
|
||||
}
|
||||
showToast("任务已删除");
|
||||
@Override
|
||||
public void onYes() {
|
||||
LogUtils.d(TAG, "删除按钮点击 position=" + position + " taskId=" + task.getTaskId());
|
||||
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) {
|
||||
LogUtils.e(TAG, "删除异常: " + e.getMessage(), e);
|
||||
showToast("删除失败,请重试");
|
||||
syncTasksFromMainService();
|
||||
}
|
||||
if (mOnTaskUpdatedListener != null && mBindPositionId != null) {
|
||||
mOnTaskUpdatedListener.onTaskUpdated(mBindPositionId, new ArrayList<>(mAdapterData));
|
||||
}
|
||||
showToast("任务已删除");
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "删除异常: " + e.getMessage(), e);
|
||||
showToast("删除失败,请重试");
|
||||
syncTasksFromMainService();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user