Compare commits
	
		
			16 Commits
		
	
	
		
			positions-
			...
			positions-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6376ff4ccf | |||
| 
						 | 
					dd20060754 | ||
| 
						 | 
					298b337392 | ||
| 377ec4de09 | |||
| 
						 | 
					033da4d544 | ||
| 
						 | 
					1398ffc064 | ||
| 247f3f9b49 | |||
| 
						 | 
					cec2e82550 | ||
| 
						 | 
					ac5f425624 | ||
| 5646b589e0 | |||
| 
						 | 
					5a1716341b | ||
| 7f8fdc2eb8 | |||
| 
						 | 
					bcd4fc5abd | ||
| 
						 | 
					6a90bbb263 | ||
| 0a6796a9bc | |||
| 
						 | 
					838568f4cd | 
@@ -46,6 +46,9 @@ android {
 | 
				
			|||||||
dependencies {
 | 
					dependencies {
 | 
				
			||||||
    api fileTree(dir: 'libs', include: ['*.jar'])
 | 
					    api fileTree(dir: 'libs', include: ['*.jar'])
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						// https://mvnrepository.com/artifact/com.jzxiang.pickerview/TimePickerDialog
 | 
				
			||||||
 | 
						api 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	// 谷歌定位服务核心依赖(FusedLocationProviderClient所在库)
 | 
						// 谷歌定位服务核心依赖(FusedLocationProviderClient所在库)
 | 
				
			||||||
    api 'com.google.android.gms:play-services-location:21.0.1'
 | 
					    api 'com.google.android.gms:play-services-location:21.0.1'
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@@ -59,7 +62,7 @@ dependencies {
 | 
				
			|||||||
    // 应用介绍页类库
 | 
					    // 应用介绍页类库
 | 
				
			||||||
    api 'io.github.medyo:android-about-page:2.0.0'
 | 
					    api 'io.github.medyo:android-about-page:2.0.0'
 | 
				
			||||||
    // 吐司类库
 | 
					    // 吐司类库
 | 
				
			||||||
    api 'com.github.getActivity:ToastUtils:10.5'
 | 
					    //api 'com.github.getActivity:ToastUtils:10.5'
 | 
				
			||||||
    // 网络连接类库
 | 
					    // 网络连接类库
 | 
				
			||||||
    api 'com.squareup.okhttp3:okhttp:4.4.1'
 | 
					    api 'com.squareup.okhttp3:okhttp:4.4.1'
 | 
				
			||||||
    // AndroidX 类库
 | 
					    // AndroidX 类库
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
#Created by .winboll/winboll_app_build.gradle
 | 
					#Created by .winboll/winboll_app_build.gradle
 | 
				
			||||||
#Tue Oct 07 02:42:31 HKT 2025
 | 
					#Tue Oct 28 14:17:09 HKT 2025
 | 
				
			||||||
stageCount=11
 | 
					stageCount=17
 | 
				
			||||||
libraryProject=
 | 
					libraryProject=
 | 
				
			||||||
baseVersion=15.0
 | 
					baseVersion=15.0
 | 
				
			||||||
publishVersion=15.0.10
 | 
					publishVersion=15.0.16
 | 
				
			||||||
buildCount=0
 | 
					buildCount=0
 | 
				
			||||||
baseBetaVersion=15.0.11
 | 
					baseBetaVersion=15.0.17
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,9 +22,9 @@ import android.widget.HorizontalScrollView;
 | 
				
			|||||||
import android.widget.ScrollView;
 | 
					import android.widget.ScrollView;
 | 
				
			||||||
import android.widget.TextView;
 | 
					import android.widget.TextView;
 | 
				
			||||||
import android.widget.Toast;
 | 
					import android.widget.Toast;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
 | 
				
			||||||
import cc.winboll.studio.libappbase.GlobalApplication;
 | 
					import cc.winboll.studio.libappbase.GlobalApplication;
 | 
				
			||||||
import com.hjq.toast.ToastUtils;
 | 
					import cc.winboll.studio.libappbase.ToastUtils;
 | 
				
			||||||
import com.hjq.toast.style.WhiteToastStyle;
 | 
					 | 
				
			||||||
import java.io.ByteArrayInputStream;
 | 
					import java.io.ByteArrayInputStream;
 | 
				
			||||||
import java.io.ByteArrayOutputStream;
 | 
					import java.io.ByteArrayOutputStream;
 | 
				
			||||||
import java.io.Closeable;
 | 
					import java.io.Closeable;
 | 
				
			||||||
@@ -41,7 +41,6 @@ import java.util.Arrays;
 | 
				
			|||||||
import java.util.Date;
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.LinkedHashMap;
 | 
					import java.util.LinkedHashMap;
 | 
				
			||||||
import java.util.concurrent.atomic.AtomicBoolean;
 | 
					import java.util.concurrent.atomic.AtomicBoolean;
 | 
				
			||||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class App extends GlobalApplication {
 | 
					public class App extends GlobalApplication {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -58,8 +57,8 @@ public class App extends GlobalApplication {
 | 
				
			|||||||
        ToastUtils.init(this);
 | 
					        ToastUtils.init(this);
 | 
				
			||||||
        // 设置 Toast 布局样式
 | 
					        // 设置 Toast 布局样式
 | 
				
			||||||
        //ToastUtils.setView(R.layout.view_toast);
 | 
					        //ToastUtils.setView(R.layout.view_toast);
 | 
				
			||||||
        ToastUtils.setStyle(new WhiteToastStyle());
 | 
					        //ToastUtils.setStyle(new WhiteToastStyle());
 | 
				
			||||||
        ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
 | 
					        //ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        //CrashHandler.getInstance().registerGlobal(this);
 | 
					        //CrashHandler.getInstance().registerGlobal(this);
 | 
				
			||||||
        //CrashHandler.getInstance().registerPart(this);
 | 
					        //CrashHandler.getInstance().registerPart(this);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ import cc.winboll.studio.positions.activities.LocationActivity;
 | 
				
			|||||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
 | 
					import cc.winboll.studio.positions.activities.WinBoLLActivity;
 | 
				
			||||||
import cc.winboll.studio.positions.services.MainService;
 | 
					import cc.winboll.studio.positions.services.MainService;
 | 
				
			||||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
 | 
					import cc.winboll.studio.positions.utils.AppConfigsUtil;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.utils.ServiceUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 主页面:仅负责
 | 
					 * 主页面:仅负责
 | 
				
			||||||
@@ -141,18 +142,11 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
 | 
				
			|||||||
					// 权限就绪:执行服务启停逻辑
 | 
										// 权限就绪:执行服务启停逻辑
 | 
				
			||||||
					if (isChecked) {
 | 
										if (isChecked) {
 | 
				
			||||||
						LogUtils.d(TAG, "设置启动服务");
 | 
											LogUtils.d(TAG, "设置启动服务");
 | 
				
			||||||
						AppConfigsUtil.getInstance(MainActivity.this).setIsEnableMainService(true);
 | 
											ServiceUtil.startAutoService(MainActivity.this);
 | 
				
			||||||
						// 启动服务(startService确保服务独立运行,不受Activity绑定影响)
 | 
					 | 
				
			||||||
						startService(new Intent(MainActivity.this, MainService.class));
 | 
					 | 
				
			||||||
					} else {
 | 
										} else {
 | 
				
			||||||
						LogUtils.d(TAG, "设置关闭服务");
 | 
											LogUtils.d(TAG, "设置关闭服务");
 | 
				
			||||||
						AppConfigsUtil.getInstance(MainActivity.this).setIsEnableMainService(false);
 | 
					
 | 
				
			||||||
						// 停止服务前先解绑,避免服务被Activity持有
 | 
											ServiceUtil.stopAutoService(MainActivity.this);
 | 
				
			||||||
//						if (isServiceBound) {
 | 
					 | 
				
			||||||
//							unbindService(mServiceConn);
 | 
					 | 
				
			||||||
//							isServiceBound = false;
 | 
					 | 
				
			||||||
//						}
 | 
					 | 
				
			||||||
						stopService(new Intent(MainActivity.this, MainService.class));
 | 
					 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					mManagePositionsButton.setEnabled(isChecked);
 | 
										mManagePositionsButton.setEnabled(isChecked);
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -26,19 +26,22 @@ public class PositionTaskModel extends BaseBean {
 | 
				
			|||||||
	boolean isLessThan;
 | 
						boolean isLessThan;
 | 
				
			||||||
	// 任务条件距离(单位:米)
 | 
						// 任务条件距离(单位:米)
 | 
				
			||||||
	int discussDistance;
 | 
						int discussDistance;
 | 
				
			||||||
 | 
						// 任务开始启用时间
 | 
				
			||||||
 | 
						long startTime;
 | 
				
			||||||
	// 任务是否已触发
 | 
						// 任务是否已触发
 | 
				
			||||||
	boolean isBingo = false;
 | 
						boolean isBingo = false;
 | 
				
			||||||
	// 是否启用任务
 | 
						// 是否启用任务
 | 
				
			||||||
	boolean isEnable;
 | 
						boolean isEnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 带参构造(强制传入positionId,确保任务与位置绑定)
 | 
						// 带参构造(强制传入positionId,确保任务与位置绑定)
 | 
				
			||||||
	public PositionTaskModel(String taskId, String positionId, String taskDescription, boolean isGreaterThan, int discussDistance, boolean isEnable) {
 | 
						public PositionTaskModel(String taskId, String positionId, String taskDescription, boolean isGreaterThan, int discussDistance, long startTime, boolean isEnable) {
 | 
				
			||||||
		this.taskId = (taskId == null || taskId.trim().isEmpty()) ? genTaskId() : taskId; // 空ID自动生成
 | 
							this.taskId = (taskId == null || taskId.trim().isEmpty()) ? genTaskId() : taskId; // 空ID自动生成
 | 
				
			||||||
		this.positionId = positionId; // 强制绑定位置ID
 | 
							this.positionId = positionId; // 强制绑定位置ID
 | 
				
			||||||
		this.taskDescription = (taskDescription == null || taskDescription.trim().isEmpty()) ? "新任务" : taskDescription;
 | 
							this.taskDescription = (taskDescription == null || taskDescription.trim().isEmpty()) ? "新任务" : taskDescription;
 | 
				
			||||||
		this.isGreaterThan = isGreaterThan;
 | 
							this.isGreaterThan = isGreaterThan;
 | 
				
			||||||
		this.isLessThan = !isGreaterThan; // 确保互斥
 | 
							this.isLessThan = !isGreaterThan; // 确保互斥
 | 
				
			||||||
		this.discussDistance = Math.max(discussDistance, 1); // 距离最小1米,避免无效值
 | 
							this.discussDistance = Math.max(discussDistance, 1); // 距离最小1米,避免无效值
 | 
				
			||||||
 | 
							this.startTime = startTime;
 | 
				
			||||||
		this.isEnable = isEnable;
 | 
							this.isEnable = isEnable;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -50,9 +53,18 @@ public class PositionTaskModel extends BaseBean {
 | 
				
			|||||||
		this.isGreaterThan = true;
 | 
							this.isGreaterThan = true;
 | 
				
			||||||
		this.isLessThan = false; // 初始互斥
 | 
							this.isLessThan = false; // 初始互斥
 | 
				
			||||||
		this.discussDistance = 100; // 默认100米
 | 
							this.discussDistance = 100; // 默认100米
 | 
				
			||||||
 | 
							this.startTime = System.currentTimeMillis();
 | 
				
			||||||
		this.isEnable = true;
 | 
							this.isEnable = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setStartTime(long startTime) {
 | 
				
			||||||
 | 
							this.startTime = startTime;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public long getStartTime() {
 | 
				
			||||||
 | 
							return startTime;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setIsBingo(boolean isBingo) {
 | 
						public void setIsBingo(boolean isBingo) {
 | 
				
			||||||
		this.isBingo = isBingo;
 | 
							this.isBingo = isBingo;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -144,6 +156,7 @@ public class PositionTaskModel extends BaseBean {
 | 
				
			|||||||
		jsonWriter.name("isGreaterThan").value(isGreaterThan());
 | 
							jsonWriter.name("isGreaterThan").value(isGreaterThan());
 | 
				
			||||||
		jsonWriter.name("isLessThan").value(isLessThan());
 | 
							jsonWriter.name("isLessThan").value(isLessThan());
 | 
				
			||||||
		jsonWriter.name("discussDistance").value(getDiscussDistance());
 | 
							jsonWriter.name("discussDistance").value(getDiscussDistance());
 | 
				
			||||||
 | 
							jsonWriter.name("startTime").value(getStartTime());
 | 
				
			||||||
		jsonWriter.name("isEnable").value(isEnable());
 | 
							jsonWriter.name("isEnable").value(isEnable());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -165,6 +178,8 @@ public class PositionTaskModel extends BaseBean {
 | 
				
			|||||||
				setIsLessThan(jsonReader.nextBoolean());
 | 
									setIsLessThan(jsonReader.nextBoolean());
 | 
				
			||||||
			} else if (name.equals("discussDistance")) {
 | 
								} else if (name.equals("discussDistance")) {
 | 
				
			||||||
				setDiscussDistance(jsonReader.nextInt());
 | 
									setDiscussDistance(jsonReader.nextInt());
 | 
				
			||||||
 | 
								} else if (name.equals("startTime")) {
 | 
				
			||||||
 | 
									setStartTime(jsonReader.nextLong());
 | 
				
			||||||
			} else if (name.equals("isEnable")) {
 | 
								} else if (name.equals("isEnable")) {
 | 
				
			||||||
				setIsEnable(jsonReader.nextBoolean());
 | 
									setIsEnable(jsonReader.nextBoolean());
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,7 @@ import cc.winboll.studio.positions.utils.ServiceUtil;
 | 
				
			|||||||
public class AssistantService extends Service {
 | 
					public class AssistantService extends Service {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public final static String TAG = "AssistantService";
 | 
					    public final static String TAG = "AssistantService";
 | 
				
			||||||
 | 
						public static final String EXTRA_IS_SETTING_TO_ENABLE = "EXTRA_IS_SETTING_TO_ENABLE";
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
    MyServiceConnection mMyServiceConnection;
 | 
					    MyServiceConnection mMyServiceConnection;
 | 
				
			||||||
    volatile boolean mIsServiceRunning;
 | 
					    volatile boolean mIsServiceRunning;
 | 
				
			||||||
@@ -37,13 +38,18 @@ public class AssistantService extends Service {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        // 设置运行参数
 | 
					        // 设置运行参数
 | 
				
			||||||
        mIsServiceRunning = false;
 | 
					        mIsServiceRunning = false;
 | 
				
			||||||
        run();
 | 
					        if (mAppConfigsUtil.isEnableMainService(true)) {
 | 
				
			||||||
 | 
								run();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int onStartCommand(Intent intent, int flags, int startId) {
 | 
					    public int onStartCommand(Intent intent, int flags, int startId) {
 | 
				
			||||||
        run();
 | 
							if (mAppConfigsUtil.isEnableMainService(true)) {
 | 
				
			||||||
        return START_STICKY;
 | 
								run();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return  mAppConfigsUtil.isEnableMainService(true) ? Service.START_STICKY : super.onStartCommand(intent, flags, startId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,16 +20,14 @@ import android.os.Handler;
 | 
				
			|||||||
import android.os.IBinder;
 | 
					import android.os.IBinder;
 | 
				
			||||||
import android.os.Looper;
 | 
					import android.os.Looper;
 | 
				
			||||||
import android.text.TextUtils;
 | 
					import android.text.TextUtils;
 | 
				
			||||||
import android.util.Log;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import cc.winboll.studio.libappbase.LogUtils;
 | 
					import cc.winboll.studio.libappbase.LogUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.ToastUtils;
 | 
				
			||||||
import cc.winboll.studio.positions.models.PositionModel;
 | 
					import cc.winboll.studio.positions.models.PositionModel;
 | 
				
			||||||
import cc.winboll.studio.positions.models.PositionTaskModel;
 | 
					import cc.winboll.studio.positions.models.PositionTaskModel;
 | 
				
			||||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
 | 
					import cc.winboll.studio.positions.utils.AppConfigsUtil;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.utils.DistanceCalculatorUtil;
 | 
				
			||||||
import cc.winboll.studio.positions.utils.NotificationUtil;
 | 
					import cc.winboll.studio.positions.utils.NotificationUtil;
 | 
				
			||||||
import cc.winboll.studio.positions.utils.ServiceUtil;
 | 
					import cc.winboll.studio.positions.utils.ServiceUtil;
 | 
				
			||||||
import com.hjq.toast.ToastUtils;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.lang.ref.WeakReference;
 | 
					import java.lang.ref.WeakReference;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashSet;
 | 
					import java.util.HashSet;
 | 
				
			||||||
@@ -37,11 +35,19 @@ import java.util.Iterator;
 | 
				
			|||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
import java.util.concurrent.Executors;
 | 
					import java.util.concurrent.Executors;
 | 
				
			||||||
import java.util.concurrent.ScheduledExecutorService;
 | 
					import java.util.concurrent.ScheduledExecutorService;
 | 
				
			||||||
 | 
					import java.util.concurrent.TimeUnit; // 新增:定时器时间单位依赖
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MainService extends Service {
 | 
					public class MainService extends Service {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static final String TAG = "MainService";
 | 
					    public static final String TAG = "MainService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static final String EXTRA_IS_SETTING_TO_ENABLE = "EXTRA_IS_SETTING_TO_ENABLE";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ---------------------- 新增:定时器相关变量 ----------------------
 | 
				
			||||||
 | 
					    private ScheduledExecutorService taskCheckTimer; // 任务校验定时器
 | 
				
			||||||
 | 
					    private static final long TASK_CHECK_INTERVAL = 1; // 定时间隔(1分钟)
 | 
				
			||||||
 | 
					    private static final long TASK_CHECK_INIT_DELAY = 1; // 初始延迟(1分钟:立即启动)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // GPS监听接口(Java 7 标准接口定义,无Lambda依赖)
 | 
					    // GPS监听接口(Java 7 标准接口定义,无Lambda依赖)
 | 
				
			||||||
    public interface GpsUpdateListener {
 | 
					    public interface GpsUpdateListener {
 | 
				
			||||||
        void onGpsPositionUpdated(PositionModel currentGpsPos);
 | 
					        void onGpsPositionUpdated(PositionModel currentGpsPos);
 | 
				
			||||||
@@ -70,7 +76,7 @@ public class MainService extends Service {
 | 
				
			|||||||
    // 数据存储集合(Java 7 基础集合,避免Stream/forEach等Java 8+特性)
 | 
					    // 数据存储集合(Java 7 基础集合,避免Stream/forEach等Java 8+特性)
 | 
				
			||||||
    private final ArrayList<PositionModel> mPositionList = new ArrayList<PositionModel>();   // 位置数据列表
 | 
					    private final ArrayList<PositionModel> mPositionList = new ArrayList<PositionModel>();   // 位置数据列表
 | 
				
			||||||
    private final ArrayList<PositionTaskModel> mAllTasks = new ArrayList<PositionTaskModel>();// 任务数据列表
 | 
					    private final ArrayList<PositionTaskModel> mAllTasks = new ArrayList<PositionTaskModel>();// 任务数据列表
 | 
				
			||||||
    private PositionModel mCurrentGpsPosition; // 当前GPS定位数据
 | 
					    private static PositionModel _mCurrentGpsPosition; // 当前GPS定位数据
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 服务相关变量(Java 7 显式声明,保持原逻辑)
 | 
					    // 服务相关变量(Java 7 显式声明,保持原逻辑)
 | 
				
			||||||
    MyServiceConnection mMyServiceConnection;
 | 
					    MyServiceConnection mMyServiceConnection;
 | 
				
			||||||
@@ -84,6 +90,51 @@ public class MainService extends Service {
 | 
				
			|||||||
    private static Context sAppContext;
 | 
					    private static Context sAppContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // =========================================================================
 | 
				
			||||||
 | 
					    // 新增:定时器初始化方法(创建单线程定时器,每1分钟调用任务校验)
 | 
				
			||||||
 | 
					    // =========================================================================
 | 
				
			||||||
 | 
					    private void initTaskCheckTimer() {
 | 
				
			||||||
 | 
					        // 先销毁旧定时器(避免重复创建导致多线程问题)
 | 
				
			||||||
 | 
					        if (taskCheckTimer != null && !taskCheckTimer.isShutdown()) {
 | 
				
			||||||
 | 
					            taskCheckTimer.shutdown();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 创建单线程定时器(确保任务串行执行,避免并发异常)
 | 
				
			||||||
 | 
					        taskCheckTimer = Executors.newSingleThreadScheduledExecutor();
 | 
				
			||||||
 | 
					        // 定时任务:初始延迟1分钟,每1分钟执行一次
 | 
				
			||||||
 | 
					        taskCheckTimer.scheduleAtFixedRate(new Runnable() {
 | 
				
			||||||
 | 
									@Override
 | 
				
			||||||
 | 
									public void run() {
 | 
				
			||||||
 | 
										LogUtils.d(TAG, "定时任务触发:开始校验任务(间隔1分钟)");
 | 
				
			||||||
 | 
										// 调用任务校验核心方法(与GPS位置变化时逻辑一致)
 | 
				
			||||||
 | 
										DistanceCalculatorUtil.getInstance(MainService.this).checkAllTaskTriggerCondition(MainService._mCurrentGpsPosition);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}, TASK_CHECK_INIT_DELAY, TASK_CHECK_INTERVAL, TimeUnit.MINUTES);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "任务校验定时器已启动(间隔:" + TASK_CHECK_INTERVAL + "分钟)");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // =========================================================================
 | 
				
			||||||
 | 
					    // 新增:定时器销毁方法(服务销毁时调用,避免内存泄漏)
 | 
				
			||||||
 | 
					    // =========================================================================
 | 
				
			||||||
 | 
					    private void destroyTaskCheckTimer() {
 | 
				
			||||||
 | 
					        if (taskCheckTimer != null && !taskCheckTimer.isShutdown()) {
 | 
				
			||||||
 | 
					            taskCheckTimer.shutdown(); // 优雅关闭:等待已提交任务执行完成
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                // 等待1秒,若未终止则强制关闭
 | 
				
			||||||
 | 
					                if (!taskCheckTimer.awaitTermination(1, TimeUnit.SECONDS)) {
 | 
				
			||||||
 | 
					                    taskCheckTimer.shutdownNow(); // 强制终止未完成任务
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (InterruptedException e) {
 | 
				
			||||||
 | 
					                taskCheckTimer.shutdownNow(); // 捕获中断异常,强制关闭
 | 
				
			||||||
 | 
					                Thread.currentThread().interrupt(); // 恢复线程中断状态
 | 
				
			||||||
 | 
					            } finally {
 | 
				
			||||||
 | 
					                taskCheckTimer = null; // 置空,避免重复操作
 | 
				
			||||||
 | 
					                LogUtils.d(TAG, "任务校验定时器已销毁");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // =========================================================================
 | 
					    // =========================================================================
 | 
				
			||||||
    // 任务操作核心接口(Java 7 实现,全迭代器遍历,无ConcurrentModificationException)
 | 
					    // 任务操作核心接口(Java 7 实现,全迭代器遍历,无ConcurrentModificationException)
 | 
				
			||||||
    // =========================================================================
 | 
					    // =========================================================================
 | 
				
			||||||
@@ -147,7 +198,7 @@ public class MainService extends Service {
 | 
				
			|||||||
     * @return 所有任务的拷贝列表
 | 
					     * @return 所有任务的拷贝列表
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public ArrayList<PositionTaskModel> getAllTasks() {
 | 
					    public ArrayList<PositionTaskModel> getAllTasks() {
 | 
				
			||||||
        return new ArrayList<PositionTaskModel>(mAllTasks); // Java 7 集合拷贝方式
 | 
					        return mAllTasks; // Java 7 集合拷贝方式
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void updateTask(PositionTaskModel updatedTask) {
 | 
						public void updateTask(PositionTaskModel updatedTask) {
 | 
				
			||||||
@@ -272,8 +323,10 @@ public class MainService extends Service {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public static synchronized MainService getInstance(Context context) {
 | 
					    public static synchronized MainService getInstance(Context context) {
 | 
				
			||||||
        if (sInstance == null) {
 | 
					        if (sInstance == null) {
 | 
				
			||||||
            Intent intent = new Intent(context.getApplicationContext(), MainService.class);
 | 
								if (AppConfigsUtil.getInstance(context).isEnableMainService(true)) {
 | 
				
			||||||
            context.getApplicationContext().startService(intent);
 | 
									Intent intent = new Intent(context.getApplicationContext(), MainService.class);
 | 
				
			||||||
 | 
									context.getApplicationContext().startService(intent);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (sAppContext == null) {
 | 
					        if (sAppContext == null) {
 | 
				
			||||||
@@ -312,11 +365,14 @@ public class MainService extends Service {
 | 
				
			|||||||
            mMyServiceConnection = new MyServiceConnection();
 | 
					            mMyServiceConnection = new MyServiceConnection();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        run(); // 启动服务核心逻辑
 | 
							if (mAppConfigsUtil.isEnableMainService(true)) {
 | 
				
			||||||
 | 
								run(); // 启动服务核心逻辑
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 服务核心逻辑(启动前台服务、初始化GPS、加载数据等)
 | 
					     * 服务核心逻辑(启动前台服务、初始化GPS、加载数据等)
 | 
				
			||||||
 | 
					     * 【关键修改】新增定时器初始化,每1分钟调用任务校验
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void run() {
 | 
					    public void run() {
 | 
				
			||||||
        if (mAppConfigsUtil.isEnableMainService(true)) {
 | 
					        if (mAppConfigsUtil.isEnableMainService(true)) {
 | 
				
			||||||
@@ -339,9 +395,13 @@ public class MainService extends Service {
 | 
				
			|||||||
                PositionModel.loadBeanList(MainService.this, mPositionList, PositionModel.class);
 | 
					                PositionModel.loadBeanList(MainService.this, mPositionList, PositionModel.class);
 | 
				
			||||||
                PositionTaskModel.loadBeanList(MainService.this, mAllTasks, PositionTaskModel.class);
 | 
					                PositionTaskModel.loadBeanList(MainService.this, mAllTasks, PositionTaskModel.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // 提示与日志(Java 7 基础调用)
 | 
									// 提示与日志(Java 7 基础调用)
 | 
				
			||||||
                ToastUtils.show(initialStatus);
 | 
					                ToastUtils.show(initialStatus);
 | 
				
			||||||
                LogUtils.i(TAG, initialStatus);
 | 
					                LogUtils.i(TAG, initialStatus);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // ---------------------- 关键新增:启动任务校验定时器 ----------------------
 | 
				
			||||||
 | 
									//checkAllTaskTriggerCondition();
 | 
				
			||||||
 | 
									initTaskCheckTimer();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -356,6 +416,7 @@ public class MainService extends Service {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 服务销毁回调(清理资源、停止GPS、清空数据、反注册监听等)
 | 
					     * 服务销毁回调(清理资源、停止GPS、清空数据、反注册监听等)
 | 
				
			||||||
 | 
					     * 【关键修改】新增定时器销毁,避免内存泄漏
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onDestroy() {
 | 
					    public void onDestroy() {
 | 
				
			||||||
@@ -373,6 +434,13 @@ public class MainService extends Service {
 | 
				
			|||||||
            mTaskListeners.clear();
 | 
					            mTaskListeners.clear();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // ---------------------- 关键新增:销毁任务校验定时器 ----------------------
 | 
				
			||||||
 | 
					        destroyTaskCheckTimer();
 | 
				
			||||||
 | 
					        // 销毁距离计算线程池(原有逻辑,补充确保线程安全)
 | 
				
			||||||
 | 
					        if (distanceExecutor != null && !distanceExecutor.isShutdown()) {
 | 
				
			||||||
 | 
					            distanceExecutor.shutdown();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 重置状态变量
 | 
					        // 重置状态变量
 | 
				
			||||||
        _mIsServiceRunning = false;
 | 
					        _mIsServiceRunning = false;
 | 
				
			||||||
        isGpsEnabled = false;
 | 
					        isGpsEnabled = false;
 | 
				
			||||||
@@ -396,7 +464,7 @@ public class MainService extends Service {
 | 
				
			|||||||
     * @return 当前GPS定位模型(未获取时返回null)
 | 
					     * @return 当前GPS定位模型(未获取时返回null)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public PositionModel getCurrentGpsPosition() {
 | 
					    public PositionModel getCurrentGpsPosition() {
 | 
				
			||||||
        return mCurrentGpsPosition;
 | 
					        return _mCurrentGpsPosition;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -490,7 +558,7 @@ public class MainService extends Service {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 持久化任务数据(Java 7 静态方法调用,保持原逻辑)
 | 
					     * 持久化任务数据(Java 7 静态方法调用,保持原逻辑)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void saveAllTasks() {
 | 
					    public void saveAllTasks() {
 | 
				
			||||||
        LogUtils.d(TAG, String.format("saveTaskList : size=%d", mAllTasks.size()));
 | 
					        LogUtils.d(TAG, String.format("saveTaskList : size=%d", mAllTasks.size()));
 | 
				
			||||||
        PositionTaskModel.saveBeanList(MainService.this, mAllTasks, PositionTaskModel.class);
 | 
					        PositionTaskModel.saveBeanList(MainService.this, mAllTasks, PositionTaskModel.class);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -501,7 +569,7 @@ public class MainService extends Service {
 | 
				
			|||||||
    public void clearAllData() {
 | 
					    public void clearAllData() {
 | 
				
			||||||
        mPositionList.clear();
 | 
					        mPositionList.clear();
 | 
				
			||||||
        mAllTasks.clear();
 | 
					        mAllTasks.clear();
 | 
				
			||||||
        mCurrentGpsPosition = null;
 | 
					        _mCurrentGpsPosition = null;
 | 
				
			||||||
        LogUtils.d(TAG, "clearAllData:已清空所有数据");
 | 
					        LogUtils.d(TAG, "clearAllData:已清空所有数据");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -514,7 +582,7 @@ public class MainService extends Service {
 | 
				
			|||||||
            LogUtils.w(TAG, "syncCurrentGpsPosition:位置为空");
 | 
					            LogUtils.w(TAG, "syncCurrentGpsPosition:位置为空");
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.mCurrentGpsPosition = position;
 | 
					        this._mCurrentGpsPosition = position;
 | 
				
			||||||
        LogUtils.d(TAG, "syncCurrentGpsPosition:成功(纬度=" + position.getLatitude() + ",经度=" + position.getLongitude() + ")");
 | 
					        LogUtils.d(TAG, "syncCurrentGpsPosition:成功(纬度=" + position.getLatitude() + ",经度=" + position.getLongitude() + ")");
 | 
				
			||||||
        notifyAllGpsListeners(position);
 | 
					        notifyAllGpsListeners(position);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -528,14 +596,14 @@ public class MainService extends Service {
 | 
				
			|||||||
     * 同步GPS状态到前台通知(Java 7 匿名Runnable切换主线程,无Lambda)
 | 
					     * 同步GPS状态到前台通知(Java 7 匿名Runnable切换主线程,无Lambda)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void syncGpsStatusToNotification() {
 | 
					    private void syncGpsStatusToNotification() {
 | 
				
			||||||
        if (!_mIsServiceRunning || mCurrentGpsPosition == null) {
 | 
					        if (!_mIsServiceRunning || _mCurrentGpsPosition == null) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // 格式化通知内容(Java 7 String.format,无String.join等Java 8+方法)
 | 
					        // 格式化通知内容(Java 7 String.format,无String.join等Java 8+方法)
 | 
				
			||||||
        final String gpsStatus = String.format(
 | 
					        final String gpsStatus = String.format(
 | 
				
			||||||
			"GPS位置:北纬%.4f° 东经%.4f° | 可见位置:%d个",
 | 
								"GPS位置:北纬%.4f° 东经%.4f° | 可见位置:%d个",
 | 
				
			||||||
			mCurrentGpsPosition.getLatitude(),
 | 
								_mCurrentGpsPosition.getLatitude(),
 | 
				
			||||||
			mCurrentGpsPosition.getLongitude(),
 | 
								_mCurrentGpsPosition.getLongitude(),
 | 
				
			||||||
			mVisiblePositionIds.size()
 | 
								mVisiblePositionIds.size()
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        // 主线程判断+切换(Java 7 匿名内部类)
 | 
					        // 主线程判断+切换(Java 7 匿名内部类)
 | 
				
			||||||
@@ -551,174 +619,7 @@ public class MainService extends Service {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 计算可见位置距离(原逻辑保留,Java 7 语法兼容,无Stream/并行流)
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void calculateVisiblePositionDistance() {
 | 
					 | 
				
			||||||
        // 原有逻辑(Java 7 语法适配:用迭代器/基础循环,无Lambda/forEach)
 | 
					 | 
				
			||||||
        // 注:原代码标注“略”,此处保持空实现,实际使用时补充具体逻辑
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 计算两点间距离(Haversine公式,纯Java 7 基础API,无数学工具类依赖)
 | 
					 | 
				
			||||||
     * @param gpsLat GPS纬度
 | 
					 | 
				
			||||||
     * @param gpsLon GPS经度
 | 
					 | 
				
			||||||
     * @param posLat 目标位置纬度
 | 
					 | 
				
			||||||
     * @param posLon 目标位置经度
 | 
					 | 
				
			||||||
     * @return 两点间距离(单位:米)
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private double calculateHaversineDistance(double gpsLat, double gpsLon, double posLat, double posLon) {
 | 
					 | 
				
			||||||
        final double EARTH_RADIUS = 6371000; // 地球半径(米)
 | 
					 | 
				
			||||||
        double latDiff = Math.toRadians(posLat - gpsLat);
 | 
					 | 
				
			||||||
        double lonDiff = Math.toRadians(posLon - gpsLon);
 | 
					 | 
				
			||||||
        // Haversine公式核心计算(Java 7 基础数学方法)
 | 
					 | 
				
			||||||
        double a = Math.sin(latDiff / 2) * Math.sin(latDiff / 2)
 | 
					 | 
				
			||||||
			+ Math.cos(Math.toRadians(gpsLat)) * Math.cos(Math.toRadians(posLat))
 | 
					 | 
				
			||||||
			* Math.sin(lonDiff / 2) * Math.sin(lonDiff / 2);
 | 
					 | 
				
			||||||
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
 | 
					 | 
				
			||||||
        return EARTH_RADIUS * c;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 强制刷新所有位置距离(GPS更新后调用,计算距离+校验任务触发条件)
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void forceRefreshDistance() {
 | 
					 | 
				
			||||||
        if (mCurrentGpsPosition == null || mPositionList.isEmpty()) {
 | 
					 | 
				
			||||||
            LogUtils.w(TAG, "forceRefreshDistance:GPS未获取或位置为空");
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 遍历所有位置计算距离(Java 7 增强for循环,无Stream)
 | 
					 | 
				
			||||||
        for (PositionModel pos : mPositionList) {
 | 
					 | 
				
			||||||
            if (pos.isEnableRealPositionDistance()) {
 | 
					 | 
				
			||||||
                try {
 | 
					 | 
				
			||||||
                    double distance = calculateHaversineDistance(
 | 
					 | 
				
			||||||
						mCurrentGpsPosition.getLatitude(),
 | 
					 | 
				
			||||||
						mCurrentGpsPosition.getLongitude(),
 | 
					 | 
				
			||||||
						pos.getLatitude(),
 | 
					 | 
				
			||||||
						pos.getLongitude()
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                    pos.setRealPositionDistance(distance);
 | 
					 | 
				
			||||||
                } catch (Exception e) {
 | 
					 | 
				
			||||||
                    pos.setRealPositionDistance(-1); // 标记距离计算失败
 | 
					 | 
				
			||||||
                    LogUtils.e(TAG, "计算距离失败:" + e.getMessage());
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                pos.setRealPositionDistance(-1); // 未启用距离计算,标记为无效
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 距离刷新后校验任务触发条件+通知GPS监听者
 | 
					 | 
				
			||||||
        checkAllTaskTriggerCondition();
 | 
					 | 
				
			||||||
        notifyAllGpsListeners(mCurrentGpsPosition);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // =========================================================================
 | 
					 | 
				
			||||||
    // 任务触发相关方法(Java 7 语法,全迭代器遍历,无Java 8+特性)
 | 
					 | 
				
			||||||
    // =========================================================================
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 校验所有任务触发条件(距离达标则触发任务通知)
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void checkAllTaskTriggerCondition() {
 | 
					 | 
				
			||||||
        if (mCurrentGpsPosition == null || mPositionList.isEmpty() || mAllTasks.isEmpty()) {
 | 
					 | 
				
			||||||
            LogUtils.d(TAG, "checkAllTaskTriggerCondition:跳过校验(GPS/位置/任务为空)");
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        LogUtils.d(TAG, "checkAllTaskTriggerCondition:开始校验(任务总数=" + mAllTasks.size() + ")");
 | 
					 | 
				
			||||||
        // 迭代器遍历任务(Java 7 安全遍历,避免并发修改异常)
 | 
					 | 
				
			||||||
        Iterator<PositionTaskModel> taskIter = mAllTasks.iterator();
 | 
					 | 
				
			||||||
        while (taskIter.hasNext()) {
 | 
					 | 
				
			||||||
            PositionTaskModel task = taskIter.next();
 | 
					 | 
				
			||||||
            // 仅校验“已启用”且“绑定有效位置”的任务
 | 
					 | 
				
			||||||
            if (!task.isEnable() || TextUtils.isEmpty(task.getPositionId())) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 查找任务绑定的位置(Java 7 迭代器遍历位置列表)
 | 
					 | 
				
			||||||
            PositionModel bindPos = null;
 | 
					 | 
				
			||||||
            Iterator<PositionModel> posIter = mPositionList.iterator();
 | 
					 | 
				
			||||||
            while (posIter.hasNext()) {
 | 
					 | 
				
			||||||
                PositionModel pos = posIter.next();
 | 
					 | 
				
			||||||
                if (task.getPositionId().equals(pos.getPositionId())) {
 | 
					 | 
				
			||||||
                    bindPos = pos;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (bindPos == null) {
 | 
					 | 
				
			||||||
                LogUtils.w(TAG, "任务ID=" + task.getTaskId() + ":绑定位置不存在,跳过");
 | 
					 | 
				
			||||||
                task.setIsBingo(false);
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 校验距离条件(判断是否满足任务触发阈值)
 | 
					 | 
				
			||||||
            double currentDistance = bindPos.getRealPositionDistance();
 | 
					 | 
				
			||||||
            if (currentDistance < 0) {
 | 
					 | 
				
			||||||
                LogUtils.w(TAG, "任务ID=" + task.getTaskId() + ":距离计算失败,跳过");
 | 
					 | 
				
			||||||
                task.setIsBingo(false);
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            boolean isTriggered = false;
 | 
					 | 
				
			||||||
            int taskDistance = task.getDiscussDistance();
 | 
					 | 
				
			||||||
            // 任务触发条件:大于/小于指定距离(Java 7 基础判断,无三元运算符嵌套)
 | 
					 | 
				
			||||||
            if (task.isGreaterThan()) {
 | 
					 | 
				
			||||||
                isTriggered = currentDistance > taskDistance;
 | 
					 | 
				
			||||||
            } else if (task.isLessThan()) {
 | 
					 | 
				
			||||||
                isTriggered = currentDistance < taskDistance;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 更新任务触发状态+发送通知(状态变化时才处理)
 | 
					 | 
				
			||||||
            if (task.isBingo() != isTriggered) {
 | 
					 | 
				
			||||||
                task.setIsBingo(isTriggered);
 | 
					 | 
				
			||||||
                if (isTriggered) {
 | 
					 | 
				
			||||||
                    sendTaskTriggerNotification(task, bindPos, currentDistance);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        saveAllTasks(); // 持久化更新后的任务状态
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 发送任务触发通知(更新前台通知+显示Toast,Java 7 匿名Runnable切换主线程)
 | 
					 | 
				
			||||||
     * @param task 触发的任务
 | 
					 | 
				
			||||||
     * @param bindPos 任务绑定的位置
 | 
					 | 
				
			||||||
     * @param currentDistance 当前距离
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void sendTaskTriggerNotification(final PositionTaskModel task, PositionModel bindPos, double currentDistance) {
 | 
					 | 
				
			||||||
        if (!_mIsServiceRunning) {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 格式化通知内容(Java 7 String.format,无TextBlock等Java 15+特性)
 | 
					 | 
				
			||||||
        final String triggerContent = String.format(
 | 
					 | 
				
			||||||
			"任务触发:%s\n位置:%s\n当前距离:%.1f米(条件:%s%d米)",
 | 
					 | 
				
			||||||
			task.getTaskDescription(),
 | 
					 | 
				
			||||||
			bindPos.getMemo(),
 | 
					 | 
				
			||||||
			currentDistance,
 | 
					 | 
				
			||||||
			task.isGreaterThan() ? ">" : "<",
 | 
					 | 
				
			||||||
			task.getDiscussDistance()
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 更新前台通知(主线程判断+切换)
 | 
					 | 
				
			||||||
        updateNotificationGpsStatus(triggerContent);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 显示Toast(主线程安全调用,Java 7 匿名内部类)
 | 
					 | 
				
			||||||
        if (Looper.myLooper() == Looper.getMainLooper()) {
 | 
					 | 
				
			||||||
            ToastUtils.show(triggerContent);
 | 
					 | 
				
			||||||
			NotificationUtil.show(MainService.this, task.getTaskId(), task.getPositionId(), task.getTaskDescription());
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            new Handler(Looper.getMainLooper()).post(new Runnable() {
 | 
					 | 
				
			||||||
					@Override
 | 
					 | 
				
			||||||
					public void run() {
 | 
					 | 
				
			||||||
						ToastUtils.show(triggerContent);
 | 
					 | 
				
			||||||
						NotificationUtil.show(MainService.this, task.getTaskId(), task.getPositionId(), task.getTaskDescription());
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				});
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        LogUtils.i(TAG, "任务触发通知:" + triggerContent);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // =========================================================================
 | 
					    // =========================================================================
 | 
				
			||||||
@@ -729,9 +630,17 @@ public class MainService extends Service {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int onStartCommand(Intent intent, int flags, int startId) {
 | 
					    public int onStartCommand(Intent intent, int flags, int startId) {
 | 
				
			||||||
        run(); // 重启服务核心逻辑(保证服务启动后进入运行状态)
 | 
							boolean isSettingToEnable = false;
 | 
				
			||||||
        // 返回START_STICKY:服务被异常杀死后,系统会尝试重启(原逻辑保留)
 | 
							if (intent != null) {
 | 
				
			||||||
        return mAppConfigsUtil.isEnableMainService(true) ? Service.START_STICKY : super.onStartCommand(intent, flags, startId);
 | 
								isSettingToEnable = intent.getBooleanExtra(EXTRA_IS_SETTING_TO_ENABLE, false);
 | 
				
			||||||
 | 
								if (isSettingToEnable) {
 | 
				
			||||||
 | 
									run(); // 重启服务核心逻辑(保证服务启动后进入运行状态)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 如果被设置为自启动就返回START_STICKY:服务被异常杀死后,系统会尝试重启(原逻辑保留)
 | 
				
			||||||
 | 
							// 否则就启动默认参数
 | 
				
			||||||
 | 
					        return isSettingToEnable ? Service.START_STICKY : super.onStartCommand(intent, flags, startId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -753,7 +662,7 @@ public class MainService extends Service {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 唤醒并绑定辅助服务(检查服务状态,未存活则启动+绑定)
 | 
						 * 唤醒并绑定辅助服务(检查服务状态,未存活则启动+绑定)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void wakeupAndBindAssistant() {
 | 
					    void wakeupAndBindAssistant() {
 | 
				
			||||||
        // 检查辅助服务是否存活(Java 7 静态方法调用,无方法引用)
 | 
					        // 检查辅助服务是否存活(Java 7 静态方法调用,无方法引用)
 | 
				
			||||||
@@ -794,7 +703,7 @@ public class MainService extends Service {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    // 同步GPS位置+刷新距离+日志(原逻辑保留)
 | 
					                    // 同步GPS位置+刷新距离+日志(原逻辑保留)
 | 
				
			||||||
                    syncCurrentGpsPosition(gpsPos);
 | 
					                    syncCurrentGpsPosition(gpsPos);
 | 
				
			||||||
                    forceRefreshDistance();
 | 
										DistanceCalculatorUtil.getInstance(MainService.this).checkAllTaskTriggerCondition(gpsPos);
 | 
				
			||||||
                    LogUtils.d(TAG, "GPS位置更新:纬度=" + location.getLatitude() + ",经度=" + location.getLongitude());
 | 
					                    LogUtils.d(TAG, "GPS位置更新:纬度=" + location.getLatitude() + ",经度=" + location.getLongitude());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -840,7 +749,7 @@ public class MainService extends Service {
 | 
				
			|||||||
                // GPS禁用时清空状态+通知+提示(Java 7 基础逻辑)
 | 
					                // GPS禁用时清空状态+通知+提示(Java 7 基础逻辑)
 | 
				
			||||||
                if (provider.equals(LocationManager.GPS_PROVIDER)) {
 | 
					                if (provider.equals(LocationManager.GPS_PROVIDER)) {
 | 
				
			||||||
                    isGpsEnabled = false;
 | 
					                    isGpsEnabled = false;
 | 
				
			||||||
                    mCurrentGpsPosition = null;
 | 
					                    _mCurrentGpsPosition = null;
 | 
				
			||||||
                    String statusDesc = "GPS已关闭(用户手动关闭)";
 | 
					                    String statusDesc = "GPS已关闭(用户手动关闭)";
 | 
				
			||||||
                    LogUtils.w(TAG, statusDesc);
 | 
					                    LogUtils.w(TAG, statusDesc);
 | 
				
			||||||
                    notifyAllGpsStatusListeners(statusDesc);
 | 
					                    notifyAllGpsStatusListeners(statusDesc);
 | 
				
			||||||
@@ -959,11 +868,52 @@ public class MainService extends Service {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 发送任务触发通知(更新前台通知+显示Toast,Java 7 匿名Runnable切换主线程)
 | 
				
			||||||
 | 
					     * @param task 触发的任务
 | 
				
			||||||
 | 
					     * @param bindPos 任务绑定的位置
 | 
				
			||||||
 | 
					     * @param currentDistance 当前距离
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void sendTaskTriggerNotification(final PositionTaskModel task, PositionModel bindPos, double currentDistance) {
 | 
				
			||||||
 | 
					        /*if (!_mIsServiceRunning) {
 | 
				
			||||||
 | 
							 return;
 | 
				
			||||||
 | 
							 }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 格式化通知内容(Java 7 String.format,无TextBlock等Java 15+特性)
 | 
				
			||||||
 | 
					        final String triggerContent = String.format(
 | 
				
			||||||
 | 
								"任务触发:%s\n位置:%s\n当前距离:%.1f米(条件:%s%d米)",
 | 
				
			||||||
 | 
								task.getTaskDescription(),
 | 
				
			||||||
 | 
								bindPos.getMemo(),
 | 
				
			||||||
 | 
								currentDistance,
 | 
				
			||||||
 | 
								task.isGreaterThan() ? ">" : "<",
 | 
				
			||||||
 | 
								task.getDiscussDistance()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 更新前台通知(主线程判断+切换)
 | 
				
			||||||
 | 
					        updateNotificationGpsStatus(triggerContent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 显示Toast(主线程安全调用,Java 7 匿名内部类)
 | 
				
			||||||
 | 
					        if (Looper.myLooper() == Looper.getMainLooper()) {
 | 
				
			||||||
 | 
					            ToastUtils.show(triggerContent);
 | 
				
			||||||
 | 
								NotificationUtil.show(MainService.this, task.getTaskId(), task.getPositionId(), task.getTaskDescription());
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            new Handler(Looper.getMainLooper()).post(new Runnable() {
 | 
				
			||||||
 | 
										@Override
 | 
				
			||||||
 | 
										public void run() {
 | 
				
			||||||
 | 
											ToastUtils.show(triggerContent);
 | 
				
			||||||
 | 
											NotificationUtil.show(MainService.this, task.getTaskId(), task.getPositionId(), task.getTaskDescription());
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									});
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        LogUtils.i(TAG, "任务触发通知:" + triggerContent);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 更新前台通知的GPS状态(Java 7 主线程切换,匿名Runnable实现)
 | 
					     * 更新前台通知的GPS状态(Java 7 主线程切换,匿名Runnable实现)
 | 
				
			||||||
     * @param statusText 通知显示的状态文本
 | 
					     * @param statusText 通知显示的状态文本
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void updateNotificationGpsStatus(final String statusText) {
 | 
					    void updateNotificationGpsStatus(final String statusText) {
 | 
				
			||||||
        if (_mIsServiceRunning) {
 | 
					        if (_mIsServiceRunning) {
 | 
				
			||||||
            // 判断当前线程是否为主线程,避免UI操作在子线程
 | 
					            // 判断当前线程是否为主线程,避免UI操作在子线程
 | 
				
			||||||
            if (Looper.myLooper() == Looper.getMainLooper()) {
 | 
					            if (Looper.myLooper() == Looper.getMainLooper()) {
 | 
				
			||||||
@@ -987,7 +937,7 @@ public class MainService extends Service {
 | 
				
			|||||||
     * 通知所有GPS监听者位置更新(Java 7 迭代器+弱引用管理,无Stream)
 | 
					     * 通知所有GPS监听者位置更新(Java 7 迭代器+弱引用管理,无Stream)
 | 
				
			||||||
     * @param currentGpsPos 当前最新GPS位置
 | 
					     * @param currentGpsPos 当前最新GPS位置
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void notifyAllGpsListeners(PositionModel currentGpsPos) {
 | 
					    public void notifyAllGpsListeners(PositionModel currentGpsPos) {
 | 
				
			||||||
        if (currentGpsPos == null || mGpsListeners.isEmpty()) {
 | 
					        if (currentGpsPos == null || mGpsListeners.isEmpty()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -1068,8 +1018,8 @@ public class MainService extends Service {
 | 
				
			|||||||
            mGpsListeners.add(new WeakReference<GpsUpdateListener>(listener));
 | 
					            mGpsListeners.add(new WeakReference<GpsUpdateListener>(listener));
 | 
				
			||||||
            LogUtils.d(TAG, "GPS监听注册成功,当前数量:" + mGpsListeners.size());
 | 
					            LogUtils.d(TAG, "GPS监听注册成功,当前数量:" + mGpsListeners.size());
 | 
				
			||||||
            // 注册后立即推送当前GPS位置(避免监听者错过初始数据)
 | 
					            // 注册后立即推送当前GPS位置(避免监听者错过初始数据)
 | 
				
			||||||
            if (mCurrentGpsPosition != null) {
 | 
					            if (_mCurrentGpsPosition != null) {
 | 
				
			||||||
                notifySingleListener(listener, mCurrentGpsPosition);
 | 
					                notifySingleListener(listener, _mCurrentGpsPosition);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,11 +41,11 @@ public class AppConfigsUtil {
 | 
				
			|||||||
        return sInstance;
 | 
					        return sInstance;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void loadConfigs() {
 | 
						public void loadConfigs() {
 | 
				
			||||||
		mAppConfigsModel = AppConfigsModel.loadBean(mContext, AppConfigsModel.class);
 | 
							mAppConfigsModel = AppConfigsModel.loadBean(mContext, AppConfigsModel.class);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void saveConfigs() {
 | 
						public void saveConfigs() {
 | 
				
			||||||
		AppConfigsModel.saveBean(mContext, mAppConfigsModel);
 | 
							AppConfigsModel.saveBean(mContext, mAppConfigsModel);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.utils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
 | 
				
			||||||
 | 
					 * @Date 2025/10/22 01:16
 | 
				
			||||||
 | 
					 * @Describe DensityUtils
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.util.DisplayMetrics;
 | 
				
			||||||
 | 
					import android.view.WindowManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 屏幕密度工具类(dp/sp 转 px、获取屏幕尺寸)
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DensityUtils {
 | 
				
			||||||
 | 
						public static final String TAG = "DensityUtils";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * dp 转 px(根据屏幕密度)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static int dp2px(Context context, float dpValue) {
 | 
				
			||||||
 | 
							final float scale = context.getResources().getDisplayMetrics().density;
 | 
				
			||||||
 | 
							return (int) (dpValue * scale + 0.5f);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * sp 转 px(根据文字缩放比例)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static int sp2px(Context context, float spValue) {
 | 
				
			||||||
 | 
							final float scale = context.getResources().getDisplayMetrics().scaledDensity;
 | 
				
			||||||
 | 
							return (int) (spValue * scale + 0.5f);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 获取屏幕宽度(像素)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static int getScreenWidth(Context context) {
 | 
				
			||||||
 | 
							WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
 | 
				
			||||||
 | 
							DisplayMetrics dm = new DisplayMetrics();
 | 
				
			||||||
 | 
							wm.getDefaultDisplay().getMetrics(dm);
 | 
				
			||||||
 | 
							return dm.widthPixels;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,246 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.utils;
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.os.Handler;
 | 
				
			||||||
 | 
					import android.os.Looper;
 | 
				
			||||||
 | 
					import android.text.TextUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.LogUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.ToastUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.models.PositionModel;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.models.PositionTaskModel;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.services.MainService;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Iterator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
 | 
				
			||||||
 | 
					 * @Date 2025/10/27 18:40
 | 
				
			||||||
 | 
					 * @Describe 距离计算工具集(单例模式)
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DistanceCalculatorUtil {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final String TAG = "DistanceCalculatorUtil";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 1. 私有静态 volatile 实例:保证多线程下实例可见性,避免指令重排序导致的空指针
 | 
				
			||||||
 | 
					    private static volatile DistanceCalculatorUtil sInstance;
 | 
				
			||||||
 | 
						Context mContext;
 | 
				
			||||||
 | 
						ArrayList<PositionModel> mPositionList;   // 位置数据列表
 | 
				
			||||||
 | 
					    ArrayList<PositionTaskModel> mAllTasks;// 任务数据列表
 | 
				
			||||||
 | 
						PositionModel mGpsPositionCalculated;
 | 
				
			||||||
 | 
						long mLastCalculatedTime = 0;
 | 
				
			||||||
 | 
						long mMinCalculatedTimeBettween = 30000; // GPS数据更新时,两次计算之间的最小时间间隔
 | 
				
			||||||
 | 
						double mMinjumpDistance = 10.0f; // GPS数据更新时,能跳跃距离最小有效值,达到有效值时,两次计算之间的最小时间间隔阀值将被忽略。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 2. 私有构造器:禁止外部通过 new 关键字创建实例,确保单例唯一性
 | 
				
			||||||
 | 
					    private DistanceCalculatorUtil(Context context) {
 | 
				
			||||||
 | 
					        // 可选:初始化工具类依赖的资源(如配置参数、缓存等)
 | 
				
			||||||
 | 
							mContext = context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        LogUtils.d(TAG, "DistanceCalculatorUtil 单例实例初始化");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 3. 公开静态方法:双重校验锁获取单例,兼顾线程安全与性能
 | 
				
			||||||
 | 
					    public static DistanceCalculatorUtil getInstance(Context context) {
 | 
				
			||||||
 | 
					        // 第一重校验:避免已创建实例时的频繁加锁,提升性能
 | 
				
			||||||
 | 
					        if (sInstance == null) {
 | 
				
			||||||
 | 
					            // 加锁:确保多线程下仅一个线程进入实例创建逻辑
 | 
				
			||||||
 | 
					            synchronized (DistanceCalculatorUtil.class) {
 | 
				
			||||||
 | 
					                // 第二重校验:防止多线程并发时重复创建实例
 | 
				
			||||||
 | 
					                if (sInstance == null) {
 | 
				
			||||||
 | 
					                    sInstance = new DistanceCalculatorUtil(context);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return sInstance;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ---------------------- 以下可补充距离计算相关工具方法 ----------------------
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 示例:Haversine 公式计算两点间距离(单位:米)
 | 
				
			||||||
 | 
					     * @param lat1 第一点纬度
 | 
				
			||||||
 | 
					     * @param lon1 第一点经度
 | 
				
			||||||
 | 
					     * @param lat2 第二点纬度
 | 
				
			||||||
 | 
					     * @param lon2 第二点经度
 | 
				
			||||||
 | 
					     * @return 两点间直线距离(米),计算失败返回 -1
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static double calculateHaversineDistance(double lat1, double lon1, double lat2, double lon2) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            final double EARTH_RADIUS = 6371000; // 地球半径(米)
 | 
				
			||||||
 | 
					            // 角度转弧度
 | 
				
			||||||
 | 
					            double latDiff = Math.toRadians(lat2 - lat1);
 | 
				
			||||||
 | 
					            double lonDiff = Math.toRadians(lon2 - lon1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Haversine 核心公式
 | 
				
			||||||
 | 
					            double a = Math.sin(latDiff / 2) * Math.sin(latDiff / 2)
 | 
				
			||||||
 | 
									+ Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
 | 
				
			||||||
 | 
									* Math.sin(lonDiff / 2) * Math.sin(lonDiff / 2);
 | 
				
			||||||
 | 
					            double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return EARTH_RADIUS * c; // 返回距离(米)
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, "Haversine 距离计算失败:" + e.getMessage());
 | 
				
			||||||
 | 
					            return -1; // 标记计算失败
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 计算两点间距离(Haversine公式,纯Java 7 基础API,无数学工具类依赖)
 | 
				
			||||||
 | 
					     * @param gpsLat GPS纬度
 | 
				
			||||||
 | 
					     * @param gpsLon GPS经度
 | 
				
			||||||
 | 
					     * @param posLat 目标位置纬度
 | 
				
			||||||
 | 
					     * @param posLon 目标位置经度
 | 
				
			||||||
 | 
					     * @return 两点间距离(单位:米)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    /*private double calculateHaversineDistance(double gpsLat, double gpsLon, double posLat, double posLon) {
 | 
				
			||||||
 | 
						 final double EARTH_RADIUS = 6371000; // 地球半径(米)
 | 
				
			||||||
 | 
						 double latDiff = Math.toRadians(posLat - gpsLat);
 | 
				
			||||||
 | 
						 double lonDiff = Math.toRadians(posLon - gpsLon);
 | 
				
			||||||
 | 
						 // Haversine公式核心计算(Java 7 基础数学方法)
 | 
				
			||||||
 | 
						 double a = Math.sin(latDiff / 2) * Math.sin(latDiff / 2)
 | 
				
			||||||
 | 
						 + Math.cos(Math.toRadians(gpsLat)) * Math.cos(Math.toRadians(posLat))
 | 
				
			||||||
 | 
						 * Math.sin(lonDiff / 2) * Math.sin(lonDiff / 2);
 | 
				
			||||||
 | 
						 double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
 | 
				
			||||||
 | 
						 return EARTH_RADIUS * c;
 | 
				
			||||||
 | 
						 }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
					     * 校验所有任务触发条件(距离达标则触发任务通知)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void checkAllTaskTriggerCondition(PositionModel currentGpsPosition) {
 | 
				
			||||||
 | 
							if (currentGpsPosition == null) {
 | 
				
			||||||
 | 
								LogUtils.d(TAG, "传入坐标参数为空,退出函数。");
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 计算频率控制模块
 | 
				
			||||||
 | 
							//
 | 
				
			||||||
 | 
							// 计算与最近一次GPS计算的时间间隔
 | 
				
			||||||
 | 
							long nCalculatedTimeBettween = System.currentTimeMillis() - mLastCalculatedTime;
 | 
				
			||||||
 | 
							// 计算跳跃距离
 | 
				
			||||||
 | 
							double gpsPositionCalculatedLatitude = mGpsPositionCalculated == null ?0.0f: mGpsPositionCalculated.getLatitude();
 | 
				
			||||||
 | 
							double gpsPositionCalculatedLongitude = mGpsPositionCalculated == null ?0.0f: mGpsPositionCalculated.getLongitude();
 | 
				
			||||||
 | 
							double jumpDistance = calculateHaversineDistance(gpsPositionCalculatedLatitude, gpsPositionCalculatedLongitude, currentGpsPosition.getLatitude(), currentGpsPosition.getLongitude());
 | 
				
			||||||
 | 
							if (jumpDistance < mMinjumpDistance) {
 | 
				
			||||||
 | 
								LogUtils.d(TAG, String.format("checkAllTaskTriggerCondition:跳跃距离%f,小于50米。", jumpDistance));
 | 
				
			||||||
 | 
								// 跳跃距离小于最小有效跳跃值
 | 
				
			||||||
 | 
								if (nCalculatedTimeBettween < mMinCalculatedTimeBettween) {
 | 
				
			||||||
 | 
									//间隔小于最小时间间隔设定
 | 
				
			||||||
 | 
									LogUtils.d(TAG, String.format("checkAllTaskTriggerCondition:与最近一次计算间隔时间%d,坐标变化忽略。", nCalculatedTimeBettween));
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (mGpsPositionCalculated == null) {
 | 
				
			||||||
 | 
								mGpsPositionCalculated = currentGpsPosition;
 | 
				
			||||||
 | 
								LogUtils.d(TAG, "最后计算位置记录为空,现在使用新坐标为初始化。");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							LogUtils.d(TAG, String.format("checkAllTaskTriggerCondition:跳跃距离%f,与上次计算间隔%d,现在启动任务数据计算。", jumpDistance, nCalculatedTimeBettween));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 获取位置任务基础数据
 | 
				
			||||||
 | 
							MainService mainService = MainService.getInstance(mContext);
 | 
				
			||||||
 | 
							mPositionList = mainService.getPositionList();
 | 
				
			||||||
 | 
							mAllTasks = mainService.getAllTasks();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 位置数据为空,跳过校验。
 | 
				
			||||||
 | 
					        if (mPositionList.isEmpty()) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, "checkAllTaskTriggerCondition:位置数据为空,跳过距离计算。");
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 更新所有位置点的位置距离数据
 | 
				
			||||||
 | 
							refreshRealPositionDistance(currentGpsPosition);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 任务数据为空,跳过校验。
 | 
				
			||||||
 | 
					        if (mAllTasks.isEmpty()) {
 | 
				
			||||||
 | 
					            LogUtils.d(TAG, "checkAllTaskTriggerCondition:任务数据为空,跳过任务提醒检查计算。");
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 迭代器遍历任务(Java 7 安全遍历,避免并发修改异常)
 | 
				
			||||||
 | 
					        Iterator<PositionTaskModel> taskIter = mAllTasks.iterator();
 | 
				
			||||||
 | 
					        while (taskIter.hasNext()) {
 | 
				
			||||||
 | 
					            PositionTaskModel task = taskIter.next();
 | 
				
			||||||
 | 
					            // 仅校验“已启用”且“绑定有效位置”的任务
 | 
				
			||||||
 | 
					            if (!task.isEnable() || TextUtils.isEmpty(task.getPositionId())) {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 查找任务绑定的位置(Java 7 迭代器遍历位置列表)
 | 
				
			||||||
 | 
					            PositionModel bindPos = null;
 | 
				
			||||||
 | 
					            Iterator<PositionModel> posIter = mPositionList.iterator();
 | 
				
			||||||
 | 
					            while (posIter.hasNext()) {
 | 
				
			||||||
 | 
					                PositionModel pos = posIter.next();
 | 
				
			||||||
 | 
					                if (task.getPositionId().equals(pos.getPositionId())) {
 | 
				
			||||||
 | 
					                    bindPos = pos;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (bindPos == null) {
 | 
				
			||||||
 | 
					                LogUtils.w(TAG, "任务ID=" + task.getTaskId() + ":绑定位置不存在,跳过");
 | 
				
			||||||
 | 
					                task.setIsBingo(false);
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 校验任务开始时间
 | 
				
			||||||
 | 
								if (task.getStartTime() > System.currentTimeMillis()) {
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 校验距离条件(判断是否满足任务触发阈值)
 | 
				
			||||||
 | 
					            double currentDistance = bindPos.getRealPositionDistance();
 | 
				
			||||||
 | 
					            if (currentDistance < 0) {
 | 
				
			||||||
 | 
					                LogUtils.w(TAG, "任务ID=" + task.getTaskId() + ":距离计算失败,跳过");
 | 
				
			||||||
 | 
					                task.setIsBingo(false);
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            boolean isTriggered = false;
 | 
				
			||||||
 | 
					            int taskDistance = task.getDiscussDistance();
 | 
				
			||||||
 | 
					            // 任务触发条件:大于/小于指定距离(Java 7 基础判断,无三元运算符嵌套)
 | 
				
			||||||
 | 
					            if (task.isGreaterThan()) {
 | 
				
			||||||
 | 
					                isTriggered = currentDistance > taskDistance;
 | 
				
			||||||
 | 
					            } else if (task.isLessThan()) {
 | 
				
			||||||
 | 
					                isTriggered = currentDistance < taskDistance;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 更新任务触发状态+发送通知(状态变化时才处理)
 | 
				
			||||||
 | 
					            if (task.isBingo() != isTriggered) {
 | 
				
			||||||
 | 
					                task.setIsBingo(isTriggered);
 | 
				
			||||||
 | 
					                if (isTriggered) {
 | 
				
			||||||
 | 
					                    MainService.getInstance(mContext).sendTaskTriggerNotification(task, bindPos, currentDistance);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        MainService.getInstance(mContext).saveAllTasks(); // 持久化更新后的任务状态
 | 
				
			||||||
 | 
							// 记录最后坐标更新点
 | 
				
			||||||
 | 
							mGpsPositionCalculated = currentGpsPosition;
 | 
				
			||||||
 | 
							// 记录数据计算时间
 | 
				
			||||||
 | 
							mLastCalculatedTime = System.currentTimeMillis();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 强制刷新所有位置距离(GPS更新后调用,计算距离+校验任务触发条件)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void refreshRealPositionDistance(PositionModel currentGpsPosition) {
 | 
				
			||||||
 | 
					        // 遍历所有位置计算距离(Java 7 增强for循环,无Stream)
 | 
				
			||||||
 | 
					        for (PositionModel pos : mPositionList) {
 | 
				
			||||||
 | 
					            if (pos.isEnableRealPositionDistance()) {
 | 
				
			||||||
 | 
									double distance = DistanceCalculatorUtil.calculateHaversineDistance(
 | 
				
			||||||
 | 
										currentGpsPosition.getLatitude(),
 | 
				
			||||||
 | 
										currentGpsPosition.getLongitude(),
 | 
				
			||||||
 | 
										pos.getLatitude(),
 | 
				
			||||||
 | 
										pos.getLongitude()
 | 
				
			||||||
 | 
									);
 | 
				
			||||||
 | 
									pos.setRealPositionDistance(distance);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                pos.setRealPositionDistance(-1); // 未启用距离计算,标记为无效
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 距离刷新后通知GPS监听者
 | 
				
			||||||
 | 
					        MainService.getInstance(mContext).notifyAllGpsListeners(currentGpsPosition);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -7,6 +7,10 @@ package cc.winboll.studio.positions.utils;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
import android.app.ActivityManager;
 | 
					import android.app.ActivityManager;
 | 
				
			||||||
import android.content.Context;
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.content.Intent;
 | 
				
			||||||
 | 
					import cc.winboll.studio.libappbase.LogUtils;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.services.AssistantService;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.services.MainService;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ServiceUtil {
 | 
					public class ServiceUtil {
 | 
				
			||||||
@@ -31,4 +35,35 @@ public class ServiceUtil {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static void stopAutoService(Context context) {
 | 
				
			||||||
 | 
							AppConfigsUtil appConfigsUtil = AppConfigsUtil.getInstance(context);
 | 
				
			||||||
 | 
							appConfigsUtil.setIsEnableMainService(false);
 | 
				
			||||||
 | 
							appConfigsUtil.saveConfigs();
 | 
				
			||||||
 | 
							// 关闭并设置主服务
 | 
				
			||||||
 | 
							Intent intent1 = new Intent(context, MainService.class);
 | 
				
			||||||
 | 
							intent1.putExtra(MainService.EXTRA_IS_SETTING_TO_ENABLE, false);
 | 
				
			||||||
 | 
							context.stopService(intent1); // 先停止旧服务
 | 
				
			||||||
 | 
							context.startService(intent1); // 传入新的启动标志位,返回给系统
 | 
				
			||||||
 | 
							// 关闭并设置主服务守护进程
 | 
				
			||||||
 | 
							Intent intent2 = new Intent(context, AssistantService.class);
 | 
				
			||||||
 | 
							intent2.putExtra(AssistantService.EXTRA_IS_SETTING_TO_ENABLE, false);
 | 
				
			||||||
 | 
							context.stopService(intent2); // 先停止旧服务
 | 
				
			||||||
 | 
							context.startService(intent2); // 传入新的启动标志位,返回给系统
 | 
				
			||||||
 | 
							// 再次关闭所有服务
 | 
				
			||||||
 | 
							context.stopService(intent1);
 | 
				
			||||||
 | 
							context.stopService(intent2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							LogUtils.d(TAG, "stopAutoService");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static void startAutoService(Context context) {
 | 
				
			||||||
 | 
							AppConfigsUtil appConfigsUtil = AppConfigsUtil.getInstance(context);
 | 
				
			||||||
 | 
							appConfigsUtil.setIsEnableMainService(true);
 | 
				
			||||||
 | 
							appConfigsUtil.saveConfigs();
 | 
				
			||||||
 | 
							Intent intent = new Intent(context, MainService.class);
 | 
				
			||||||
 | 
							intent.putExtra(MainService.EXTRA_IS_SETTING_TO_ENABLE, true);
 | 
				
			||||||
 | 
							context.startService(intent);
 | 
				
			||||||
 | 
							LogUtils.d(TAG, "startAutoService");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,254 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.views;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
 | 
				
			||||||
 | 
					 * @Date 2025/10/22 02:15
 | 
				
			||||||
 | 
					 * @Describe DateTimePickerPopup
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.view.LayoutInflater;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.view.ViewGroup;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					import android.widget.NumberPicker;
 | 
				
			||||||
 | 
					import android.widget.PopupWindow;
 | 
				
			||||||
 | 
					import java.util.Calendar;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.utils.DensityUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 日期时间选择弹窗(竖直滚动行:年、月、日、时、分)
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DateTimePickerPopup extends PopupWindow {
 | 
				
			||||||
 | 
						public static final String TAG = "DateTimePickerPopup";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Context mContext;
 | 
				
			||||||
 | 
					    private NumberPicker mPickerYear;
 | 
				
			||||||
 | 
					    private NumberPicker mPickerMonth;
 | 
				
			||||||
 | 
					    private NumberPicker mPickerDay;
 | 
				
			||||||
 | 
					    private NumberPicker mPickerHour;
 | 
				
			||||||
 | 
					    private NumberPicker mPickerMinute;
 | 
				
			||||||
 | 
					    private Button mBtnCancel;
 | 
				
			||||||
 | 
					    private Button mBtnConfirm;
 | 
				
			||||||
 | 
					    private OnDateTimeSelectedListener mListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 时间范围默认值
 | 
				
			||||||
 | 
					    private int mMinYear = 2000;
 | 
				
			||||||
 | 
					    private int mMaxYear = Calendar.getInstance().get(Calendar.YEAR) + 10;
 | 
				
			||||||
 | 
					    private int mMinMonth = 1;
 | 
				
			||||||
 | 
					    private int mMaxMonth = 12;
 | 
				
			||||||
 | 
					    private int mMinDay = 1;
 | 
				
			||||||
 | 
					    private int mMaxDay = 31;
 | 
				
			||||||
 | 
					    private int mMinHour = 0;
 | 
				
			||||||
 | 
					    private int mMaxHour = 23;
 | 
				
			||||||
 | 
					    private int mMinMinute = 0;
 | 
				
			||||||
 | 
					    private int mMaxMinute = 59;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 默认选中时间
 | 
				
			||||||
 | 
					    private int mDefaultYear;
 | 
				
			||||||
 | 
					    private int mDefaultMonth;
 | 
				
			||||||
 | 
					    private int mDefaultDay;
 | 
				
			||||||
 | 
					    private int mDefaultHour;
 | 
				
			||||||
 | 
					    private int mDefaultMinute;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 日期时间选择回调
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public interface OnDateTimeSelectedListener {
 | 
				
			||||||
 | 
					        void onDateTimeSelected(int year, int month, int day, int hour, int minute);
 | 
				
			||||||
 | 
					        void onCancel();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Builder 模式
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static class Builder {
 | 
				
			||||||
 | 
					        private Context mContext;
 | 
				
			||||||
 | 
					        private DateTimePickerPopup mPopup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder(Context context) {
 | 
				
			||||||
 | 
					            this.mContext = context;
 | 
				
			||||||
 | 
					            mPopup = new DateTimePickerPopup(context);
 | 
				
			||||||
 | 
					            Calendar calendar = Calendar.getInstance();
 | 
				
			||||||
 | 
					            mPopup.mDefaultYear = calendar.get(Calendar.YEAR);
 | 
				
			||||||
 | 
					            mPopup.mDefaultMonth = calendar.get(Calendar.MONTH) + 1;
 | 
				
			||||||
 | 
					            mPopup.mDefaultDay = calendar.get(Calendar.DAY_OF_MONTH);
 | 
				
			||||||
 | 
					            mPopup.mDefaultHour = calendar.get(Calendar.HOUR_OF_DAY);
 | 
				
			||||||
 | 
					            mPopup.mDefaultMinute = calendar.get(Calendar.MINUTE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder setDateTimeRange(int minYear, int maxYear, int minMonth, int maxMonth,
 | 
				
			||||||
 | 
					                                       int minDay, int maxDay, int minHour, int maxHour,
 | 
				
			||||||
 | 
					                                       int minMinute, int maxMinute) {
 | 
				
			||||||
 | 
					            mPopup.mMinYear = minYear;
 | 
				
			||||||
 | 
					            mPopup.mMaxYear = maxYear;
 | 
				
			||||||
 | 
					            mPopup.mMinMonth = minMonth;
 | 
				
			||||||
 | 
					            mPopup.mMaxMonth = maxMonth;
 | 
				
			||||||
 | 
					            mPopup.mMinDay = minDay;
 | 
				
			||||||
 | 
					            mPopup.mMaxDay = maxDay;
 | 
				
			||||||
 | 
					            mPopup.mMinHour = minHour;
 | 
				
			||||||
 | 
					            mPopup.mMaxHour = maxHour;
 | 
				
			||||||
 | 
					            mPopup.mMinMinute = minMinute;
 | 
				
			||||||
 | 
					            mPopup.mMaxMinute = maxMinute;
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder setDefaultDateTime(int year, int month, int day, int hour, int minute) {
 | 
				
			||||||
 | 
					            mPopup.mDefaultYear = year;
 | 
				
			||||||
 | 
					            mPopup.mDefaultMonth = month;
 | 
				
			||||||
 | 
					            mPopup.mDefaultDay = day;
 | 
				
			||||||
 | 
					            mPopup.mDefaultHour = hour;
 | 
				
			||||||
 | 
					            mPopup.mDefaultMinute = minute;
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder setOnDateTimeSelectedListener(OnDateTimeSelectedListener listener) {
 | 
				
			||||||
 | 
					            mPopup.mListener = listener;
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DateTimePickerPopup build() {
 | 
				
			||||||
 | 
					            mPopup.initView();
 | 
				
			||||||
 | 
					            mPopup.initPickers();
 | 
				
			||||||
 | 
					            mPopup.bindButtonClick();
 | 
				
			||||||
 | 
					            mPopup.setPopupStyle();
 | 
				
			||||||
 | 
					            return mPopup;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private DateTimePickerPopup(Context context) {
 | 
				
			||||||
 | 
					        super(context);
 | 
				
			||||||
 | 
					        this.mContext = context;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void initView() {
 | 
				
			||||||
 | 
					        LayoutInflater inflater = LayoutInflater.from(mContext);
 | 
				
			||||||
 | 
					        View rootView = inflater.inflate(R.layout.dialog_date_time_picker, null, false);
 | 
				
			||||||
 | 
					        setContentView(rootView);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mPickerYear = (NumberPicker) rootView.findViewById(R.id.picker_year);
 | 
				
			||||||
 | 
					        mPickerMonth = (NumberPicker) rootView.findViewById(R.id.picker_month);
 | 
				
			||||||
 | 
					        mPickerDay = (NumberPicker) rootView.findViewById(R.id.picker_day);
 | 
				
			||||||
 | 
					        mPickerHour = (NumberPicker) rootView.findViewById(R.id.picker_hour);
 | 
				
			||||||
 | 
					        mPickerMinute = (NumberPicker) rootView.findViewById(R.id.picker_minute);
 | 
				
			||||||
 | 
					        mBtnCancel = (Button) rootView.findViewById(R.id.btn_cancel);
 | 
				
			||||||
 | 
					        mBtnConfirm = (Button) rootView.findViewById(R.id.btn_confirm);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void initPickers() {
 | 
				
			||||||
 | 
					        // 初始化年选择器
 | 
				
			||||||
 | 
					        mPickerYear.setMinValue(mMinYear);
 | 
				
			||||||
 | 
					        mPickerYear.setMaxValue(mMaxYear);
 | 
				
			||||||
 | 
					        mPickerYear.setValue(mDefaultYear);
 | 
				
			||||||
 | 
					        mPickerYear.setWrapSelectorWheel(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 初始化月选择器
 | 
				
			||||||
 | 
					        mPickerMonth.setMinValue(mMinMonth);
 | 
				
			||||||
 | 
					        mPickerMonth.setMaxValue(mMaxMonth);
 | 
				
			||||||
 | 
					        mPickerMonth.setValue(mDefaultMonth);
 | 
				
			||||||
 | 
					        mPickerMonth.setWrapSelectorWheel(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 初始化日选择器(根据年月动态调整范围)
 | 
				
			||||||
 | 
					        updateDayRange(mDefaultYear, mDefaultMonth);
 | 
				
			||||||
 | 
					        mPickerDay.setValue(mDefaultDay);
 | 
				
			||||||
 | 
					        mPickerDay.setWrapSelectorWheel(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 初始化时选择器
 | 
				
			||||||
 | 
					        mPickerHour.setMinValue(mMinHour);
 | 
				
			||||||
 | 
					        mPickerHour.setMaxValue(mMaxHour);
 | 
				
			||||||
 | 
					        mPickerHour.setValue(mDefaultHour);
 | 
				
			||||||
 | 
					        mPickerHour.setWrapSelectorWheel(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 初始化分选择器
 | 
				
			||||||
 | 
					        mPickerMinute.setMinValue(mMinMinute);
 | 
				
			||||||
 | 
					        mPickerMinute.setMaxValue(mMaxMinute);
 | 
				
			||||||
 | 
					        mPickerMinute.setValue(mDefaultMinute);
 | 
				
			||||||
 | 
					        mPickerMinute.setWrapSelectorWheel(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 年月变化时更新日范围(Java 7 匿名内部类)
 | 
				
			||||||
 | 
					        mPickerYear.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
				
			||||||
 | 
					                updateDayRange(newVal, mPickerMonth.getValue());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mPickerMonth.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
 | 
				
			||||||
 | 
					                updateDayRange(mPickerYear.getValue(), newVal);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void updateDayRange(int year, int month) {
 | 
				
			||||||
 | 
					        int maxDay;
 | 
				
			||||||
 | 
					        switch (month) {
 | 
				
			||||||
 | 
					            case 2:
 | 
				
			||||||
 | 
					                if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
 | 
				
			||||||
 | 
					                    maxDay = 29;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    maxDay = 28;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case 4:
 | 
				
			||||||
 | 
					            case 6:
 | 
				
			||||||
 | 
					            case 9:
 | 
				
			||||||
 | 
					            case 11:
 | 
				
			||||||
 | 
					                maxDay = 30;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                maxDay = 31;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        mPickerDay.setMaxValue(maxDay);
 | 
				
			||||||
 | 
					        if (mPickerDay.getValue() > maxDay) {
 | 
				
			||||||
 | 
					            mPickerDay.setValue(maxDay);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void bindButtonClick() {
 | 
				
			||||||
 | 
					        // 取消按钮(Java 7 匿名内部类)
 | 
				
			||||||
 | 
					        mBtnCancel.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onClick(View v) {
 | 
				
			||||||
 | 
					                dismiss();
 | 
				
			||||||
 | 
					                if (mListener != null) {
 | 
				
			||||||
 | 
					                    mListener.onCancel();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 确认按钮(Java 7 匿名内部类)
 | 
				
			||||||
 | 
					        mBtnConfirm.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onClick(View v) {
 | 
				
			||||||
 | 
					                int year = mPickerYear.getValue();
 | 
				
			||||||
 | 
					                int month = mPickerMonth.getValue();
 | 
				
			||||||
 | 
					                int day = mPickerDay.getValue();
 | 
				
			||||||
 | 
					                int hour = mPickerHour.getValue();
 | 
				
			||||||
 | 
					                int minute = mPickerMinute.getValue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (mListener != null) {
 | 
				
			||||||
 | 
					                    mListener.onDateTimeSelected(year, month, day, hour, minute);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                dismiss();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void setPopupStyle() {
 | 
				
			||||||
 | 
					        int width = (int) (DensityUtils.getScreenWidth(mContext) * 0.85f);
 | 
				
			||||||
 | 
					        int height = ViewGroup.LayoutParams.WRAP_CONTENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setWidth(width);
 | 
				
			||||||
 | 
					        setHeight(height);
 | 
				
			||||||
 | 
					        setFocusable(true);
 | 
				
			||||||
 | 
					        setOutsideTouchable(true);
 | 
				
			||||||
 | 
					        setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_dialog_round));
 | 
				
			||||||
 | 
					        setAnimationStyle(R.style.PopupDateTimePickerAnim);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void showAsDropDown(View anchorView) {
 | 
				
			||||||
 | 
					        super.showAsDropDown(anchorView, 0, DensityUtils.dp2px(mContext, 10));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -14,7 +14,6 @@ import android.widget.Button;
 | 
				
			|||||||
import android.widget.CompoundButton;
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
import android.widget.EditText;
 | 
					import android.widget.EditText;
 | 
				
			||||||
import android.widget.LinearLayout;
 | 
					import android.widget.LinearLayout;
 | 
				
			||||||
import android.widget.RadioButton;
 | 
					 | 
				
			||||||
import android.widget.RadioGroup;
 | 
					import android.widget.RadioGroup;
 | 
				
			||||||
import android.widget.TextView;
 | 
					import android.widget.TextView;
 | 
				
			||||||
import android.widget.Toast;
 | 
					import android.widget.Toast;
 | 
				
			||||||
@@ -26,8 +25,14 @@ 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;
 | 
				
			||||||
import cc.winboll.studio.positions.services.MainService;
 | 
					import cc.winboll.studio.positions.services.MainService;
 | 
				
			||||||
 | 
					import com.jzxiang.pickerview.TimePickerDialog;
 | 
				
			||||||
 | 
					import com.jzxiang.pickerview.listener.OnDateSetListener;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Calendar;
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Locale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PositionTaskListView extends LinearLayout {
 | 
					public class PositionTaskListView extends LinearLayout {
 | 
				
			||||||
    // 视图模式常量
 | 
					    // 视图模式常量
 | 
				
			||||||
@@ -321,6 +326,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
                // 任务描述
 | 
					                // 任务描述
 | 
				
			||||||
                String taskDesc = task.getTaskDescription() == null ? "未设置描述" : task.getTaskDescription();
 | 
					                String taskDesc = task.getTaskDescription() == null ? "未设置描述" : task.getTaskDescription();
 | 
				
			||||||
                simpleHolder.tvSimpleTaskDesc.setText(String.format("任务:%s", taskDesc));
 | 
					                simpleHolder.tvSimpleTaskDesc.setText(String.format("任务:%s", taskDesc));
 | 
				
			||||||
 | 
									simpleHolder.tvStartTime.setText(genSelectedTimeText(task.getStartTime()));
 | 
				
			||||||
                // 距离条件(大于/小于+距离值)
 | 
					                // 距离条件(大于/小于+距离值)
 | 
				
			||||||
                String distanceCond = task.isGreaterThan() ? "大于" : "小于";
 | 
					                String distanceCond = task.isGreaterThan() ? "大于" : "小于";
 | 
				
			||||||
                simpleHolder.tvSimpleDistanceCond.setText(String.format("条件:距离 %s %d 米", distanceCond, task.getDiscussDistance()));
 | 
					                simpleHolder.tvSimpleDistanceCond.setText(String.format("条件:距离 %s %d 米", distanceCond, task.getDiscussDistance()));
 | 
				
			||||||
@@ -328,10 +334,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
                simpleHolder.tvSimpleIsEnable.setText(task.isEnable() ? "状态:已启用" : "状态:已禁用");
 | 
					                simpleHolder.tvSimpleIsEnable.setText(task.isEnable() ? "状态:已启用" : "状态:已禁用");
 | 
				
			||||||
                // isBingo红点(任务触发时显示,未触发时隐藏)
 | 
					                // isBingo红点(任务触发时显示,未触发时隐藏)
 | 
				
			||||||
                simpleHolder.vBingoDot.setVisibility(task.isBingo() ? View.VISIBLE : View.GONE);
 | 
					                simpleHolder.vBingoDot.setVisibility(task.isBingo() ? View.VISIBLE : View.GONE);
 | 
				
			||||||
            }
 | 
					            } else if (holder instanceof TaskContentViewHolder) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 4. 编辑模式绑定(核心调整:所有修改操作后同步MainService)
 | 
					 | 
				
			||||||
            else if (holder instanceof TaskContentViewHolder) {
 | 
					 | 
				
			||||||
                TaskContentViewHolder contentHolder = (TaskContentViewHolder) holder;
 | 
					                TaskContentViewHolder contentHolder = (TaskContentViewHolder) holder;
 | 
				
			||||||
                bindEditModeTask(contentHolder, task, position);
 | 
					                bindEditModeTask(contentHolder, task, position);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -346,6 +349,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
            holder.tvTaskDesc.setText(String.format("任务:%s", taskDesc));
 | 
					            holder.tvTaskDesc.setText(String.format("任务:%s", taskDesc));
 | 
				
			||||||
            String distanceCond = task.isGreaterThan() ? "大于" : "小于";
 | 
					            String distanceCond = task.isGreaterThan() ? "大于" : "小于";
 | 
				
			||||||
            holder.tvTaskDistance.setText(String.format("条件:%s %d 米", distanceCond, task.getDiscussDistance()));
 | 
					            holder.tvTaskDistance.setText(String.format("条件:%s %d 米", distanceCond, task.getDiscussDistance()));
 | 
				
			||||||
 | 
								holder.tvStartTime.setText(genSelectedTimeText(task.getStartTime()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 4.2 绑定“启用开关”(修复:先解绑监听→设值→再绑定监听,避免设值触发回调)
 | 
					            // 4.2 绑定“启用开关”(修复:先解绑监听→设值→再绑定监听,避免设值触发回调)
 | 
				
			||||||
            holder.cbTaskEnable.setOnCheckedChangeListener(null);
 | 
					            holder.cbTaskEnable.setOnCheckedChangeListener(null);
 | 
				
			||||||
@@ -372,10 +376,11 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
							LogUtils.d(TAG, "调用MainService删除任务:ID=" + task.getTaskId() + "(位置ID=" + mBindPositionId + ")");
 | 
												LogUtils.d(TAG, "调用MainService删除任务:ID=" + task.getTaskId() + "(位置ID=" + mBindPositionId + ")");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							// 步骤2:从Adapter数据源移除任务(避免等待同步,立即反馈UI)
 | 
												// 步骤2:从Adapter数据源移除任务(避免等待同步,立即反馈UI)
 | 
				
			||||||
							mAdapterData.remove(position);
 | 
												//mAdapterData.remove(position);
 | 
				
			||||||
							// 步骤3:刷新Adapter(局部刷新+范围通知,避免列表错乱)
 | 
												// 步骤3:刷新Adapter(局部刷新+范围通知,避免列表错乱)
 | 
				
			||||||
							notifyItemRemoved(position);
 | 
												notifyItemRemoved(position);
 | 
				
			||||||
							notifyItemRangeChanged(position, mAdapterData.size());
 | 
												notifyItemRangeChanged(position, mAdapterData.size());
 | 
				
			||||||
 | 
												
 | 
				
			||||||
							LogUtils.d(TAG, "Adapter已移除任务,刷新列表(位置索引=" + position + ")");
 | 
												LogUtils.d(TAG, "Adapter已移除任务,刷新列表(位置索引=" + position + ")");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							// 步骤4:通知外部(如Activity)任务已更新
 | 
												// 步骤4:通知外部(如Activity)任务已更新
 | 
				
			||||||
@@ -453,11 +458,19 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
				});
 | 
									});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							private String genSelectedTimeText(long timeMillis) {
 | 
				
			||||||
 | 
								// 2. 格式化时间字符串(Java 7 用 SimpleDateFormat,需处理 ParseException)
 | 
				
			||||||
 | 
								SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
 | 
				
			||||||
 | 
								String formattedDateTime = sdf.format(new Date(timeMillis)); // Date 需导入 java.util.Date
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								return formattedDateTime;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * 编辑任务弹窗(核心:保存修改→同步MainService→刷新Adapter)
 | 
					         * 编辑任务弹窗(核心:保存修改→同步MainService→刷新Adapter)
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        private void showEditTaskDialog(final PositionTaskModel task, final int position) {
 | 
					        private void showEditTaskDialog(final PositionTaskModel task, final int position) {
 | 
				
			||||||
            Context context = getContext();
 | 
					            final Context context = getContext();
 | 
				
			||||||
            if (context == null) {
 | 
					            if (context == null) {
 | 
				
			||||||
                LogUtils.w(TAG, "编辑弹窗无法显示:上下文为空");
 | 
					                LogUtils.w(TAG, "编辑弹窗无法显示:上下文为空");
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
@@ -468,9 +481,72 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
            final EditText etEditDesc = dialogView.findViewById(R.id.et_edit_task_desc);
 | 
					            final EditText etEditDesc = dialogView.findViewById(R.id.et_edit_task_desc);
 | 
				
			||||||
            final RadioGroup rgDistanceCondition = dialogView.findViewById(R.id.rg_distance_condition);
 | 
					            final RadioGroup rgDistanceCondition = dialogView.findViewById(R.id.rg_distance_condition);
 | 
				
			||||||
            final EditText etEditDistance = dialogView.findViewById(R.id.et_edit_distance);
 | 
					            final EditText etEditDistance = dialogView.findViewById(R.id.et_edit_distance);
 | 
				
			||||||
            Button btnCancel = dialogView.findViewById(R.id.btn_dialog_cancel);
 | 
								Button btnCancel = dialogView.findViewById(R.id.btn_dialog_cancel);
 | 
				
			||||||
            Button btnSave = dialogView.findViewById(R.id.btn_dialog_save);
 | 
					            Button btnSave = dialogView.findViewById(R.id.btn_dialog_save);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 绑定外层对话框内的控件
 | 
				
			||||||
 | 
								final Button btnSelectTime = (Button) dialogView.findViewById(R.id.btn_select_time);
 | 
				
			||||||
 | 
								final TextView tv_SelectedTime = (TextView) dialogView.findViewById(R.id.tv_selected_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								tv_SelectedTime.setText(genSelectedTimeText(task.getStartTime()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 核心:从 long 时间戳解析年月日时分,用于初始化弹窗
 | 
				
			||||||
 | 
								// --------------------------
 | 
				
			||||||
 | 
								Calendar initCalendar = Calendar.getInstance();
 | 
				
			||||||
 | 
								initCalendar.setTimeInMillis(task.getStartTime()); // 将 long 时间戳传入 Calendar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 从 Calendar 中解析出年月日时分(对应弹窗需要的参数格式)
 | 
				
			||||||
 | 
								int initYear = initCalendar.get(Calendar.YEAR);
 | 
				
			||||||
 | 
								int initMonth = initCalendar.get(Calendar.MONTH) + 1; // 关键:Calendar 月份0-11,转成1-12
 | 
				
			||||||
 | 
								int initDay = initCalendar.get(Calendar.DAY_OF_MONTH);
 | 
				
			||||||
 | 
								int initHour = initCalendar.get(Calendar.HOUR_OF_DAY); // 24小时制
 | 
				
			||||||
 | 
								int initMinute = initCalendar.get(Calendar.MINUTE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 初始化弹窗,用解析出的年月日时分设置默认选中时间
 | 
				
			||||||
 | 
								final DateTimePickerPopup dateTimePopup = new DateTimePickerPopup.Builder(context)
 | 
				
			||||||
 | 
									.setDateTimeRange(2020, 2030, 1, 12, 1, 31, 0, 23, 0, 59)
 | 
				
			||||||
 | 
									// 用 long 时间戳解析出的参数设置初始时间
 | 
				
			||||||
 | 
									.setDefaultDateTime(initYear, initMonth, initDay, initHour, initMinute)
 | 
				
			||||||
 | 
									.setOnDateTimeSelectedListener(new DateTimePickerPopup.OnDateTimeSelectedListener() {
 | 
				
			||||||
 | 
										@Override
 | 
				
			||||||
 | 
										public void onDateTimeSelected(int year, int month, int day, int hour, int minute) {
 | 
				
			||||||
 | 
											// 处理选择的日期时间
 | 
				
			||||||
 | 
											// 1. 创建 Calendar 实例(用于组装日期时间)
 | 
				
			||||||
 | 
											Calendar calendar = Calendar.getInstance();
 | 
				
			||||||
 | 
											// 2. 设置 Calendar 的年、月、日、时、分(注意:Calendar 月份从 0 开始,需减 1)
 | 
				
			||||||
 | 
											calendar.set(Calendar.YEAR, year);
 | 
				
			||||||
 | 
											calendar.set(Calendar.MONTH, month - 1); // 关键:传入的 month 是 1-12,需转为 0-11
 | 
				
			||||||
 | 
											calendar.set(Calendar.DAY_OF_MONTH, day);
 | 
				
			||||||
 | 
											calendar.set(Calendar.HOUR_OF_DAY, hour); // 24小时制,对应参数中的 hour(0-23)
 | 
				
			||||||
 | 
											calendar.set(Calendar.MINUTE, minute);
 | 
				
			||||||
 | 
											calendar.set(Calendar.SECOND, 0); // 秒默认设为 0,避免随机值
 | 
				
			||||||
 | 
											calendar.set(Calendar.MILLISECOND, 0); // 毫秒默认设为 0,确保时间戳精确
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											// 3. 转为 long 类型时间戳(单位:毫秒,从 1970-01-01 00:00:00 开始计算)
 | 
				
			||||||
 | 
											long timeMillis = calendar.getTimeInMillis();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											// 4. 后续使用(示例:打印时间戳或传递给其他逻辑)
 | 
				
			||||||
 | 
											tv_SelectedTime.setText(genSelectedTimeText(timeMillis));
 | 
				
			||||||
 | 
											task.setStartTime(timeMillis);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										@Override
 | 
				
			||||||
 | 
										public void onCancel() {
 | 
				
			||||||
 | 
											// 处理取消操作
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
									.build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 3. “选择时间”按钮点击事件(弹出 TimePickerPopup)
 | 
				
			||||||
 | 
								btnSelectTime.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
										@Override
 | 
				
			||||||
 | 
										public void onClick(final View v) {
 | 
				
			||||||
 | 
											dateTimePopup.showAsDropDown(btnSelectTime);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 初始化弹窗数据(填充当前任务信息)
 | 
					            // 初始化弹窗数据(填充当前任务信息)
 | 
				
			||||||
            etEditDesc.setText(task.getTaskDescription() == null ? "" : task.getTaskDescription());
 | 
					            etEditDesc.setText(task.getTaskDescription() == null ? "" : task.getTaskDescription());
 | 
				
			||||||
            etEditDesc.setSelection(etEditDesc.getText().length()); // 光标定位到末尾
 | 
					            etEditDesc.setSelection(etEditDesc.getText().length()); // 光标定位到末尾
 | 
				
			||||||
@@ -489,6 +565,14 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
				.create();
 | 
									.create();
 | 
				
			||||||
            dialog.show();
 | 
					            dialog.show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								final OnDateSetListener onSateSetListener = new OnDateSetListener(){
 | 
				
			||||||
 | 
									@Override
 | 
				
			||||||
 | 
									public void onDateSet(TimePickerDialog timePickerDialog, long p) {
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 取消按钮:关闭弹窗(不做操作)
 | 
					            // 取消按钮:关闭弹窗(不做操作)
 | 
				
			||||||
            btnCancel.setOnClickListener(new View.OnClickListener() {
 | 
					            btnCancel.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
					@Override
 | 
										@Override
 | 
				
			||||||
@@ -583,6 +667,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
        public class SimpleTaskViewHolder extends TaskViewHolder {
 | 
					        public class SimpleTaskViewHolder extends TaskViewHolder {
 | 
				
			||||||
            TextView tvSimpleTaskDesc;    // 任务描述
 | 
					            TextView tvSimpleTaskDesc;    // 任务描述
 | 
				
			||||||
            TextView tvSimpleDistanceCond;// 距离条件(大于/小于+距离)
 | 
					            TextView tvSimpleDistanceCond;// 距离条件(大于/小于+距离)
 | 
				
			||||||
 | 
								TextView tvStartTime;
 | 
				
			||||||
            TextView tvSimpleIsEnable;    // 启用状态(已启用/已禁用)
 | 
					            TextView tvSimpleIsEnable;    // 启用状态(已启用/已禁用)
 | 
				
			||||||
            View vBingoDot;               // isBingo红点(任务触发时显示)
 | 
					            View vBingoDot;               // isBingo红点(任务触发时显示)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -591,6 +676,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
                // 绑定简单模式布局控件(与XML控件ID严格对应)
 | 
					                // 绑定简单模式布局控件(与XML控件ID严格对应)
 | 
				
			||||||
                tvSimpleTaskDesc = itemView.findViewById(R.id.tv_simple_task_desc);
 | 
					                tvSimpleTaskDesc = itemView.findViewById(R.id.tv_simple_task_desc);
 | 
				
			||||||
                tvSimpleDistanceCond = itemView.findViewById(R.id.tv_simple_distance_cond);
 | 
					                tvSimpleDistanceCond = itemView.findViewById(R.id.tv_simple_distance_cond);
 | 
				
			||||||
 | 
									tvStartTime = itemView.findViewById(R.id.tv_starttime);
 | 
				
			||||||
                tvSimpleIsEnable = itemView.findViewById(R.id.tv_simple_is_enable);
 | 
					                tvSimpleIsEnable = itemView.findViewById(R.id.tv_simple_is_enable);
 | 
				
			||||||
                vBingoDot = itemView.findViewById(R.id.v_bingo_dot);
 | 
					                vBingoDot = itemView.findViewById(R.id.v_bingo_dot);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -600,6 +686,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
        public class TaskContentViewHolder extends TaskViewHolder {
 | 
					        public class TaskContentViewHolder extends TaskViewHolder {
 | 
				
			||||||
            TextView tvTaskDesc;         // 任务描述
 | 
					            TextView tvTaskDesc;         // 任务描述
 | 
				
			||||||
            TextView tvTaskDistance;     // 距离条件
 | 
					            TextView tvTaskDistance;     // 距离条件
 | 
				
			||||||
 | 
								TextView tvStartTime;
 | 
				
			||||||
            CompoundButton cbTaskEnable; // 启用开关
 | 
					            CompoundButton cbTaskEnable; // 启用开关
 | 
				
			||||||
            Button btnEditTask;          // 编辑按钮
 | 
					            Button btnEditTask;          // 编辑按钮
 | 
				
			||||||
            Button btnDeleteTask;        // 删除按钮
 | 
					            Button btnDeleteTask;        // 删除按钮
 | 
				
			||||||
@@ -609,6 +696,7 @@ public class PositionTaskListView extends LinearLayout {
 | 
				
			|||||||
                // 绑定编辑模式布局控件(与XML控件ID严格对应)
 | 
					                // 绑定编辑模式布局控件(与XML控件ID严格对应)
 | 
				
			||||||
                tvTaskDesc = itemView.findViewById(R.id.tv_task_desc);
 | 
					                tvTaskDesc = itemView.findViewById(R.id.tv_task_desc);
 | 
				
			||||||
                tvTaskDistance = itemView.findViewById(R.id.tv_task_distance);
 | 
					                tvTaskDistance = itemView.findViewById(R.id.tv_task_distance);
 | 
				
			||||||
 | 
									tvStartTime = itemView.findViewById(R.id.tv_starttime);
 | 
				
			||||||
                cbTaskEnable = itemView.findViewById(R.id.cb_task_enable);
 | 
					                cbTaskEnable = itemView.findViewById(R.id.cb_task_enable);
 | 
				
			||||||
                btnEditTask = itemView.findViewById(R.id.btn_edit_task);
 | 
					                btnEditTask = itemView.findViewById(R.id.btn_edit_task);
 | 
				
			||||||
                btnDeleteTask = itemView.findViewById(R.id.btn_delete_task);
 | 
					                btnDeleteTask = itemView.findViewById(R.id.btn_delete_task);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								positions/src/main/res/anim/popup_date_time_picker_in.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								positions/src/main/res/anim/popup_date_time_picker_in.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<set xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					    android:duration="300">
 | 
				
			||||||
 | 
					    <translate
 | 
				
			||||||
 | 
					        android:fromYDelta="50%"
 | 
				
			||||||
 | 
					        android:toYDelta="0%"
 | 
				
			||||||
 | 
					        android:interpolator="@android:anim/decelerate_interpolator" />
 | 
				
			||||||
 | 
					    <alpha
 | 
				
			||||||
 | 
					        android:fromAlpha="0.6"
 | 
				
			||||||
 | 
					        android:toAlpha="1.0"
 | 
				
			||||||
 | 
					        android:interpolator="@android:anim/decelerate_interpolator" />
 | 
				
			||||||
 | 
					</set>
 | 
				
			||||||
							
								
								
									
										12
									
								
								positions/src/main/res/anim/popup_date_time_picker_out.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								positions/src/main/res/anim/popup_date_time_picker_out.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<set xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					    android:duration="250">
 | 
				
			||||||
 | 
					    <translate
 | 
				
			||||||
 | 
					        android:fromYDelta="0%"
 | 
				
			||||||
 | 
					        android:toYDelta="50%"
 | 
				
			||||||
 | 
					        android:interpolator="@android:anim/accelerate_interpolator" />
 | 
				
			||||||
 | 
					    <alpha
 | 
				
			||||||
 | 
					        android:fromAlpha="1.0"
 | 
				
			||||||
 | 
					        android:toAlpha="0.6"
 | 
				
			||||||
 | 
					        android:interpolator="@android:anim/accelerate_interpolator" />
 | 
				
			||||||
 | 
					</set>
 | 
				
			||||||
							
								
								
									
										13
									
								
								positions/src/main/res/drawable/bg_dialog_round.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								positions/src/main/res/drawable/bg_dialog_round.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<shape xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					    android:shape="rectangle">
 | 
				
			||||||
 | 
					    <!-- 白色背景 -->
 | 
				
			||||||
 | 
					    <solid android:color="#FFFFFF" />
 | 
				
			||||||
 | 
					    <!-- 圆角(12dp,可根据需求调整) -->
 | 
				
			||||||
 | 
					    <corners android:radius="12dp" />
 | 
				
			||||||
 | 
					    <!-- 轻微阴影(增强层次感) -->
 | 
				
			||||||
 | 
					    <stroke
 | 
				
			||||||
 | 
					        android:width="1dp"
 | 
				
			||||||
 | 
					        android:color="#00000008" /> <!-- 透明黑色阴影,避免生硬 -->
 | 
				
			||||||
 | 
					</shape>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								positions/src/main/res/drawable/btn_dialog_cancel.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								positions/src/main/res/drawable/btn_dialog_cancel.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<shape xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					    android:shape="rectangle">
 | 
				
			||||||
 | 
					    <!-- 透明背景 -->
 | 
				
			||||||
 | 
					    <solid android:color="#00000000" />
 | 
				
			||||||
 | 
					    <!-- 灰色边框(与取消按钮文字同色) -->
 | 
				
			||||||
 | 
					    <stroke
 | 
				
			||||||
 | 
					        android:width="1dp"
 | 
				
			||||||
 | 
					        android:color="#FF333333" />
 | 
				
			||||||
 | 
					    <!-- 圆角(与弹窗一致,12dp) -->
 | 
				
			||||||
 | 
					    <corners android:radius="12dp" />
 | 
				
			||||||
 | 
					</shape>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								positions/src/main/res/drawable/btn_dialog_confirm.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								positions/src/main/res/drawable/btn_dialog_confirm.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<shape xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					    android:shape="rectangle">
 | 
				
			||||||
 | 
					    <!-- 填充色(示例深灰色,可改为 #FF007AFF 等主题色) -->
 | 
				
			||||||
 | 
					    <solid android:color="#FF333333" />
 | 
				
			||||||
 | 
					    <!-- 圆角(与弹窗一致) -->
 | 
				
			||||||
 | 
					    <corners android:radius="12dp" />
 | 
				
			||||||
 | 
					</shape>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										74
									
								
								positions/src/main/res/layout/dialog_date_time_picker.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								positions/src/main/res/layout/dialog_date_time_picker.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,74 @@
 | 
				
			|||||||
 | 
					<?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="16dp"
 | 
				
			||||||
 | 
					    android:background="@drawable/bg_dialog_round">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <LinearLayout
 | 
				
			||||||
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
 | 
					        android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					        android:orientation="horizontal"
 | 
				
			||||||
 | 
					        android:gravity="center">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <NumberPicker
 | 
				
			||||||
 | 
					            android:id="@+id/picker_year"
 | 
				
			||||||
 | 
					            android:layout_width="0dp"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_weight="1" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <NumberPicker
 | 
				
			||||||
 | 
					            android:id="@+id/picker_month"
 | 
				
			||||||
 | 
					            android:layout_width="0dp"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_weight="1" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <NumberPicker
 | 
				
			||||||
 | 
					            android:id="@+id/picker_day"
 | 
				
			||||||
 | 
					            android:layout_width="0dp"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_weight="1" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <NumberPicker
 | 
				
			||||||
 | 
					            android:id="@+id/picker_hour"
 | 
				
			||||||
 | 
					            android:layout_width="0dp"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_weight="1" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <NumberPicker
 | 
				
			||||||
 | 
					            android:id="@+id/picker_minute"
 | 
				
			||||||
 | 
					            android:layout_width="0dp"
 | 
				
			||||||
 | 
					            android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_weight="1" />
 | 
				
			||||||
 | 
					    </LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <LinearLayout
 | 
				
			||||||
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
 | 
					        android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					        android:orientation="horizontal"
 | 
				
			||||||
 | 
					        android:gravity="end"
 | 
				
			||||||
 | 
					        android:layout_marginTop="16dp"
 | 
				
			||||||
 | 
					        android:spacing="12dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <Button
 | 
				
			||||||
 | 
					            android:id="@+id/btn_cancel"
 | 
				
			||||||
 | 
					            android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_height="42dp"
 | 
				
			||||||
 | 
					            android:minWidth="80dp"
 | 
				
			||||||
 | 
					            android:background="@drawable/btn_dialog_cancel"
 | 
				
			||||||
 | 
					            android:text="取消"
 | 
				
			||||||
 | 
					            android:textSize="16sp" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <Button
 | 
				
			||||||
 | 
					            android:id="@+id/btn_confirm"
 | 
				
			||||||
 | 
					            android:layout_width="wrap_content"
 | 
				
			||||||
 | 
					            android:layout_height="42dp"
 | 
				
			||||||
 | 
					            android:minWidth="80dp"
 | 
				
			||||||
 | 
					            android:background="@drawable/btn_dialog_confirm"
 | 
				
			||||||
 | 
					            android:text="确认"
 | 
				
			||||||
 | 
					            android:textSize="16sp"
 | 
				
			||||||
 | 
					            android:textColor="@android:color/white" />
 | 
				
			||||||
 | 
					    </LinearLayout>
 | 
				
			||||||
 | 
					</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,82 +1,120 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					<LinearLayout
 | 
				
			||||||
    android:layout_width="match_parent"
 | 
						xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
						android:layout_width="match_parent"
 | 
				
			||||||
    android:orientation="vertical"
 | 
						android:layout_height="wrap_content"
 | 
				
			||||||
    android:padding="16dp"
 | 
						android:orientation="vertical"
 | 
				
			||||||
    android:background="@color/white">
 | 
						android:padding="16dp"
 | 
				
			||||||
 | 
						android:background="@color/white">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <EditText
 | 
						<EditText
 | 
				
			||||||
        android:id="@+id/et_edit_task_desc"
 | 
							android:id="@+id/et_edit_task_desc"
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:hint="输入任务描述"
 | 
							android:hint="输入任务描述"
 | 
				
			||||||
        android:maxLines="1"
 | 
							android:maxLines="1"
 | 
				
			||||||
        android:textSize="14sp" />
 | 
							android:textSize="14sp"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <RadioGroup
 | 
						<LinearLayout
 | 
				
			||||||
        android:id="@+id/rg_distance_condition"
 | 
							android:orientation="horizontal"
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:orientation="horizontal"
 | 
							android:layout_marginTop="12dp"
 | 
				
			||||||
        android:layout_marginTop="12dp">
 | 
							android:gravity="center_vertical">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <RadioButton
 | 
							<RadioGroup
 | 
				
			||||||
            android:id="@+id/rb_greater_than"
 | 
								android:id="@+id/rg_distance_condition"
 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
            android:layout_height="wrap_content"
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
            android:text="大于"
 | 
								android:orientation="horizontal"
 | 
				
			||||||
            android:textColor="@color/black"
 | 
								android:layout_marginRight="10dp">
 | 
				
			||||||
            android:textSize="14sp" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <RadioButton
 | 
								<RadioButton
 | 
				
			||||||
            android:id="@+id/rb_less_than"
 | 
									android:id="@+id/rb_greater_than"
 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
            android:layout_height="wrap_content"
 | 
									android:layout_height="wrap_content"
 | 
				
			||||||
            android:text="小于"
 | 
									android:text="大于"
 | 
				
			||||||
            android:textColor="@color/black"
 | 
									android:textColor="@color/black"
 | 
				
			||||||
            android:textSize="14sp"
 | 
									android:textSize="14sp"/>
 | 
				
			||||||
            android:layout_marginLeft="24dp" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </RadioGroup>
 | 
								<RadioButton
 | 
				
			||||||
 | 
									android:id="@+id/rb_less_than"
 | 
				
			||||||
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
 | 
									android:layout_height="wrap_content"
 | 
				
			||||||
 | 
									android:text="小于"
 | 
				
			||||||
 | 
									android:textColor="@color/black"
 | 
				
			||||||
 | 
									android:textSize="14sp"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <EditText
 | 
							</RadioGroup>
 | 
				
			||||||
        android:id="@+id/et_edit_distance"
 | 
					 | 
				
			||||||
        android:layout_width="match_parent"
 | 
					 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
					 | 
				
			||||||
        android:hint="输入距离(米)"
 | 
					 | 
				
			||||||
        android:inputType="number"
 | 
					 | 
				
			||||||
        android:maxLines="1"
 | 
					 | 
				
			||||||
        android:textSize="14sp"
 | 
					 | 
				
			||||||
        android:layout_marginTop="8dp" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <LinearLayout
 | 
							<EditText
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
								android:id="@+id/et_edit_distance"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
								android:layout_width="0dp"
 | 
				
			||||||
        android:orientation="horizontal"
 | 
								android:layout_weight="1.0"
 | 
				
			||||||
        android:gravity="end"
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
        android:layout_marginTop="16dp">
 | 
								android:hint="输入距离(米)"
 | 
				
			||||||
 | 
								android:inputType="number"
 | 
				
			||||||
 | 
								android:maxLines="1"
 | 
				
			||||||
 | 
								android:textSize="14sp"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <Button
 | 
							<TextView
 | 
				
			||||||
            android:id="@+id/btn_dialog_cancel"
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
            android:layout_height="40dp"
 | 
								android:text="米"
 | 
				
			||||||
            android:text="取消"
 | 
								android:layout_marginRight="10dp"/>
 | 
				
			||||||
            android:textColor="@color/black"
 | 
					 | 
				
			||||||
            android:textSize="14sp"
 | 
					 | 
				
			||||||
            android:layout_marginRight="8dp"
 | 
					 | 
				
			||||||
            android:background="@color/gray" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <Button
 | 
						</LinearLayout>
 | 
				
			||||||
            android:id="@+id/btn_dialog_save"
 | 
					 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
					 | 
				
			||||||
            android:layout_height="40dp"
 | 
					 | 
				
			||||||
            android:text="保存"
 | 
					 | 
				
			||||||
            android:textSize="14sp"
 | 
					 | 
				
			||||||
            android:background="@color/blue"
 | 
					 | 
				
			||||||
            android:textColor="@color/white" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </LinearLayout>
 | 
						<LinearLayout
 | 
				
			||||||
 | 
							android:orientation="horizontal"
 | 
				
			||||||
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
 | 
							android:layout_marginTop="12dp"
 | 
				
			||||||
 | 
							android:gravity="center_vertical">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<Button
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
 | 
								android:text="开始时间"
 | 
				
			||||||
 | 
								android:id="@+id/btn_select_time"/>
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<TextView
 | 
				
			||||||
 | 
								android:id="@+id/tv_selected_time"
 | 
				
			||||||
 | 
								android:layout_width="0dp"
 | 
				
			||||||
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
 | 
								android:text="Text"
 | 
				
			||||||
 | 
								android:layout_weight="1.0"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<LinearLayout
 | 
				
			||||||
 | 
							android:layout_width="match_parent"
 | 
				
			||||||
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
 | 
							android:orientation="horizontal"
 | 
				
			||||||
 | 
							android:gravity="end"
 | 
				
			||||||
 | 
							android:layout_marginTop="16dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<Button
 | 
				
			||||||
 | 
								android:id="@+id/btn_dialog_cancel"
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="40dp"
 | 
				
			||||||
 | 
								android:text="取消"
 | 
				
			||||||
 | 
								android:textColor="@color/black"
 | 
				
			||||||
 | 
								android:textSize="14sp"
 | 
				
			||||||
 | 
								android:layout_marginRight="8dp"
 | 
				
			||||||
 | 
								android:background="@color/gray"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<Button
 | 
				
			||||||
 | 
								android:id="@+id/btn_dialog_save"
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="40dp"
 | 
				
			||||||
 | 
								android:text="保存"
 | 
				
			||||||
 | 
								android:textSize="14sp"
 | 
				
			||||||
 | 
								android:background="@color/blue"
 | 
				
			||||||
 | 
								android:textColor="@color/white"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</LinearLayout>
 | 
					</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,56 +1,77 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<!-- 根布局改为 RelativeLayout,支持红点右上角定位(原 LinearLayout 无法便捷实现绝对位置) -->
 | 
					 | 
				
			||||||
<RelativeLayout
 | 
					<RelativeLayout
 | 
				
			||||||
    xmlns:android="http://schemas.android.com/apk/res/android"
 | 
						xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
    android:layout_width="match_parent"
 | 
						android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
						android:layout_height="wrap_content"
 | 
				
			||||||
    android:orientation="vertical"
 | 
						android:orientation="vertical"
 | 
				
			||||||
    android:padding="12dp"
 | 
						android:padding="12dp"
 | 
				
			||||||
    android:background="@drawable/item_bg_simple"
 | 
						android:background="@drawable/item_bg_simple"
 | 
				
			||||||
    android:layout_marginBottom="8dp">
 | 
						android:layout_marginBottom="8dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- 1. 右上角小红点(仅 isBingo=true 时显示,绑定 isBingo 属性) -->
 | 
						<View
 | 
				
			||||||
    <View
 | 
							android:id="@+id/v_bingo_dot"
 | 
				
			||||||
        android:id="@+id/v_bingo_dot"
 | 
							android:layout_width="12dp"
 | 
				
			||||||
        android:layout_width="12dp"
 | 
							android:layout_height="12dp"
 | 
				
			||||||
        android:layout_height="12dp"
 | 
							android:layout_alignParentRight="true"
 | 
				
			||||||
        android:layout_alignParentRight="true"
 | 
							android:layout_alignParentTop="true"
 | 
				
			||||||
        android:layout_alignParentTop="true"
 | 
							android:layout_marginRight="2dp"
 | 
				
			||||||
        android:layout_marginRight="2dp"
 | 
							android:layout_marginTop="2dp"
 | 
				
			||||||
        android:layout_marginTop="2dp"
 | 
							android:background="@drawable/bg_bingo_dot"
 | 
				
			||||||
        android:background="@drawable/bg_bingo_dot"
 | 
							android:visibility="gone"/>
 | 
				
			||||||
        android:visibility="gone"/>  <!-- 默认隐藏,仅任务触发(isBingo=true)时显示 -->
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- 2. 任务描述(原控件不变,位置受红点不影响) -->
 | 
						<TextView
 | 
				
			||||||
    <TextView
 | 
							android:id="@+id/tv_simple_task_desc"
 | 
				
			||||||
        android:id="@+id/tv_simple_task_desc"
 | 
							android:layout_width="wrap_content"
 | 
				
			||||||
        android:layout_width="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:textSize="16sp"
 | 
				
			||||||
        android:textSize="16sp"
 | 
							android:textColor="#333333"
 | 
				
			||||||
        android:textColor="#333333"
 | 
							android:text="任务:无描述"/>
 | 
				
			||||||
        android:text="任务:无描述"/>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- 3. 距离条件(原控件不变) -->
 | 
						<TextView
 | 
				
			||||||
    <TextView
 | 
							android:id="@+id/tv_simple_distance_cond"
 | 
				
			||||||
        android:id="@+id/tv_simple_distance_cond"
 | 
							android:layout_width="wrap_content"
 | 
				
			||||||
        android:layout_width="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:textSize="14sp"
 | 
				
			||||||
        android:textSize="14sp"
 | 
							android:textColor="#666666"
 | 
				
			||||||
        android:textColor="#666666"
 | 
							android:layout_marginTop="6dp"
 | 
				
			||||||
        android:layout_marginTop="6dp"
 | 
							android:layout_below="@id/tv_simple_task_desc"
 | 
				
			||||||
        android:layout_below="@id/tv_simple_task_desc"
 | 
							android:text="条件:距离 > 0 米"/>
 | 
				
			||||||
        android:text="条件:距离 > 0 米"/>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- 4. 启用状态(原控件不变) -->
 | 
						<LinearLayout
 | 
				
			||||||
    <TextView
 | 
							android:orientation="horizontal"
 | 
				
			||||||
        android:id="@+id/tv_simple_is_enable"
 | 
							android:layout_marginTop="6dp"
 | 
				
			||||||
        android:layout_width="wrap_content"
 | 
							android:layout_width="wrap_content"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:textSize="14sp"
 | 
							android:layout_below="@id/tv_simple_distance_cond"
 | 
				
			||||||
        android:textColor="#2E8B57"
 | 
							android:id="@+id/ll_starttime"
 | 
				
			||||||
        android:layout_marginTop="4dp"
 | 
							android:gravity="center_vertical">
 | 
				
			||||||
        android:layout_below="@id/tv_simple_distance_cond"
 | 
					
 | 
				
			||||||
        android:text="状态:已启用"/>
 | 
							<TextView
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
 | 
								android:textSize="14sp"
 | 
				
			||||||
 | 
								android:textColor="#666666"
 | 
				
			||||||
 | 
								android:text="开始时间:"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<TextView
 | 
				
			||||||
 | 
								android:id="@+id/tv_starttime"
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
 | 
								android:textSize="14sp"
 | 
				
			||||||
 | 
								android:textColor="#666666"
 | 
				
			||||||
 | 
								android:text=""/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<TextView
 | 
				
			||||||
 | 
							android:id="@+id/tv_simple_is_enable"
 | 
				
			||||||
 | 
							android:layout_width="wrap_content"
 | 
				
			||||||
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
 | 
							android:textSize="14sp"
 | 
				
			||||||
 | 
							android:textColor="#2E8B57"
 | 
				
			||||||
 | 
							android:layout_marginTop="4dp"
 | 
				
			||||||
 | 
							android:layout_below="@id/ll_starttime"
 | 
				
			||||||
 | 
							android:text="状态:已启用"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</RelativeLayout>
 | 
					</RelativeLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,70 +1,110 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					<LinearLayout
 | 
				
			||||||
    android:layout_width="match_parent"
 | 
						xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
						android:layout_width="match_parent"
 | 
				
			||||||
    android:orientation="horizontal"
 | 
						android:layout_height="wrap_content"
 | 
				
			||||||
    android:gravity="center_vertical"
 | 
						android:orientation="horizontal"
 | 
				
			||||||
    android:padding="8dp"
 | 
						android:gravity="center_vertical"
 | 
				
			||||||
    android:background="@drawable/bg_task_item"
 | 
						android:padding="8dp"
 | 
				
			||||||
    android:layout_marginVertical="4dp">
 | 
						android:background="@drawable/bg_task_item"
 | 
				
			||||||
 | 
						android:layout_marginVertical="4dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <CheckBox
 | 
						<CheckBox
 | 
				
			||||||
        android:id="@+id/cb_task_enable"
 | 
							android:id="@+id/cb_task_enable"
 | 
				
			||||||
        android:layout_width="wrap_content"
 | 
							android:layout_width="wrap_content"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:layout_marginRight="12dp" />
 | 
							android:layout_marginRight="12dp"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <LinearLayout
 | 
						<LinearLayout
 | 
				
			||||||
        android:layout_width="0dp"
 | 
							android:orientation="vertical"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
							android:layout_width="0dp"
 | 
				
			||||||
        android:layout_weight="1"
 | 
							android:layout_height="wrap_content"
 | 
				
			||||||
        android:orientation="vertical">
 | 
							android:layout_weight="1.0">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <TextView
 | 
							<LinearLayout
 | 
				
			||||||
            android:id="@+id/tv_task_desc"
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
            android:layout_height="wrap_content"
 | 
								android:orientation="horizontal">
 | 
				
			||||||
            android:text="任务描述"
 | 
					 | 
				
			||||||
            android:textSize="16sp"
 | 
					 | 
				
			||||||
            android:textColor="@color/black" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <TextView
 | 
								<TextView
 | 
				
			||||||
            android:id="@+id/tv_task_distance"
 | 
									android:id="@+id/tv_task_desc"
 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
            android:layout_height="wrap_content"
 | 
									android:layout_height="wrap_content"
 | 
				
			||||||
            android:text="条件:大于 100 米"
 | 
									android:text="任务描述"
 | 
				
			||||||
            android:textSize="12sp"
 | 
									android:textSize="16sp"
 | 
				
			||||||
            android:textColor="@color/gray_dark"
 | 
									android:textColor="@color/black"/>
 | 
				
			||||||
            android:layout_marginTop="2dp" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </LinearLayout>
 | 
							</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <LinearLayout
 | 
							<LinearLayout
 | 
				
			||||||
        android:layout_width="wrap_content"
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
        android:layout_height="wrap_content"
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
        android:orientation="horizontal"
 | 
								android:orientation="horizontal">
 | 
				
			||||||
        android:layout_marginLeft="8dp">
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <Button
 | 
								<TextView
 | 
				
			||||||
            android:id="@+id/btn_edit_task"
 | 
									android:id="@+id/tv_task_distance"
 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
            android:layout_height="30dp"
 | 
									android:layout_height="wrap_content"
 | 
				
			||||||
            android:text="修改"
 | 
									android:text="条件:大于 100 米"
 | 
				
			||||||
            android:textSize="12sp"
 | 
									android:textSize="12sp"
 | 
				
			||||||
            android:layout_marginRight="4dp"
 | 
									android:textColor="@color/gray_dark"
 | 
				
			||||||
            android:background="@color/blue"
 | 
									android:layout_marginTop="2dp"/>
 | 
				
			||||||
            android:textColor="@color/white" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <Button
 | 
							</LinearLayout>
 | 
				
			||||||
            android:id="@+id/btn_delete_task"
 | 
					 | 
				
			||||||
            android:layout_width="wrap_content"
 | 
					 | 
				
			||||||
            android:layout_height="30dp"
 | 
					 | 
				
			||||||
            android:text="删除"
 | 
					 | 
				
			||||||
            android:textSize="12sp"
 | 
					 | 
				
			||||||
            android:background="@color/red"
 | 
					 | 
				
			||||||
            android:textColor="@color/white" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    </LinearLayout>
 | 
							<LinearLayout
 | 
				
			||||||
 | 
								android:orientation="horizontal"
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
 | 
								android:layout_below="@id/tv_simple_distance_cond"
 | 
				
			||||||
 | 
								android:id="@+id/ll_starttime"
 | 
				
			||||||
 | 
								android:gravity="center_vertical">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<TextView
 | 
				
			||||||
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
 | 
									android:layout_height="wrap_content"
 | 
				
			||||||
 | 
									android:textSize="12sp"
 | 
				
			||||||
 | 
									android:textColor="#666666"
 | 
				
			||||||
 | 
									android:text="开始时间:"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<TextView
 | 
				
			||||||
 | 
									android:id="@+id/tv_starttime"
 | 
				
			||||||
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
 | 
									android:layout_height="wrap_content"
 | 
				
			||||||
 | 
									android:textSize="12sp"
 | 
				
			||||||
 | 
									android:textColor="#666666"
 | 
				
			||||||
 | 
									android:text=""/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<LinearLayout
 | 
				
			||||||
 | 
								android:layout_width="wrap_content"
 | 
				
			||||||
 | 
								android:layout_height="wrap_content"
 | 
				
			||||||
 | 
								android:orientation="horizontal"
 | 
				
			||||||
 | 
								android:layout_gravity="center">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<Button
 | 
				
			||||||
 | 
									android:id="@+id/btn_edit_task"
 | 
				
			||||||
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
 | 
									android:layout_height="30dp"
 | 
				
			||||||
 | 
									android:text="修改"
 | 
				
			||||||
 | 
									android:textSize="12sp"
 | 
				
			||||||
 | 
									android:layout_marginRight="4dp"
 | 
				
			||||||
 | 
									android:background="@color/blue"
 | 
				
			||||||
 | 
									android:textColor="@color/white"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								<Button
 | 
				
			||||||
 | 
									android:id="@+id/btn_delete_task"
 | 
				
			||||||
 | 
									android:layout_width="wrap_content"
 | 
				
			||||||
 | 
									android:layout_height="30dp"
 | 
				
			||||||
 | 
									android:text="删除"
 | 
				
			||||||
 | 
									android:textSize="12sp"
 | 
				
			||||||
 | 
									android:background="@color/red"
 | 
				
			||||||
 | 
									android:textColor="@color/white"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</LinearLayout>
 | 
					</LinearLayout>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,5 +29,11 @@
 | 
				
			|||||||
	<!-- 扩展颜色(避免后续新增功能时再次缺失) -->
 | 
						<!-- 扩展颜色(避免后续新增功能时再次缺失) -->
 | 
				
			||||||
	<color name="green">#4CAF50</color> <!-- 绿色(备用:如“启用”状态标识) -->
 | 
						<color name="green">#4CAF50</color> <!-- 绿色(备用:如“启用”状态标识) -->
 | 
				
			||||||
	<color name="yellow">#FFC107</color> <!-- 黄色(备用:如“提醒”标识) -->
 | 
						<color name="yellow">#FFC107</color> <!-- 黄色(备用:如“提醒”标识) -->
 | 
				
			||||||
 | 
					    <color name="color_text_primary">#333333</color>
 | 
				
			||||||
 | 
					    <color name="color_gray">#999999</color>
 | 
				
			||||||
 | 
					    <color name="color_gray_light">#F5F5F5</color>
 | 
				
			||||||
 | 
					    <color name="color_shadow">#1A000000</color>
 | 
				
			||||||
 | 
					    <color name="color_primary">#2196F3</color> <!-- 主题蓝 -->
 | 
				
			||||||
 | 
					    <color name="color_primary_dark">#1976D2</color> <!-- 主题蓝加深 -->
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
</resources>
 | 
					</resources>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,4 +8,10 @@
 | 
				
			|||||||
        <item name="colorAccent">@color/colorAccent</item>
 | 
					        <item name="colorAccent">@color/colorAccent</item>
 | 
				
			||||||
    </style>
 | 
					    </style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<style name="PopupDateTimePickerAnim" parent="android:Animation">
 | 
				
			||||||
 | 
							<item name="android:windowEnterAnimation">@anim/popup_date_time_picker_in</item>
 | 
				
			||||||
 | 
							<item name="android:windowExitAnimation">@anim/popup_date_time_picker_out</item>
 | 
				
			||||||
 | 
						</style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</resources>
 | 
					</resources>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user