Polyv Help Center

Help Center

核心common 数据

Updated: 2023-04-17 15:27:57

1 Overview

The data module is located under the polyvLiveCommonModul package of the data module. It includes configuration data, HTTP data, business module data, etc. These data are collectively referred to as live room data and are managed using PLVLiveRoomDataManager.

2 Core Class Introduction

2.1 PLVLiveRoomDataManager

The live room data manager implements the IPLVLiveRoomDataManager interface. It is responsible for calling IPLVLiveRoomDataRequester to retrieve HTTP data, storing HTTP data, configuration data, and shared data across various business modules. Therefore, each business module must hold the same live room data manager object. Usage example:

PLVLCCloudClassActivity

// 直播间数据管理器,每个业务初始化所需的参数
private IPLVLiveRoomDataManager liveRoomDataManager;

private void initLiveRoomManager() {
    // 使用PLVLiveChannelConfigFiller配置好直播参数后,用其创建直播间数据管理器实例
    liveRoomDataManager = new PLVLiveRoomDataManager(PLVLiveChannelConfigFiller.generateNewChannelConfig());

    // 进行网络请求,获取上报观看热度
    liveRoomDataManager.requestPageViewer();

    // 进行网络请求,获取直播详情数据
    liveRoomDataManager.requestChannelDetail();

    // 进行网络请求,获取功能开关数据
    liveRoomDataManager.requestChannelSwitch();
}

2.2 IPLVLiveRoomDataManager

The interface implemented by the live room data manager. It defines:

  1. Retrieving config
  2. Local data retrieval and setting
  3. HTTP interface requests
  4. Destruction
public interface IPLVLiveRoomDataManager {

    // <editor-fold defaultstate="collapsed" desc="1、获取config">

    /**
     * 获取直播频道参数信息
     */
    @NonNull
    PLVLiveChannelConfig getConfig();
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="2、本地数据获取、设置">

    /**
     * 获取观看热度数据liveData
     */
    LiveData<PLVStatefulData<Integer>> getPageViewerData();

    /**
     * 获取直播详情数据LiveData
     */
    LiveData<PLVStatefulData<PolyvLiveClassDetailVO>> getClassDetailVO();

    /**
     * 获取功能开关数据LiveData
     */
    LiveData<PLVStatefulData<PolyvChatFunctionSwitchVO>> getFunctionSwitchVO();

    /**
     * 获取直播商品数据LiveData
     */
    LiveData<PLVStatefulData<PolyvCommodityVO>> getCommodityVO();

    /**
     * 获取直播状态LiveData
     */
    LiveData<PLVStatefulData<PLVLiveRoomDataManager.LiveStatus>> getLiveStatusData();

    /**
     * 获取请求商品接口的rank
     */
    int getCommodityRank();

    /**
     * 设置sessionId
     */
    void setSessionId(String sessionId);

    /**
     * 获取sessionId
     */
    String getSessionId();
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="3、http接口请求">

    /**
     * 上报观看热度
     */
    void requestPageViewer();

    /**
     * 获取直播详情数据
     */
    void requestChannelDetail();

    /**
     * 获取功能开关数据
     */
    void requestChannelSwitch();

    /**
     * 获取商品信息
     */
    void requestProductList();

    /**
     * 获取直播状态
     */
    void requestLiveStatus();

    /**
     * 获取商品信息
     *
     * @param rank 不传排序号会返回列表最前面的数据,传rank后返回rank之后的商品列表。传-1时和不传的结果一致。
     */
    void requestProductList(int rank);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="4、销毁">

    /**
     * 销毁,取消所有的接口请求
     */
    void destroy();
    // </editor-fold>
}
联系客服,在线咨询
在线咨询