6_4-互动学堂场景-工具栏
- 1 Feature Overview
- 2 Usage Demo
- 3 API Introduction
- 4 Implementation Overview
- 5 Subdirectory Overview
1 Feature Overview
The toolbar module is one of the basic features of the interactive classroom, divided into instructor view and student view. This module supports setting parameters for tools such as camera, microphone, and pen. The toolbar module enhances classroom interaction, promoting more efficient communication between students and instructors.
2 Usage Demo
The usage of this module is introduced in the PLVHCLiveHiClassActivity interface of the demo as follows.
// 工具栏布局
private IPLVHCToolBarLayout plvhcToolBarLy;
//findView()
plvhcToolBarLy = findViewById(R.id.plvhc_tool_bar_ly);
// 初始化工具栏布局,initView()
plvhcToolBarLy.init(liveRoomDataManager);
// 初始化连麦的媒体配置
boolean isOpenMic = getIntent().getBooleanExtra(EXTRA_IS_OPEN_MIC, true);
boolean isOpenCamera = getIntent().getBooleanExtra(EXTRA_IS_OPEN_CAMERA, true);
boolean isFrontCamera = getIntent().getBooleanExtra(EXTRA_IS_FRONT_CAMERA, true);
//...
plvhcToolBarLy.initDefaultMediaStatus(!isOpenMic, !isOpenCamera, isFrontCamera);
3 API Introduction
In the interactive classroom scenario, IPLVHCToolBarLayout defines the API for the toolbar layout, mainly including:
Methods directly called externally
Interactive event listeners that require external responses
public interface IPLVHCToolBarLayout {
/**
* 初始化
*
* @param liveRoomDataManager 直播间数据管理器
*/
void init(IPLVLiveRoomDataManager liveRoomDataManager);
/**
* 处理图片选择结果
*
* @param data 数据
*/
void handleImgSelectResult(Intent data);
/**
* 设置view交互事件监听器
*
* @param listener 监听器
*/
void setOnViewActionListener(OnViewActionListener listener);
/**
* 初始化默认的媒体状态
*
* @param isMuteAudio 是否禁用麦克风
* @param isMuteVideo 是否禁用摄像头
* @param isFrontCamera 是否是前置摄像头
*/
void initDefaultMediaStatus(boolean isMuteAudio, boolean isMuteVideo, boolean isFrontCamera);
/**
* 课节准备中
*/
void onLessonPreparing(long serverTime, long lessonStartTime);
/**
* 课节开始
*/
void onLessonStarted();
/**
* 课节结束
*/
void onLessonEnd(long inClassTime);
/**
* 调整布局
*/
void adjustLayout();
/**
* 接收用户举手变化
*
* @param raiseHandCount 举手数量
* @param isRaiseHand 是否举手
*/
void acceptUserRaiseHand(int raiseHandCount, boolean isRaiseHand);
/**
* 接收我的画笔权限变化
*
* @param isHasPaint
*/
void acceptHasPaintToMe(boolean isHasPaint);
/**
* 更新标注工具按钮状态
*
* @param showUndoButton 是否显示撤销按钮
* @param showDeleteButton 是否显示删除按钮
*/
void changeMarkToolState(boolean showUndoButton, boolean showDeleteButton);
/**
* 获取成员列表布局的连麦View
*
* @return linkMicView
*/
IPLVMultiRoleLinkMicContract.IMultiRoleLinkMicView getMemberLayoutLinkMicView();
/**
* 获取设置布局的连麦View
*
* @return linkMicView
*/
IPLVMultiRoleLinkMicContract.IMultiRoleLinkMicView getSettingLayoutLinkMicView();
/**
* 是否拦截返回事件
*
* @return true:拦截,false:不拦截
*/
boolean onBackPressed();
/**
* 销毁,释放资源
*/
void destroy();
/**
* view交互事件监听器
*/
interface OnViewActionListener {
/**
* 发送举手事件
*
* @param raiseHandTime 举手时间
*/
void onSendRaiseHandEvent(int raiseHandTime);
/**
* 全屏控制
*
* @param isFullScreen true:全屏,false:退出全屏
*/
void onFullScreenControl(boolean isFullScreen);
/**
* 初始化上课下课按钮后回调
*
* @param classImageView 上下课按钮
*/
void onInitClassImageView(View classImageView);
/**
* 上课
*
* @param listener 监听器
*/
void onStartLesson(IPLVDataRequestListener<String> listener);
/**
* 下课
*
* @param listener 监听器
*/
void onStopLesson(IPLVDataRequestListener<String> listener);
/**
* 切换标注工具
*
* @param newMarkTool 新的工具
*/
void onRequestChangeDocumentMarkTool(PLVHCMarkToolEnums.MarkTool newMarkTool);
/**
* 切换标注工具颜色
*
* @param newColor 新的颜色
*/
void onRequestChangeDocumentColor(PLVHCMarkToolEnums.Color newColor);
/**
* 撤销画笔操作
*/
void onRequestUndo();
/**
* 删除标注内容
*/
void onRequestDelete();
}
}
4 Implementation Overview
Within the PLVHCToolBarLayout toolbar layout, the interface of IPLVHCToolBarLayout is implemented.
The elements included in this layout are: chat room, member list, settings, document management, and other related interface layouts.
The main methods involved in this layout are introduced below.
4.1 View Initialization Method
PLVHCToolBarLayout inherits from FramLayout, and the view is initialized using the initView() method in the constructor.
//构造器
public PLVHCToolBarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView();
}
//initView()方法
private void initView() {
LayoutInflater.from(getContext()).inflate(R.layout.plvhc_toolbar_layout, this);
initChatroomLayout();
initMemberLayout();
initSettingLayout();
initPptListLayout();
}
4.2 Data Initialization Method
Since there are two user types—instructor and student—the user type needs to be determined when initializing data. The method is in the external API. Additionally, the annotation tool control bar layout is initialized here.
//PLVHCToolBarLayout.java
@Override
public void init(IPLVLiveRoomDataManager liveRoomDataManager) {
String userType = liveRoomDataManager.getConfig().getUser().getViewerType();
if (PLVSocketUserConstant.USERTYPE_TEACHER.equals(userType)) {
initTeacherLayout();
} else {
initStudentLayout();
}
chatroomLayout.init(liveRoomDataManager);
//register after init
chatroomLayout.getChatroomPresenter().registerView(memberLayout.getChatroomView());
chatroomLayout.getChatroomPresenter().requestKickUsers();
plvhcToolbarMarkToolControllerLayout.init(liveRoomDataManager);
}
The interface of IPLVHCToolBarLayout is implemented in the external API. Not all are listed here; only a portion is provided as a reference.
//PLVHCToolBarLayout.java
@Override
public void onLessonPreparing(long serverTime, long lessonStartTime) {
if (plvhcToolbarClassIv != null) {
plvhcToolbarClassIv.setSelected(false);
isClassButtonEnable = true;
}
if (plvhcToolbarStudentHandsUpLy != null) {
plvhcToolbarStudentHandsUpLy.setVisibility(View.INVISIBLE);
}
chatroomLayout.onLessonPreparing(serverTime, lessonStartTime);
}
//......
5 Subdirectory Overview
5.1 enums Directory
This directory enumerates some constants used by annotation tools, including annotation tool display, annotation tool types, and annotation tool colors.
| Specific Enum Data | |
|---|---|
| Annotation Tool Display | Hide, Show Annotation Tool List, Show Annotation Tool Colors |
| Annotation Tool Types | Canvas Move Tool, Canvas Selection Tool, Pencil (Freehand Line) Tool, Arrow Tool, Text Tool, Eraser Tool, Clear Screen |
| Annotation Tool Colors | Red, Blue, Green, Yellow, Black, White |
5.2 widget Directory
This is the custom control layout for annotation tools. It includes initialization, display, hiding, and click event responses for annotation tools.
