From db87ba51e330c0249cf93e328ede2a20bbb06e10 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Fri, 26 Dec 2025 02:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E6=94=B6=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E5=9B=BE=E7=89=87=E5=90=8E=E7=9A=84=E4=B8=BB=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- powerbell/build.properties | 4 +- .../java/cc/winboll/studio/powerbell/App.java | 77 +++++++++++-------- .../studio/powerbell/MainActivity.java | 2 +- .../powerbell/views/MainContentView.java | 19 +++-- 4 files changed, 62 insertions(+), 40 deletions(-) diff --git a/powerbell/build.properties b/powerbell/build.properties index ccec3e6..78b2b97 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Thu Dec 25 16:23:58 GMT 2025 +#Thu Dec 25 18:53:54 GMT 2025 stageCount=34 libraryProject= baseVersion=15.14 publishVersion=15.14.33 -buildCount=11 +buildCount=39 baseBetaVersion=15.14.34 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/App.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/App.java index 5cc82a6..a9804c1 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/App.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/App.java @@ -40,6 +40,9 @@ public class App extends GlobalApplication { private static final int INVALID_BATTERY_VALUE = -1; // ===================== 静态属性区(按工具类优先级排序) ===================== + // 应用单例 + private static App sApp; + // 数据配置工具 public static AppConfigUtils sAppConfigUtils; private static AppCacheUtils sAppCacheUtils; @@ -49,25 +52,32 @@ public class App extends GlobalApplication { public static BitmapCacheUtils sBitmapCacheUtils; // 全局视图控件缓存工具(极致强制保持:一旦初始化,永不销毁) - // 核心修改:改为私有静态,通过实例方法获取,避免全局通用暴露 private static MemoryCachedBackgroundView sMemoryCachedBackgroundView; + + // 电池状态 public static volatile int sQuantityOfElectricity = INVALID_BATTERY_VALUE; + // 通知管理工具 + private static NotificationManagerUtils sNotificationManagerUtils; + // ===================== 成员属性区(按生命周期关联度排序) ===================== // 全局广播接收器 private GlobalApplicationReceiver mGlobalReceiver; - // 通知管理工具 - private static NotificationManagerUtils sNotificationManagerUtils; - private static App sApp; + // ===================== 公共静态方法区(工具类实例获取/单例) ===================== + /** + * 获取应用单例实例 + */ + public static App getInstance() { + return sApp; + } - // ===================== 公共静态方法区(工具类实例获取) ===================== /** * 获取应用配置工具实例 */ public static AppConfigUtils getAppConfigUtils(Context context) { LogUtils.d(TAG, String.format("getAppConfigUtils() 调用 | 传入Context类型=%s", - context != null ? context.getClass().getSimpleName() : "null")); + context != null ? context.getClass().getSimpleName() : "null")); if (sAppConfigUtils == null) { sAppConfigUtils = AppConfigUtils.getInstance(context); LogUtils.d(TAG, "getAppConfigUtils():AppConfigUtils实例已初始化"); @@ -80,7 +90,7 @@ public class App extends GlobalApplication { */ public static AppCacheUtils getAppCacheUtils(Context context) { LogUtils.d(TAG, String.format("getAppCacheUtils() 调用 | 传入Context类型=%s", - context != null ? context.getClass().getSimpleName() : "null")); + context != null ? context.getClass().getSimpleName() : "null")); if (sAppCacheUtils == null) { sAppCacheUtils = AppCacheUtils.getInstance(context); LogUtils.d(TAG, "getAppCacheUtils():AppCacheUtils实例已初始化"); @@ -88,13 +98,6 @@ public class App extends GlobalApplication { return sAppCacheUtils; } - /** - * 获取应用单例实例 - */ - public static App getInstance() { - return sApp; - } - // ===================== 公共成员方法区(业务功能) ===================== /** * 清除电池历史数据 @@ -139,12 +142,26 @@ public class App extends GlobalApplication { return sMemoryCachedBackgroundView; } + /** + * 发送调试通知 + */ + public static void notifyMessage(String title, String content) { + LogUtils.d(TAG, String.format("notifyMessage() 调用 | title=%s | content=%s", title, content)); + if (isDebugging() && sApp != null && sNotificationManagerUtils != null) { + NotificationMessage message = new NotificationMessage(title, content, ""); + sNotificationManagerUtils.showMessageNotification(sApp, message); + LogUtils.d(TAG, "notifyMessage():调试通知发送成功"); + } else { + LogUtils.d(TAG, "notifyMessage():调试通知发送失败(条件不满足)"); + } + } + // ===================== 生命周期方法区(按执行顺序排序) ===================== @Override public void onCreate() { super.onCreate(); - sApp = this; LogUtils.d(TAG, "onCreate() 应用启动,开始初始化"); + sApp = this; // 初始化调试模式 setIsDebugging(BuildConfig.DEBUG); @@ -152,7 +169,6 @@ public class App extends GlobalApplication { // 初始化基础工具 initBaseTools(); - //App.notifyMessage(TAG, "onCreate() 应用启动中。。。"); // 初始化工具类实例(核心:极致强制缓存,永不销毁) initUtils(); // 初始化广播接收器 @@ -185,7 +201,7 @@ public class App extends GlobalApplication { super.onTrimMemory(level); // 极致强制缓存:禁止任何缓存清理操作,仅记录日志 LogUtils.w(TAG, String.format("%s onTrimMemory() 调用 | 内存等级level=%d | 极致强制保持所有缓存", - CACHE_PROTECT_TAG, level)); + CACHE_PROTECT_TAG, level)); // 记录详细缓存状态,不执行任何清理 logDetailedCacheStatus(); } @@ -201,15 +217,14 @@ public class App extends GlobalApplication { // ===================== 私有初始化方法区(按初始化顺序排序) ===================== /** - * 初始化基础工具(Activity管理、Toast) + * 初始化基础工具(Activity管理、Toast、通知工具) */ private void initBaseTools() { LogUtils.d(TAG, "initBaseTools() 开始初始化基础工具"); WinBoLLActivityManager.init(this); ToastUtils.init(this); - LogUtils.d(TAG, "initBaseTools() 基础工具初始化完成"); sNotificationManagerUtils = new NotificationManagerUtils(this); - LogUtils.d(TAG, "initBaseTools() 工具类初始化完成,极致强制缓存策略已生效"); + LogUtils.d(TAG, "initBaseTools() 基础工具+通知工具初始化完成,极致强制缓存策略已生效"); } /** @@ -217,22 +232,31 @@ public class App extends GlobalApplication { */ private void initUtils() { LogUtils.d(TAG, "initUtils() 开始初始化工具类,启用极致强制缓存策略"); - //App.notifyMessage(TAG, "initUtils() 开始初始化工具类,启用极致强制缓存策略"); + // 初始化配置&缓存工具 sAppConfigUtils = getAppConfigUtils(this); sAppCacheUtils = getAppCacheUtils(this); + // 初始化背景资源工具 sBackgroundSourceUtils = BackgroundSourceUtils.getInstance(this); sBackgroundSourceUtils.loadSettings(); + LogUtils.d(TAG, "initUtils() 背景资源工具已初始化"); + // 极致强制初始化Bitmap缓存工具(必初始化,永不销毁) sBitmapCacheUtils = BitmapCacheUtils.getInstance(); LogUtils.d(TAG, "initUtils() Bitmap缓存工具已初始化(极致强制保持,永不销毁)"); // 极致强制初始化视图控件缓存工具(必初始化,永不销毁) +// if(sMemoryCachedBackgroundView == null) { +// App.notifyMessage(TAG, "sMemoryCachedBackgroundView == null"); +// } sMemoryCachedBackgroundView = MemoryCachedBackgroundView.getLastInstance(this); if (sMemoryCachedBackgroundView == null) { - //App.notifyMessage(TAG, "sMemoryCachedBackgroundView == null"); sMemoryCachedBackgroundView = MemoryCachedBackgroundView.getInstance(this, sBackgroundSourceUtils.getCurrentBackgroundBean(), true); + LogUtils.d(TAG, "initUtils() 视图控件缓存工具已新建实例"); + //App.notifyMessage(TAG, "没有使用缓存控件"); } + + //App.notifyMessage(TAG, "initUtils() 视图控件缓存工具已初始化(极致强制保持,永不销毁)"); LogUtils.d(TAG, "initUtils() 视图控件缓存工具已初始化(极致强制保持,永不销毁)"); } @@ -290,7 +314,7 @@ public class App extends GlobalApplication { LogUtils.d(TAG, String.format("%s Bitmap缓存数量=%d", CACHE_PROTECT_TAG, cacheCount)); } catch (Exception e) { LogUtils.d(TAG, String.format("%s Bitmap缓存数量获取失败(不影响缓存)| 异常信息=%s", - CACHE_PROTECT_TAG, e.getMessage())); + CACHE_PROTECT_TAG, e.getMessage())); } } // 视图控件缓存状态 @@ -302,12 +326,5 @@ public class App extends GlobalApplication { } LogUtils.d(TAG, "logDetailedCacheStatus() 详细缓存状态记录完成,所有缓存均极致强制保持"); } - - public static void notifyMessage(String title, String content) { - if (isDebugging() && sApp != null && sNotificationManagerUtils != null) { - NotificationMessage message = new NotificationMessage(title, content, ""); - sNotificationManagerUtils.showMessageNotification(sApp, message); - } - } } diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java index 056bcbc..869b936 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java @@ -127,7 +127,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV if (isReloadBackgroundView) { LogUtils.d(TAG, "接收到刷新背景视图指令"); // 执行背景刷新逻辑 - App.notifyMessage(TAG, "reloadBackgroundView"); + //App.notifyMessage(TAG, "reloadBackgroundView"); reloadBackgroundView(); } } diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/MainContentView.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/MainContentView.java index 16dceec..481e1ec 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/MainContentView.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/MainContentView.java @@ -154,9 +154,11 @@ public class MainContentView { mainLayout = (RelativeLayout) rootView.findViewById(R.id.activitymainRelativeLayout1); mllBackgroundView = (LinearLayout) rootView.findViewById(R.id.ll_backgroundview); - backgroundView = App.getInstance().getMemoryCachedBackgroundView().getLastInstance(mContext); + backgroundView = App.getInstance().getMemoryCachedBackgroundView(); if (backgroundView == null) { - reloadBackgroundView(); + App.sBackgroundSourceUtils.loadSettings(); + BackgroundBean backgroundBean = App.sBackgroundSourceUtils.getCurrentBackgroundBean(); + backgroundView = App.getInstance().getMemoryCachedBackgroundView().getInstance(mContext, backgroundBean, true); } if (backgroundView.getParent() != null) { ((ViewGroup) backgroundView.getParent()).removeView(backgroundView); @@ -194,11 +196,14 @@ public class MainContentView { if (backgroundView == null) LogUtils.e(TAG, "【bindViews】backgroundView 绑定失败"); LogUtils.d(TAG, "【bindViews】视图绑定完成"); } - - public void reloadBackgroundView(){ - App.sBackgroundSourceUtils.loadSettings(); - BackgroundBean backgroundBean = App.sBackgroundSourceUtils.getCurrentBackgroundBean(); - backgroundView = App.getInstance().getMemoryCachedBackgroundView().getInstance(mContext, backgroundBean, true); + + public void reloadBackgroundView() { + if (backgroundView != null) { + App.sBackgroundSourceUtils.loadSettings(); + BackgroundBean backgroundBean = App.sBackgroundSourceUtils.getCurrentBackgroundBean(); + backgroundView.loadByBackgroundBean(backgroundBean, true); + //App.notifyMessage(TAG, "reloadBackgroundView"); + } } /**