Interface IMKitThemeManager.OnThemeListener

  • All Implemented Interfaces:

    
    public interface IMKitThemeManager.OnThemeListener
    
                        

    主题变化监听器接口

    用于监听主题切换事件,当主题发生变化时会收到回调通知。

    使用示例:

    // 创建监听器
    OnThemeListener listener = new OnThemeListener() {
        @Override
        public void onThemeChanged(Context context, String oldTheme, String newTheme) {
            Log.d("Theme", "主题从 " + oldTheme + " 切换到 " + newTheme);
            // 可以直接使用传入的 context,无需自己持有引用
            if (context instanceof Activity) {
                ((Activity) context).recreate(); // 重建 Activity 应用新主题
            }
        }
    };
    
    // 添加监听器
    IMKitThemeManager.addThemeListener(listener);
    
    // 不需要时移除监听器(避免内存泄漏)
    IMKitThemeManager.removeThemeListener(listener);
    
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract void onThemeChanged(Context context, String oldTheme, String newTheme) 主题变化回调
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • onThemeChanged

         abstract void onThemeChanged(Context context, String oldTheme, String newTheme)

        主题变化回调

        Parameters:
        context - 上下文(通常是调用主题切换方法时传入的 Context)
        oldTheme - 旧主题标识(如 TRADITION_THEME、LIVELY_THEME 或自定义主题名称)
        newTheme - 新主题标识(如 TRADITION_THEME、LIVELY_THEME 或自定义主题名称)