|
|
## 点赞组件
|
|
|
|
|
|
|
|
|
|
|
|
### 版本历史
|
|
|
|
|
|
| 版本号 | 更新时间 | 更新描述 |
|
|
|
| ------ | -------- | -------- |
|
|
|
| 1.0.0 | 2022.4.2 | 组件上线 |
|
|
|
| | | |
|
|
|
|
|
|
|
|
|
|
|
|
### 组件引入
|
|
|
|
|
|
注意:所有使用互动组件必须要引入basemodule库,最新版本见 [互动组件对接文档](互动组件/互动组件对接文档)
|
|
|
|
|
|
项目根目录build.gradle引入:
|
|
|
|
|
|
```groovy
|
|
|
repositories {
|
|
|
maven { url 'http://nexus-app.bokecc.com/repository/sdk-group/' }
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
module的build.gradle引入:
|
|
|
|
|
|
```java
|
|
|
dependencies {
|
|
|
api ('com.bokecc:basemodule:x.x.x')
|
|
|
api ('com.bokecc.module:likemodule:x.x.x')
|
|
|
}
|
|
|
```
|
|
|
|
|
|
Application的onCreate方法中,调用`DWLiveEngine.init`初始化dwlivesdk后,添加代码:
|
|
|
|
|
|
```java
|
|
|
LikeInteractSDK.getInstance().init(app);
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 1. 结构图
|
|
|
|
|
|
![结构图](like.png)
|
|
|
|
|
|
|
|
|
|
|
|
## 基础库引入
|
|
|
|
|
|
注意:所有使用互动组件必须要引入modelbase库
|
|
|
|
|
|
项目根目录gradle引入
|
|
|
|
|
|
```groovy
|
|
|
repositories {
|
|
|
maven { url 'http://nexus-app.bokecc.com/repository/sdk-group/' }
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
项目的model.gradle引入
|
|
|
|
|
|
```java
|
|
|
dependencies {
|
|
|
api ('com.bokecc.module:likemodule:1.0.0')
|
|
|
}
|
|
|
```
|
|
|
|
|
|
Application添加代码
|
|
|
|
|
|
```java
|
|
|
//该api不占用应用启动时间
|
|
|
LikeInteractSDK.getInstance().init(app);
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 对外参数说明
|
|
|
|
|
|
#### 对外API
|
|
|
|
|
|
```java
|
|
|
/**
|
|
|
* 点赞模块的管理器
|
|
|
*/
|
|
|
public interface LikeManager {
|
|
|
/**
|
|
|
* 初始化点赞模块
|
|
|
* @param likeListener 点赞的回调监听
|
|
|
* @param userId 用户id
|
|
|
* @param roomId 房间id
|
|
|
* @param interactToken 互动组件token
|
|
|
*/
|
|
|
void init(LikeListener likeListener, String userId, String roomId, String interactToken);
|
|
|
|
|
|
/**
|
|
|
* 发送点赞 注意内部已做防抖2s的操作
|
|
|
* @param count 点赞数量
|
|
|
* @param sendLikeCallBack 点赞回调
|
|
|
*/
|
|
|
void sendLike(int count, SendLikeCallBack sendLikeCallBack);
|
|
|
|
|
|
/**
|
|
|
* 重连
|
|
|
*/
|
|
|
void reConnect();
|
|
|
|
|
|
/**
|
|
|
* 释放
|
|
|
*/
|
|
|
void release();
|
|
|
}
|
|
|
```
|
|
|
#### 对外回调
|
|
|
```java
|
|
|
public abstract class LikeListener {
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 初始化失败
|
|
|
*/
|
|
|
public abstract void onInitFailure();
|
|
|
|
|
|
/**
|
|
|
* 初始化成功
|
|
|
*
|
|
|
* @param likeConfig 点赞的配置
|
|
|
*/
|
|
|
public abstract void onInitSuccess(LikeConfig likeConfig);
|
|
|
|
|
|
/**
|
|
|
* 收到点赞消息
|
|
|
* @param like
|
|
|
*/
|
|
|
public abstract void onLike(Like like);
|
|
|
|
|
|
/**
|
|
|
* 点赞模块连接失败
|
|
|
*/
|
|
|
public abstract void onConnectFailure();
|
|
|
|
|
|
/**
|
|
|
* 点赞pusher连接成功
|
|
|
*/
|
|
|
public void onConnect() {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
public interface SendLikeCallBack {
|
|
|
/**
|
|
|
* 发送成功
|
|
|
*/
|
|
|
void onSuccess();
|
|
|
|
|
|
/**
|
|
|
* 发送点赞失败
|
|
|
* @param count 发送点赞失败的点赞数
|
|
|
*/
|
|
|
void onFailure(int count);
|
|
|
}
|
|
|
```
|
|
|
#### 参数说明
|
|
|
```java
|
|
|
public class LikeConfig {
|
|
|
|
|
|
/**
|
|
|
* 基础倍数
|
|
|
*/
|
|
|
public int basicTimes;
|
|
|
|
|
|
/**
|
|
|
* 当前点赞总数
|
|
|
*/
|
|
|
public int currentNumbers;
|
|
|
}
|
|
|
public class Like {
|
|
|
//点赞的总数
|
|
|
private long likeSum;
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |