窗口基本加载服务数据

This commit is contained in:
ZhanGSKen
2025-10-02 16:03:50 +08:00
parent 1f57ac5401
commit 916e807f1b
2 changed files with 38 additions and 35 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Oct 02 06:11:17 GMT 2025 #Thu Oct 02 08:02:02 GMT 2025
stageCount=8 stageCount=8
libraryProject= libraryProject=
baseVersion=15.0 baseVersion=15.0
publishVersion=15.0.7 publishVersion=15.0.7
buildCount=19 buildCount=27
baseBetaVersion=15.0.8 baseBetaVersion=15.0.8

View File

@@ -69,17 +69,17 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
LogUtils.d(TAG, "onCreate"); LogUtils.d(TAG, "onCreate");
// 1. 初始化GPS监听提前创建避免空指针 // 初始化GPS监听提前创建避免空指针
initGpsUpdateListener(); initGpsUpdateListener();
// 2. 启动+初始化MainService确保服务已创建实例可获取 // 启动+初始化MainService确保服务已创建实例可获取
startAndInitMainService(); startAndInitMainService();
// 3. 检查服务状态(未运行则启动,配置未启用则提示 // 初始化RecyclerView布局+性能优化
checkServiceStatus();
// 4. 初始化RecyclerView布局+性能优化)
initRecyclerViewConfig(); initRecyclerViewConfig();
// 5. 缓存服务数据从服务PUBLIC方法获取不访问私有字段 // 检查服务状态(未运行则启动,配置未启用则提示
//checkServiceStatus();
// 缓存服务数据从服务PUBLIC方法获取不访问私有字段
cacheServiceData(); cacheServiceData();
// 6. 初始化Adapter传缓存数据+当前GPS位置支持距离计算显示 // 初始化Adapter传缓存数据+当前GPS位置支持距离计算显示
initAdapter(); initAdapter();
} }
@@ -226,46 +226,49 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
}, 1000); }, 1000);
} else { } else {
LogUtils.d(TAG, "MainService实例获取成功"); LogUtils.d(TAG, "MainService实例获取成功");
refreshCachedDataAndAdapter();
} }
} }
}, 200); }, 200);
LogUtils.d(TAG, "startAndInitMainService end.");
} }
/** /**
* 检查服务状态通过服务PUBLIC方法不访问私有字段 * 检查服务状态通过服务PUBLIC方法不访问私有字段
*/ */
private void checkServiceStatus() { // private void checkServiceStatus() {
LogUtils.d(TAG, "checkServiceStatus"); // LogUtils.d(TAG, "checkServiceStatus");
// 1. 服务实例未初始化(等待延迟获取,不重复处理) // // 1. 服务实例未初始化(等待延迟获取,不重复处理)
if (mMainService == null) { // if (mMainService == null) {
LogUtils.d(TAG, "服务实例未就绪,等待初始化..."); // LogUtils.d(TAG, "服务实例未就绪,等待初始化...");
return; // return;
} // }
//
// 2. 检查服务运行状态调用isServiceRunning() // // 2. 检查服务运行状态调用isServiceRunning()
if (!mMainService.isServiceRunning()) { // if (!mMainService.isServiceRunning()) {
// 服务未运行调用run()启动 // // 服务未运行调用run()启动
mMainService.run(); // mMainService.run();
LogUtils.d(TAG, "服务未运行已通过run()触发启动"); // LogUtils.d(TAG, "服务未运行已通过run()触发启动");
} // }
//
// 3. 检查服务配置是否启用调用AppConfigsUtil的PUBLIC方法 // // 3. 检查服务配置是否启用调用AppConfigsUtil的PUBLIC方法
if (!AppConfigsUtil.getInstance(this).isEnableMainService(true)) { // if (!AppConfigsUtil.getInstance(this).isEnableMainService(true)) {
Toast.makeText(this, "位置服务配置未启用,数据可能无法更新", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "位置服务配置未启用,数据可能无法更新", Toast.LENGTH_SHORT).show();
LogUtils.w(TAG, "位置服务配置未启用"); // LogUtils.w(TAG, "位置服务配置未启用");
} // }
//
// 4. 新增检查GPS状态通过服务逻辑间接判断提示用户 // // 4. 新增检查GPS状态通过服务逻辑间接判断提示用户
if (mCurrentGpsPos == null && mMainService.isServiceRunning()) { // if (mCurrentGpsPos == null && mMainService.isServiceRunning()) {
ToastUtils.show("等待GPS信号...请确保GPS已开启且权限已授予"); // ToastUtils.show("等待GPS信号...请确保GPS已开启且权限已授予");
} // }
} // }
// ---------------------- 原有逻辑完善适配GPS数据同步服务交互 ---------------------- // ---------------------- 原有逻辑完善适配GPS数据同步服务交互 ----------------------
/** /**
* 缓存服务数据新增GPS位置缓存供Adapter使用 * 缓存服务数据新增GPS位置缓存供Adapter使用
*/ */
private void cacheServiceData() { private void cacheServiceData() {
LogUtils.d(TAG, "cacheServiceData()");
if (mMainService == null) { if (mMainService == null) {
ToastUtils.show("缓存数据失败:服务实例为空"); ToastUtils.show("缓存数据失败:服务实例为空");
LogUtils.e(TAG, "缓存数据失败:服务实例为空"); LogUtils.e(TAG, "缓存数据失败:服务实例为空");