Compare commits

..

4 Commits

Author SHA1 Message Date
ZhanGSKen e61c36dfed <stallhelper>APK 15.20.4 release Publish. 2026-05-22 17:22:44 +08:00
aBuild 297d840bff 排档按钮增加确认对话框,列表项背景色标识已过期任务
- 点击 ▷ 按钮弹出确认对话框,显示任务详情与排档后时间
- 确认后执行排档,取消则不做任何操作
- 排档时间不超过当前时间的列表项背景色设为浅绿色
- 新增 dialog_schedule_confirm.xml 布局文件
- 新增 colorScheduleFutureBackground 颜色资源
2026-05-22 17:16:29 +08:00
aBuild 43e783f5aa 任务列表新增正序排列功能,编辑对话框添加现在按钮
- 添加 sortTaskList() 按排档时间正序排列列表
- 加载、添加、编辑、删除、排档后均排序并刷新界面
- 编辑/添加对话框的排档时间输入框旁增加现在按钮
- 点击现在按钮将当前整点时间填入输入框
2026-05-22 17:01:34 +08:00
aBuild a11bad310b 修复任务排档performSchedule逻辑:排档时间应更新当前任务而非下一任务
- performSchedule 改为将新时间设置给当前任务自身
- 添加 notifyItemChanged(position) 刷新当前列表项
- 补充 saveTaskData() 持久化数据
2026-05-22 16:48:09 +08:00
6 changed files with 216 additions and 20 deletions
Vendored Regular → Executable
View File
+4 -4
View File
@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu May 21 00:15:15 HKT 2026
stageCount=4
#Fri May 22 17:22:44 HKT 2026
stageCount=5
libraryProject=
baseVersion=15.20
publishVersion=15.20.3
publishVersion=15.20.4
buildCount=0
baseBetaVersion=15.20.4
baseBetaVersion=15.20.5
@@ -22,6 +22,8 @@ import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.stallhelper.R;
import cc.winboll.studio.stallhelper.beans.TaskSchedulerBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/**
* @Author ZhanGSKen
@@ -93,6 +95,7 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
} else {
LogUtils.i(TAG, "loadTaskData: 未找到已保存的任务数据,使用空列表");
}
sortTaskList();
}
/**
@@ -107,6 +110,21 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
}
}
/**
* 按排档时间倒序排列列表
*/
private void sortTaskList() {
Collections.sort(mTaskList, new Comparator<TaskSchedulerBean>() {
@Override
public int compare(TaskSchedulerBean a, TaskSchedulerBean b) {
long diff = a.getCurrentScheduleTime() - b.getCurrentScheduleTime();
if (diff > 0) return 1;
if (diff < 0) return -1;
return 0;
}
});
}
/**
* 格式化时间戳为年月日和小时
* @param timestamp 时间戳
@@ -241,6 +259,7 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
final EditText etRemark = dialog.findViewById(R.id.dialog_et_remark);
Button btnCancel = dialog.findViewById(R.id.dialog_btn_cancel);
Button btnSave = dialog.findViewById(R.id.dialog_btn_save);
Button btnNow = dialog.findViewById(R.id.dialog_btn_now);
etTaskName.setText(task.getTaskName());
etCurrentScheduleTime.setText(formatTimestamp(task.getCurrentScheduleTime()));
@@ -263,6 +282,17 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
etHour.setText(Integer.toString(hour));
}
btnNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
java.util.Calendar calendar = java.util.Calendar.getInstance();
calendar.set(java.util.Calendar.MINUTE, 0);
calendar.set(java.util.Calendar.SECOND, 0);
calendar.set(java.util.Calendar.MILLISECOND, 0);
etCurrentScheduleTime.setText(formatTimestamp(calendar.getTimeInMillis()));
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -311,7 +341,8 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
task.setDurationMinutes(durationMinutes);
task.setRemark(remark);
mAdapter.notifyItemChanged(position);
sortTaskList();
mAdapter.notifyDataSetChanged();
saveTaskData();
LogUtils.i(TAG, "showEditTaskDialog: 任务 [" + taskName + "] 数据已更新,排档幅度=" + durationMinutes + "分钟");
dialog.dismiss();
@@ -336,6 +367,7 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
final EditText etRemark = dialog.findViewById(R.id.dialog_et_remark);
Button btnCancel = dialog.findViewById(R.id.dialog_btn_cancel);
Button btnSave = dialog.findViewById(R.id.dialog_btn_save);
Button btnNow = dialog.findViewById(R.id.dialog_btn_now);
// 设置默认时间为当前时间
java.util.Calendar calendar = java.util.Calendar.getInstance();
@@ -344,6 +376,17 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
calendar.set(java.util.Calendar.MILLISECOND, 0);
etCurrentScheduleTime.setText(formatTimestamp(calendar.getTimeInMillis()));
btnNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(java.util.Calendar.MINUTE, 0);
cal.set(java.util.Calendar.SECOND, 0);
cal.set(java.util.Calendar.MILLISECOND, 0);
etCurrentScheduleTime.setText(formatTimestamp(cal.getTimeInMillis()));
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -389,7 +432,8 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
int durationMinutes = convertToTotalMinutes(month, day, hour);
TaskSchedulerBean newTask = new TaskSchedulerBean(taskName, remark, timestamp, durationMinutes);
mTaskList.add(newTask);
mAdapter.notifyItemInserted(mTaskList.size() - 1);
sortTaskList();
mAdapter.notifyDataSetChanged();
saveTaskData();
LogUtils.i(TAG, "showAddTaskDialog: 任务 [" + taskName + "] 已添加,排档幅度=" + durationMinutes + "分钟");
dialog.dismiss();
@@ -462,7 +506,8 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
public void onClick(View v) {
String taskName = task.getTaskName();
mTaskList.remove(position);
mAdapter.notifyItemRemoved(position);
sortTaskList();
mAdapter.notifyDataSetChanged();
saveTaskData();
LogUtils.i(TAG, "showDeleteConfirmDialog: 任务 [" + taskName + "] 已删除");
dialog.dismiss();
@@ -471,6 +516,56 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
dialog.show();
}
/**
* 显示排档确认对话框
* @param position 要排档的任务位置
*/
private void showScheduleConfirmDialog(final int position) {
if (position < 0 || position >= mTaskList.size()) {
return;
}
final TaskSchedulerBean task = mTaskList.get(position);
long currentTime = task.getCurrentScheduleTime();
int duration = task.getDurationMinutes();
long newTime = currentTime + duration * 60 * 1000L;
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_schedule_confirm);
TextView tvTaskName = dialog.findViewById(R.id.dialog_schedule_task_name);
TextView tvCurrentTime = dialog.findViewById(R.id.dialog_schedule_current_time);
TextView tvDuration = dialog.findViewById(R.id.dialog_schedule_duration);
TextView tvRemark = dialog.findViewById(R.id.dialog_schedule_remark);
TextView tvNewTime = dialog.findViewById(R.id.dialog_schedule_new_time);
Button btnCancel = dialog.findViewById(R.id.dialog_btn_cancel);
Button btnConfirm = dialog.findViewById(R.id.dialog_btn_confirm);
tvTaskName.setText("任务:" + task.getTaskName());
tvCurrentTime.setText("当前排档时间:" + formatTimestamp(currentTime));
tvDuration.setText("排档幅度:" + formatDurationToString(duration));
tvRemark.setText("备注:" + (task.getRemark() != null && !task.getRemark().isEmpty() ? task.getRemark() : ""));
tvNewTime.setText("排档后时间:" + formatTimestamp(newTime));
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
btnConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
performSchedule(position);
}
});
dialog.show();
}
/**
* 执行排档操作
* @param position 点击排档按钮的任务位置
@@ -484,12 +579,11 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
int duration = currentTask.getDurationMinutes();
long newTime = currentTime + duration * 60 * 1000L;
LogUtils.i(TAG, "performSchedule: 当前时间 " + formatTimestamp(currentTime) + " + " + duration + "分钟 = " + formatTimestamp(newTime));
if (position + 1 < mTaskList.size()) {
TaskSchedulerBean nextTask = mTaskList.get(position + 1);
nextTask.setCurrentScheduleTime(newTime);
mAdapter.notifyItemChanged(position + 1);
LogUtils.i(TAG, "performSchedule: 更新任务 [" + nextTask.getTaskName() + "] 时间更新为 " + formatTimestamp(newTime));
}
currentTask.setCurrentScheduleTime(newTime);
sortTaskList();
mAdapter.notifyDataSetChanged();
saveTaskData();
LogUtils.i(TAG, "performSchedule: 更新任务 [" + currentTask.getTaskName() + "] 时间更新为 " + formatTimestamp(newTime));
}
/**
@@ -518,6 +612,12 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
viewHolder.mtvDuration.setText(formatDurationToString(item.getDurationMinutes()));
viewHolder.mtvRemark.setText(item.getRemark());
if (item.getCurrentScheduleTime() <= System.currentTimeMillis()) {
viewHolder.mllMain.setBackgroundResource(R.color.colorScheduleFutureBackground);
} else {
viewHolder.mllMain.setBackgroundResource(R.drawable.bg_frame);
}
// 长按直接内置菜单,直接使用当前position
viewHolder.mllMain.setOnLongClickListener(new View.OnLongClickListener() {
@Override
@@ -549,7 +649,7 @@ public class TaskSchedulerActivity extends WinBoLLActivity {
viewHolder.mbtnSchedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performSchedule(position);
showScheduleConfirmDialog(position);
}
});
}
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp"
android:background="?android:attr/windowBackground">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="确认执行排档"
android:textSize="18sp"
android:textStyle="bold"
android:gravity="center"
android:paddingBottom="15dp"/>
<TextView
android:id="@+id/dialog_schedule_task_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold"
android:paddingBottom="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:paddingBottom="5dp"
android:id="@+id/dialog_schedule_current_time"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:paddingBottom="5dp"
android:id="@+id/dialog_schedule_duration"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:paddingBottom="5dp"
android:id="@+id/dialog_schedule_remark"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:paddingTop="10dp"
android:textStyle="bold"
android:id="@+id/dialog_schedule_new_time"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="20dp"
android:gravity="end">
<Button
android:id="@+id/dialog_btn_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:layout_marginEnd="10dp"/>
<Button
android:id="@+id/dialog_btn_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认排档"/>
</LinearLayout>
</LinearLayout>
@@ -40,14 +40,30 @@
android:paddingTop="15dp"
android:paddingBottom="5dp"/>
<EditText
android:id="@+id/dialog_et_start_time"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="例如:09:00"
android:inputType="time"
android:padding="10dp"
android:background="@android:drawable/edit_text"/>
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText
android:id="@+id/dialog_et_start_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="例如:09:00"
android:inputType="time"
android:padding="10dp"
android:background="@android:drawable/edit_text"/>
<Button
android:id="@+id/dialog_btn_now"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="现在"
android:layout_marginStart="10dp"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
@@ -20,4 +20,6 @@
<!-- 基础颜色 -->
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<!-- 排档时间超过当前时间的列表项背景色 -->
<color name="colorScheduleFutureBackground">#FFC8E6C9</color>
</resources>