Package io.rong.imkit.config
See: Description
-
Interface Summary Interface Description 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);OnSendMessageListener DataProcessor ConversationClickListener SSLInterceptor ConversationListBehaviorListener 会话列表界面操作的监听器。 -
Class Summary Class Description IMKitThemeManager 融云主题管理器 用于管理融云 IM SDK 的主题切换和资源适配,支持多主题动态切换。 - 内置主题:提供传统主题和欢快主题,欢快主题自动跟随系统深浅色模式
- 自定义主题:支持开发者扩展和注册自定义主题,支持深浅色模式和主题叠加
- 系统跟随:自动跟随系统深浅色模式切换(欢快主题及自定义主题)
- 动态资源:提供动态资源获取方法,根据当前主题和深浅色模式自动选择合适的资源
- 自动应用:通过 Activity 生命周期回调自动应用主题到所有页面
- 主题监听:支持监听主题切换事件,方便进行自定义处理
AppCompatDelegate.setDefaultNightMode(nightMode)来设置应用的深浅色模式, 这样可以保证深浅色模式的及时切换。// 在 Application 的 onCreate 中设置 // 跟随系统 AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); // 或强制使用浅色模式 AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); // 或强制使用深色模式 AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);// 1. 切换到欢快主题(自动跟随系统深浅色) IMKitThemeManager.changeInnerTheme(context, IMKitThemeManager.LIVELY_THEME); // 2. 切换到传统主题 IMKitThemeManager.changeInnerTheme(context, IMKitThemeManager.TRADITION_THEME); // 3. 添加自定义主题(支持深浅色模式) IMKitThemeManager.addTheme("CUSTOM_THEME", R.style.MyCustomLightTheme, // 浅色模式样式 R.style.MyCustomDarkTheme // 深色模式样式 ); // 4. 切换到自定义主题(基于欢快主题) IMKitThemeManager.changeCustomTheme(context, "CUSTOM_THEME", IMKitThemeManager.LIVELY_THEME); // 5. 在代码中动态获取主题资源 int bgResId = IMKitThemeManager.dynamicResource( context, R.attr.rc_conversation_bg, // 主题属性 R.drawable.rc_old_bg // 默认资源 ); view.setBackgroundResource(bgResId); // 6. 获取当前主题 String currentTheme = IMKitThemeManager.getCurrentThemeName(); // 7. 判断当前主题类型 if (IMKitThemeManager.TRADITION_THEME.equals(currentTheme)) { // 传统主题 }RongConfigCenter SDK 配置入口。 应用可以通过该类更改各页面的配置。 注意:需要在 init() 之前调用。 GatheredConversationConfig ConversationListConfig DefaultConversationListProcessor BaseDataProcessor FeatureConfig ConversationConfig 会话页面总配置项