20251002_104016_614
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Thu Oct 02 02:13:03 GMT 2025
|
#Thu Oct 02 02:36:00 GMT 2025
|
||||||
stageCount=8
|
stageCount=8
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.0
|
baseVersion=15.0
|
||||||
publishVersion=15.0.7
|
publishVersion=15.0.7
|
||||||
buildCount=2
|
buildCount=9
|
||||||
baseBetaVersion=15.0.8
|
baseBetaVersion=15.0.8
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ 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.services.MainService;
|
import cc.winboll.studio.positions.services.MainService;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
|
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 核心调整说明:
|
* 核心调整说明:
|
||||||
@@ -61,11 +63,13 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_location);
|
setContentView(R.layout.activity_location);
|
||||||
|
|
||||||
|
LogUtils.d(TAG, "onCreate");
|
||||||
|
|
||||||
// 1. 初始化服务实例(通过单例/全局方式,避免直接new导致数据重置)
|
// 1. 初始化服务实例(通过单例/全局方式,避免直接new导致数据重置)
|
||||||
initServiceInstance();
|
initServiceInstance();
|
||||||
// 2. 检查服务状态(未运行/未初始化则提示关闭)
|
// 2. 检查服务状态(未运行/未初始化则提示关闭)
|
||||||
//checkServiceStatus();
|
checkServiceStatus();
|
||||||
// 3. 初始化RecyclerView(布局+性能优化)
|
// 3. 初始化RecyclerView(布局+性能优化)
|
||||||
initRecyclerViewConfig();
|
initRecyclerViewConfig();
|
||||||
// 4. 缓存服务数据(从服务PUBLIC方法获取,不访问私有字段)
|
// 4. 缓存服务数据(从服务PUBLIC方法获取,不访问私有字段)
|
||||||
@@ -112,27 +116,27 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查服务状态(替代原绑定检查,通过服务PUBLIC方法判断)
|
* 检查服务状态(替代原绑定检查,通过服务PUBLIC方法判断)
|
||||||
*/
|
*/
|
||||||
private void checkServiceStatus() {
|
private void checkServiceStatus() {
|
||||||
|
LogUtils.d(TAG, "checkServiceStatus");
|
||||||
// 1. 服务实例未初始化
|
// 1. 服务实例未初始化
|
||||||
if (mMainService == null) {
|
if (mMainService == null) {
|
||||||
return; // 已在initServiceInstance中处理,此处避免重复finish
|
return; // 已在initServiceInstance中处理,此处避免重复finish
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 检查服务运行状态(通过服务PUBLIC方法isServiceRunning()获取,不访问私有字段)
|
// 2. 检查服务运行状态(通过服务PUBLIC方法isServiceRunning()获取,不访问私有字段)
|
||||||
// if (!mMainService.isServiceRunning()) {
|
if (!mMainService.isServiceRunning()) {
|
||||||
// // 服务未运行:手动触发启动(调用服务PUBLIC方法run())
|
// 服务未运行:手动触发启动(调用服务PUBLIC方法run())
|
||||||
// mMainService.run();
|
mMainService.run();
|
||||||
// LogUtils.d(TAG, "服务未运行,已通过PUBLIC方法触发启动");
|
LogUtils.d(TAG, "服务未运行,已通过PUBLIC方法触发启动");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 3. 检查SP中服务配置(双重校验,确保一致性)
|
// 3. 检查SP中服务配置(双重校验,确保一致性)
|
||||||
SharedPreferences sp = getSharedPreferences(SP_SERVICE_CONFIG, Context.MODE_PRIVATE);
|
if (!AppConfigsUtil.getInstance(LocationActivity.this).isEnableMainService(true)) {
|
||||||
boolean isServiceConfigRunning = sp.getBoolean(KEY_SERVICE_RUNNING, false);
|
|
||||||
if (!isServiceConfigRunning) {
|
|
||||||
Toast.makeText(this, "位置服务配置未启用,数据可能无法更新", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "位置服务配置未启用,数据可能无法更新", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,6 +146,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
|||||||
*/
|
*/
|
||||||
private void cacheServiceData() {
|
private void cacheServiceData() {
|
||||||
if (mMainService == null) {
|
if (mMainService == null) {
|
||||||
|
ToastUtils.show("缓存数据失败:服务实例为空");
|
||||||
LogUtils.e(TAG, "缓存数据失败:服务实例为空");
|
LogUtils.e(TAG, "缓存数据失败:服务实例为空");
|
||||||
mCachedPositionList = new ArrayList<PositionModel>();
|
mCachedPositionList = new ArrayList<PositionModel>();
|
||||||
mCachedTaskList = new ArrayList<PositionTaskModel>();
|
mCachedTaskList = new ArrayList<PositionTaskModel>();
|
||||||
@@ -156,6 +161,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
|||||||
if (mCachedPositionList == null) mCachedPositionList = new ArrayList<PositionModel>();
|
if (mCachedPositionList == null) mCachedPositionList = new ArrayList<PositionModel>();
|
||||||
if (mCachedTaskList == null) mCachedTaskList = new ArrayList<PositionTaskModel>();
|
if (mCachedTaskList == null) mCachedTaskList = new ArrayList<PositionTaskModel>();
|
||||||
|
|
||||||
|
ToastUtils.show("缓存服务数据成功:位置数=" + mCachedPositionList.size() + ",任务数=" + mCachedTaskList.size());
|
||||||
LogUtils.d(TAG, "缓存服务数据成功:位置数=" + mCachedPositionList.size() + ",任务数=" + mCachedTaskList.size());
|
LogUtils.d(TAG, "缓存服务数据成功:位置数=" + mCachedPositionList.size() + ",任务数=" + mCachedTaskList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +181,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
|||||||
* 初始化Adapter(通过缓存数据初始化,数据更新时同步调用服务方法)
|
* 初始化Adapter(通过缓存数据初始化,数据更新时同步调用服务方法)
|
||||||
*/
|
*/
|
||||||
private void initAdapter() {
|
private void initAdapter() {
|
||||||
|
LogUtils.d(TAG, "initAdapter");
|
||||||
if (mCachedPositionList == null || mCachedTaskList == null) {
|
if (mCachedPositionList == null || mCachedTaskList == null) {
|
||||||
LogUtils.e(TAG, "初始化Adapter失败:缓存数据为空");
|
LogUtils.e(TAG, "初始化Adapter失败:缓存数据为空");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class MainService extends Service {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
public void run() {
|
||||||
if (mAppConfigsUtil.isEnableMainService(true)) {
|
if (mAppConfigsUtil.isEnableMainService(true)) {
|
||||||
if (_mIsServiceRunning == false) {
|
if (_mIsServiceRunning == false) {
|
||||||
// 设置运行状态
|
// 设置运行状态
|
||||||
@@ -135,6 +135,10 @@ public class MainService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isServiceRunning() {
|
||||||
|
return _mIsServiceRunning;
|
||||||
|
}
|
||||||
|
|
||||||
public interface SMSListener {
|
public interface SMSListener {
|
||||||
void speakMessage();
|
void speakMessage();
|
||||||
|
|||||||
Reference in New Issue
Block a user