@@ -1 +1,433 @@
 
			
		
	
		
		
			
				
					
					//package cc.winboll.studio.positions.services;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					///**  
			
		
	
		
		
			
				
					
					// * @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>  
			
		
	
		
		
			
				
					
					// * @Date 2025/09/30 19:53  
			
		
	
		
		
			
				
					
					// * @Describe 位置距离服务:管理数据+定时计算距离+适配Adapter(   
			
		
	
		
		
			
				
					
					// */  
			
		
	
		
		
			
				
					
					//import android.app.Service;  
			
		
	
		
		
			
				
					
					//import android.content.Context;  
			
		
	
		
		
			
				
					
					//import android.content.Intent;  
			
		
	
		
		
			
				
					
					//import android.content.pm.PackageManager;  
			
		
	
		
		
			
				
					
					//import android.location.Location;  
			
		
	
		
		
			
				
					
					//import android.location.LocationListener;  
			
		
	
		
		
			
				
					
					//import android.location.LocationManager;  
			
		
	
		
		
			
				
					
					//import android.os.Binder;  
			
		
	
		
		
			
				
					
					//import android.os.Build;  
			
		
	
		
		
			
				
					
					//import android.os.Bundle;  
			
		
	
		
		
			
				
					
					//import android.os.IBinder;  
			
		
	
		
		
			
				
					
					//import android.os.Looper;  
			
		
	
		
		
			
				
					
					//import android.widget.Toast;  
			
		
	
		
		
			
				
					
					//import cc.winboll.studio.libappbase.LogUtils;  
			
		
	
		
		
			
				
					
					//import cc.winboll.studio.positions.adapters.PositionAdapter;  
			
		
	
		
		
			
				
					
					//import cc.winboll.studio.positions.models.AppConfigsModel;  
			
		
	
		
		
			
				
					
					//import cc.winboll.studio.positions.models.PositionModel;  
			
		
	
		
		
			
				
					
					//import cc.winboll.studio.positions.models.PositionTaskModel;  
			
		
	
		
		
			
				
					
					//import cc.winboll.studio.positions.utils.NotificationUtil;  
			
		
	
		
		
			
				
					
					//import java.util.ArrayList;  
			
		
	
		
		
			
				
					
					//import java.util.HashSet;  
			
		
	
		
		
			
				
					
					//import java.util.Iterator;  
			
		
	
		
		
			
				
					
					//import java.util.Set;  
			
		
	
		
		
			
				
					
					//import java.util.concurrent.Executors;  
			
		
	
		
		
			
				
					
					//import java.util.concurrent.ScheduledExecutorService;  
			
		
	
		
		
			
				
					
					//import java.util.concurrent.TimeUnit;  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					///**  
			
		
	
		
		
			
				
					
					// * 核心职责:  
			
		
	
		
		
			
				
					
					// * 1. 实现 PositionAdapter.DistanceServiceInterface 接口,   
			
		
	
		
		
			
				
					
					// * 2. 单例式管理位置/任务数据,提供安全增删改查接口  
			
		
	
		
		
			
				
					
					// * 3. 后台单线程定时计算可见位置距离,   
			
		
	
		
		
			
				
					
					// * 4. 内置GPS信号加载( , )   
			
		
	
		
		
			
				
					
					// * 5. 服务启动时启动前台通知( , )   
			
		
	
		
		
			
				
					
					// * 6. 严格Java 7语法: ,   
			
		
	
		
		
			
				
					
					// */  
			
		
	
		
		
			
				
					
					//public class DistanceRefreshService extends Service {  
			
		
	
		
		
			
				
					
					//    public static final String TAG = "DistanceRefreshService";  
			
		
	
		
		
			
				
					
					//	  
			
		
	
		
		
			
				
					
					//	  
			
		
	
		
		
			
				
					
					//    // 服务状态与配置  
			
		
	
		
		
			
				
					
					//    private boolean isServiceRunning = false;  
			
		
	
		
		
			
				
					
					//      
			
		
	
		
		
			
				
					
					//    private static final int REFRESH_INTERVAL = 3; // 距离刷新间隔(秒)  
			
		
	
		
		
			
				
					
					//    // 前台通知相关: ( )   
			
		
	
		
		
			
				
					
					//    private boolean isForegroundServiceStarted = false;  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//     
			
		
	
		
		
			
				
					
					//      
			
		
	
		
		
			
				
					
					//    // 服务绑定与UI回调  
			
		
	
		
		
			
				
					
					//    private final IBinder mBinder = new DistanceBinder();  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//      
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    /**  
			
		
	
		
		
			
				
					
					//     * 在主线程显示Toast( )   
			
		
	
		
		
			
				
					
					//     */  
			
		
	
		
		
			
				
					
					//    private void showToastOnMainThread(final String message) {  
			
		
	
		
		
			
				
					
					//        if (Looper.myLooper() == Looper.getMainLooper()) {  
			
		
	
		
		
			
				
					
					//            Toast.makeText(this, message, Toast.LENGTH_SHORT).show();  
			
		
	
		
		
			
				
					
					//        } else {  
			
		
	
		
		
			
				
					
					//            new android.os.Handler(Looper.getMainLooper()).post(new Runnable() {  
			
		
	
		
		
			
				
					
					//					@Override  
			
		
	
		
		
			
				
					
					//					public void run() {  
			
		
	
		
		
			
				
					
					//						Toast.makeText(DistanceRefreshService.this, message, Toast.LENGTH_SHORT).show();  
			
		
	
		
		
			
				
					
					//					}  
			
		
	
		
		
			
				
					
					//				});  
			
		
	
		
		
			
				
					
					//        }  
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    // ---------------------- Binder 内部类(供外部绑定服务) ----------------------  
			
		
	
		
		
			
				
					
					//    public class DistanceBinder extends Binder {  
			
		
	
		
		
			
				
					
					//        /**  
			
		
	
		
		
			
				
					
					//         * 外部绑定后获取服务实例(安全暴露服务引用)  
			
		
	
		
		
			
				
					
					//         */  
			
		
	
		
		
			
				
					
					//        public DistanceRefreshService getService() {  
			
		
	
		
		
			
				
					
					//            return DistanceRefreshService.this;  
			
		
	
		
		
			
				
					
					//        }  
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//      
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    @Override  
			
		
	
		
		
			
				
					
					//    public void onCreate() {  
			
		
	
		
		
			
				
					
					//        super.onCreate();  
			
		
	
		
		
			
				
					
					//		  
			
		
	
		
		
			
				
					
					//        // 初始化GPS管理器( , )   
			
		
	
		
		
			
				
					
					//        mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);  
			
		
	
		
		
			
				
					
					//        LogUtils.d(TAG, "服务 onCreate: ,   
			
		
	
		
		
			
				
					
					//        run();  
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    @Override  
			
		
	
		
		
			
				
					
					//    public int onStartCommand(Intent intent, int flags, int startId) {  
			
		
	
		
		
			
				
					
					//        run();  
			
		
	
		
		
			
				
					
					//        AppConfigsModel bean = AppConfigsModel.loadBean(DistanceRefreshService.this, AppConfigsModel.class);  
			
		
	
		
		
			
				
					
					//        boolean isEnableService = (bean == null) ? false : bean.isEnableMainService();  
			
		
	
		
		
			
				
					
					//        // 服务启用时返回START_STICKY( ) ,   
			
		
	
		
		
			
				
					
					//        return isEnableService ? Service.START_STICKY : super.onStartCommand(intent, flags, startId);  
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    public void run() {  
			
		
	
		
		
			
				
					
					//        // 仅服务未运行时启动(避免重复启动)  
			
		
	
		
		
			
				
					
					//        if (!isServiceRunning) {  
			
		
	
		
		
			
				
					
					//            isServiceRunning = true;  
			
		
	
		
		
			
				
					
					//			  
			
		
	
		
		
			
				
					
					//			  
			
		
	
		
		
			
				
					
					//			  
			
		
	
		
		
			
				
					
					//            startDistanceRefreshTask(); // 启动定时距离计算  
			
		
	
		
		
			
				
					
					//            startForegroundNotification(); // 启动前台通知  
			
		
	
		
		
			
				
					
					//              
			
		
	
		
		
			
				
					
					//            LogUtils.d(TAG, "服务 onStartCommand: ,   
			
		
	
		
		
			
				
					
					//        } else {  
			
		
	
		
		
			
				
					
					//            LogUtils.w(TAG, "服务 onStartCommand: , ( : : )   
			
		
	
		
		
			
				
					
					//            // 异常场景恢复:补全未启动的组件  
			
		
	
		
		
			
				
					
					//            if (!isForegroundServiceStarted) {  
			
		
	
		
		
			
				
					
					//                startForegroundNotification();  
			
		
	
		
		
			
				
					
					//                LogUtils.d(TAG, "服务 run: ,   
			
		
	
		
		
			
				
					
					//            }  
			
		
	
		
		
			
				
					
					//            if (isServiceRunning && !isGpsEnabled) {  
			
		
	
		
		
			
				
					
					//                startGpsLocation();  
			
		
	
		
		
			
				
					
					//                LogUtils.d(TAG, "服务 run: ,   
			
		
	
		
		
			
				
					
					//            }  
			
		
	
		
		
			
				
					
					//        }  
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    @Override  
			
		
	
		
		
			
				
					
					//    public IBinder onBind(Intent intent) {  
			
		
	
		
		
			
				
					
					//		return null; // 按你的业务逻辑返回,   
			
		
	
		
		
			
				
					
					//        //LogUtils.d(TAG, "服务 onBind: ( : : )   
			
		
	
		
		
			
				
					
					//        //return mBinder; // 返回Binder实例,   
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    /*@Override  
			
		
	
		
		
			
				
					
					//	 public boolean onUnbind(Intent intent) {  
			
		
	
		
		
			
				
					
					//	 LogUtils.d(TAG, "服务 onUnbind: ,   
			
		
	
		
		
			
				
					
					//	 // 解绑后清理资源,避免内存泄漏  
			
		
	
		
		
			
				
					
					//	 mDistanceReceiver = null;  
			
		
	
		
		
			
				
					
					//	 mVisiblePositionIds.clear();  
			
		
	
		
		
			
				
					
					//	 // 解绑时不停止GPS( , )   
			
		
	
		
		
			
				
					
					//	 return super.onUnbind(intent);  
			
		
	
		
		
			
				
					
					//	 }*/  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    @Override  
			
		
	
		
		
			
				
					
					//    public void onDestroy() {  
			
		
	
		
		
			
				
					
					//        super.onDestroy();  
			
		
	
		
		
			
				
					
					//		  
			
		
	
		
		
			
				
					
					//        LogUtils.d(TAG, "服务 onDestroy: , (   
			
		
	
		
		
			
				
					
					//    }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//    // ---------------------- 前台服务通知管理( )   
			
		
	
		
		
			
				
					
					//    /**  
			
		
	
		
		
			
				
					
					//     * 启动前台服务通知( , )   
			
		
	
		
		
			
				
					
					//     */  
			
		
	
		
		
			
				
					
					//    private void startForegroundNotification() {  
			
		
	
		
		
			
				
					
					//        // 1. 校验: ( )   
			
		
	
		
		
			
				
					
					//        if (isForegroundServiceStarted) {  
			
		
	
		
		
			
				
					
					//            LogUtils.w(TAG, "startForegroundNotification: ,   
			
		
	
		
		
			
				
					
					//            return;  
			
		
	
		
		
			
				
					
					//        }  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//        try {  
			
		
	
		
		
			
				
					
					//// 2. 初始化通知状态文本( , )   
			
		
	
		
		
			
				
					
					//			String initialStatus;  
			
		
	
		
		
			
				
					
					//			if (isGpsPermissionGranted && isGpsEnabled) {  
			
		
	
		
		
			
				
					
					//				initialStatus = "GPS已就绪, (   
			
		
	
		
		
			
				
					
					//			} else if (!isGpsPermissionGranted) {  
			
		
	
		
		
			
				
					
					//				initialStatus = "缺少定位权限,   
			
		
	
		
		
			
				
					
					//			} else {  
			
		
	
		
		
			
				
					
					//				initialStatus = "GPS未开启,   
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//// 5. 标记前台服务已启动  
			
		
	
		
		
			
				
					
					//			isForegroundServiceStarted = true;  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "startForegroundNotification: , :   
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//		} catch (Exception e) {  
			
		
	
		
		
			
				
					
					//// 捕获异常(如上下文失效、通知渠道未创建)  
			
		
	
		
		
			
				
					
					//			isForegroundServiceStarted = false;  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "startForegroundNotification:   
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	/**  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	 - 主线程回调Adapter更新UI( )   
			
		
	
		
		
			
				
					
					//	 */  
			
		
	
		
		
			
				
					
					//	/*private void notifyDistanceUpdateToUI(final String positionId) {  
			
		
	
		
		
			
				
					
					//	 if (Looper.myLooper() == Looper.getMainLooper()) {  
			
		
	
		
		
			
				
					
					//	 if (mDistanceReceiver != null) {  
			
		
	
		
		
			
				
					
					//	 mDistanceReceiver.onDistanceUpdate(positionId);  
			
		
	
		
		
			
				
					
					//	 }  
			
		
	
		
		
			
				
					
					//	 } else {  
			
		
	
		
		
			
				
					
					//	 new android.os.Handler(Looper.getMainLooper()).post(new Runnable() {  
			
		
	
		
		
			
				
					
					//	 @Override  
			
		
	
		
		
			
				
					
					//	 public void run() {  
			
		
	
		
		
			
				
					
					//	 if (mDistanceReceiver != null) {  
			
		
	
		
		
			
				
					
					//	 mDistanceReceiver.onDistanceUpdate(positionId);  
			
		
	
		
		
			
				
					
					//	 }  
			
		
	
		
		
			
				
					
					//	 }  
			
		
	
		
		
			
				
					
					//	 });  
			
		
	
		
		
			
				
					
					//	 }  
			
		
	
		
		
			
				
					
					//	 }*/  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//// ---------------------- 实现 PositionAdapter.DistanceServiceInterface 接口 ----------------------  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	public ArrayList getPositionList() {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "getPositionList: ,   
			
		
	
		
		
			
				
					
					//			return new ArrayList();  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//		return new ArrayList(mPositionList);  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	public ArrayList getPositionTasksList() {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "getPositionTasksList: ,   
			
		
	
		
		
			
				
					
					//			return new ArrayList();  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//		return new ArrayList(mTaskList);  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	  
			
		
	
		
		
			
				
					
					//	  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	/*public void setOnDistanceUpdateReceiver(PositionAdapter.OnDistanceUpdateReceiver receiver) {  
			
		
	
		
		
			
				
					
					//		this.mDistanceReceiver = receiver;  
			
		
	
		
		
			
				
					
					//		LogUtils.d(TAG, "setOnDistanceUpdateReceiver: ( )   
			
		
	
		
		
			
				
					
					//	}*/  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	public void addVisibleDistanceView(String positionId) {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning || positionId == null) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "addVisibleDistanceView: ,   
			
		
	
		
		
			
				
					
					//			return;  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//		if (mVisiblePositionIds.add(positionId)) {  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "addVisibleDistanceView: ( )   
			
		
	
		
		
			
				
					
					//// 新增:添加可见位置后,立即更新通知(显示最新可见数量)  
			
		
	
		
		
			
				
					
					//			if (isForegroundServiceStarted && mCurrentGpsPosition != null) {  
			
		
	
		
		
			
				
					
					//				syncGpsStatusToNotification();  
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	public void removeVisibleDistanceView(String positionId) {  
			
		
	
		
		
			
				
					
					//		if (positionId == null) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "removeVisibleDistanceView: ,   
			
		
	
		
		
			
				
					
					//			return;  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//		if (mVisiblePositionIds.remove(positionId)) {  
			
		
	
		
		
			
				
					
					//			int remainingCount = mVisiblePositionIds.size();  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "removeVisibleDistanceView: ( )   
			
		
	
		
		
			
				
					
					//// 新增:移除可见位置后,更新通知(同步数量变化)  
			
		
	
		
		
			
				
					
					//			if (isForegroundServiceStarted && mCurrentGpsPosition != null) {  
			
		
	
		
		
			
				
					
					//				syncGpsStatusToNotification();  
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	public void clearVisibleDistanceViews() {  
			
		
	
		
		
			
				
					
					//		mVisiblePositionIds.clear();  
			
		
	
		
		
			
				
					
					//		LogUtils.d(TAG, "clearVisibleDistanceViews:   
			
		
	
		
		
			
				
					
					//// 新增:清空可见位置后,更新通知(提示计算暂停)  
			
		
	
		
		
			
				
					
					//		if (isForegroundServiceStarted) {  
			
		
	
		
		
			
				
					
					//			updateNotificationGpsStatus("无可见位置,距离计算暂停");  
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//// ---------------------- 数据管理接口(修复原有语法错误+优化逻辑) ----------------------  
			
		
	
		
		
			
				
					
					//	/**  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	 - 获取服务运行状态  
			
		
	
		
		
			
				
					
					//	 */  
			
		
	
		
		
			
				
					
					//	public boolean isServiceRunning() {  
			
		
	
		
		
			
				
					
					//		return isServiceRunning;  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	/**  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	 - 添加位置(修复迭代器泛型缺失问题)  
			
		
	
		
		
			
				
					
					//	 */  
			
		
	
		
		
			
				
					
					//	public void addPosition(PositionModel position) {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning || position == null || position.getPositionId() == null) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "addPosition:   
			
		
	
		
		
			
				
					
					//			return;  
			
		
	
		
		
			
				
					
					//		}// 修复: ,   
			
		
	
		
		
			
				
					
					//		boolean isDuplicate = false;  
			
		
	
		
		
			
				
					
					//		Iterator posIter = mPositionList.iterator();  
			
		
	
		
		
			
				
					
					//		while (posIter.hasNext()) {  
			
		
	
		
		
			
				
					
					//			PositionModel existingPos = (PositionModel)posIter.next();  
			
		
	
		
		
			
				
					
					//			if (position.getPositionId().equals(existingPos.getPositionId())) {  
			
		
	
		
		
			
				
					
					//				isDuplicate = true;  
			
		
	
		
		
			
				
					
					//				break;  
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//		}if (!isDuplicate) {  
			
		
	
		
		
			
				
					
					//			mPositionList.add(position);  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "addPosition: ( )   
			
		
	
		
		
			
				
					
					//		} else {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "addPosition:   
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	/**  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	 - 删除位置(修复任务删除时的类型转换错误)  
			
		
	
		
		
			
				
					
					//	 */  
			
		
	
		
		
			
				
					
					//	public void removePosition(String positionId) {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning || positionId == null) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "removePosition: ,   
			
		
	
		
		
			
				
					
					//			return;  
			
		
	
		
		
			
				
					
					//		}// 1. 删除位置  
			
		
	
		
		
			
				
					
					//		boolean isRemoved = false;  
			
		
	
		
		
			
				
					
					//		Iterator posIter = mPositionList.iterator();  
			
		
	
		
		
			
				
					
					//		while (posIter.hasNext()) {  
			
		
	
		
		
			
				
					
					//			PositionModel pos = (PositionModel)posIter.next();  
			
		
	
		
		
			
				
					
					//			if (positionId.equals(pos.getPositionId())) {  
			
		
	
		
		
			
				
					
					//				posIter.remove();  
			
		
	
		
		
			
				
					
					//				isRemoved = true;  
			
		
	
		
		
			
				
					
					//				break;  
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//		}if (isRemoved) {  
			
		
	
		
		
			
				
					
					//// 修复: ( )   
			
		
	
		
		
			
				
					
					//			Iterator taskIter = mTaskList.iterator();  
			
		
	
		
		
			
				
					
					//			while (taskIter.hasNext()) {  
			
		
	
		
		
			
				
					
					//				PositionTaskModel task = (PositionTaskModel)taskIter.next();  
			
		
	
		
		
			
				
					
					//				if (positionId.equals(task.getPositionId())) {  
			
		
	
		
		
			
				
					
					//					taskIter.remove();  
			
		
	
		
		
			
				
					
					//				}  
			
		
	
		
		
			
				
					
					//			}// 3. 移除可见位置  
			
		
	
		
		
			
				
					
					//			mVisiblePositionIds.remove(positionId);  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "removePosition: ( )   
			
		
	
		
		
			
				
					
					//		} else {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "removePosition:   
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	/**  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	 - 更新位置信息(修复代码格式+迭代器泛型)  
			
		
	
		
		
			
				
					
					//	 */  
			
		
	
		
		
			
				
					
					//	public void updatePosition(PositionModel updatedPosition) {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning || updatedPosition == null || updatedPosition.getPositionId() == null) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "updatePosition:   
			
		
	
		
		
			
				
					
					//			return;  
			
		
	
		
		
			
				
					
					//		}boolean isUpdated = false;  
			
		
	
		
		
			
				
					
					//		Iterator posIter = mPositionList.iterator();  
			
		
	
		
		
			
				
					
					//		while (posIter.hasNext()) {  
			
		
	
		
		
			
				
					
					//			PositionModel pos = (PositionModel)posIter.next();  
			
		
	
		
		
			
				
					
					//			if (updatedPosition.getPositionId().equals(pos.getPositionId())) {  
			
		
	
		
		
			
				
					
					//				pos.setMemo(updatedPosition.getMemo());  
			
		
	
		
		
			
				
					
					//				pos.setIsEnableRealPositionDistance(updatedPosition.isEnableRealPositionDistance());  
			
		
	
		
		
			
				
					
					//				if (!updatedPosition.isEnableRealPositionDistance()) {  
			
		
	
		
		
			
				
					
					//					pos.setRealPositionDistance(-1);  
			
		
	
		
		
			
				
					
					//					//notifyDistanceUpdateToUI(pos.getPositionId());  
			
		
	
		
		
			
				
					
					//				}  
			
		
	
		
		
			
				
					
					//				isUpdated = true;  
			
		
	
		
		
			
				
					
					//				break;  
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//		}if (isUpdated) {  
			
		
	
		
		
			
				
					
					//			LogUtils.d(TAG, "updatePosition: ( )   
			
		
	
		
		
			
				
					
					//		} else {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "updatePosition:   
			
		
	
		
		
			
				
					
					//		}  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	/**  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//	 - 同步任务列表(修复泛型缺失+代码格式)  
			
		
	
		
		
			
				
					
					//	 */  
			
		
	
		
		
			
				
					
					//	public void syncAllPositionTasks(ArrayList tasks) {  
			
		
	
		
		
			
				
					
					//		if (!isServiceRunning || tasks == null) {  
			
		
	
		
		
			
				
					
					//			LogUtils.w(TAG, "syncAllPositionTasks:   
			
		
	
		
		
			
				
					
					//			return;  
			
		
	
		
		
			
				
					
					//		}// 1. 清空旧任务  
			
		
	
		
		
			
				
					
					//		mTaskList.clear();  
			
		
	
		
		
			
				
					
					//// 2. 添加新任务(修复泛型+去重逻辑)  
			
		
	
		
		
			
				
					
					//		Set taskIdSet = new HashSet();  
			
		
	
		
		
			
				
					
					//		Iterator taskIter = tasks.iterator();  
			
		
	
		
		
			
				
					
					//		while (taskIter.hasNext()) {  
			
		
	
		
		
			
				
					
					//			PositionTaskModel task = (PositionTaskModel)taskIter.next();  
			
		
	
		
		
			
				
					
					//			if (task != null && task.getTaskId() != null && !taskIdSet.contains(task.getTaskId())) {  
			
		
	
		
		
			
				
					
					//				taskIdSet.add(task.getTaskId());  
			
		
	
		
		
			
				
					
					//				mTaskList.add(task);  
			
		
	
		
		
			
				
					
					//			}  
			
		
	
		
		
			
				
					
					//		}LogUtils.d(TAG, "syncAllPositionTasks: ( )   
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//// ---------------------- 补充: ( )   
			
		
	
		
		
			
				
					
					//// 注: ,   
			
		
	
		
		
			
				
					
					//// 此处通过内部静态类定义, ( )   
			
		
	
		
		
			
				
					
					//	private static class LocationProvider {  
			
		
	
		
		
			
				
					
					//		public static final int AVAILABLE = 2;  
			
		
	
		
		
			
				
					
					//		public static final int OUT_OF_SERVICE = 0;  
			
		
	
		
		
			
				
					
					//		public static final int TEMPORARILY_UNAVAILABLE = 1;  
			
		
	
		
		
			
				
					
					//	}  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//// ---------------------- 补充: ( )   
			
		
	
		
		
			
				
					
					//	/*private Context getSafeContext() {  
			
		
	
		
		
			
				
					
					//	 // 服务未销毁时返回自身Context, ( )   
			
		
	
		
		
			
				
					
					//	 if (isDestroyed()) {  
			
		
	
		
		
			
				
					
					//	 return getApplicationContext();  
			
		
	
		
		
			
				
					
					//	 }  
			
		
	
		
		
			
				
					
					//	 return this;  
			
		
	
		
		
			
				
					
					//	 }*/  
			
		
	
		
		
			
				
					
					//  
			
		
	
		
		
			
				
					
					//// 注:   
			
		
	
		
		
			
				
					
					//	/*private boolean isDestroyed() {  
			
		
	
		
		
			
				
					
					//	 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {  
			
		
	
		
		
			
				
					
					//	 return super.isDestroyed();  
			
		
	
		
		
			
				
					
					//	 }  
			
		
	
		
		
			
				
					
					//	 // 低版本通过状态标记间接判断( )   
			
		
	
		
		
			
				
					
					//	 return !isServiceRunning && !isForegroundServiceStarted;  
			
		
	
		
		
			
				
					
					//	 }*/  
			
		
	
		
		
			
				
					
					//}