窗口基本加载服务数据
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 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
|
||||||
|
|||||||
@@ -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, "缓存数据失败:服务实例为空");
|
||||||
|
|||||||
Reference in New Issue
Block a user