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