提交主播投票功能
This commit is contained in:
parent
df0f5f31e0
commit
82b3b23470
@ -1,5 +1,6 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
@ -166,8 +167,12 @@ public class LiveRoomVoteModel extends BaseModel {
|
||||
public void setVote(String vote) {
|
||||
this.vote = vote;
|
||||
}
|
||||
public boolean isVoteLeft(){
|
||||
|
||||
public boolean isVoteLeft() {
|
||||
return vote.equals("option_content_first_num");
|
||||
}
|
||||
|
||||
public boolean isVote() {
|
||||
return !StringUtil.isEmpty(vote);
|
||||
}
|
||||
}
|
||||
|
@ -1337,22 +1337,36 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
break;
|
||||
case VOTE_CREATE:
|
||||
case VOTE_UPDATE:
|
||||
LiveRoomVoteModel voteModel = new LiveRoomVoteModel();
|
||||
JSONObject map = (JSONObject) event.getObject();
|
||||
manager.mLiveRoomViewHolder.setVoteData(
|
||||
map.getString("question"),
|
||||
map.getString("answer1"),
|
||||
map.getString("answer2"),
|
||||
map.getString("num1"),
|
||||
map.getString("num2")
|
||||
);
|
||||
try {
|
||||
voteModel.setStatus(1);
|
||||
voteModel.setLiveUid(mLiveUid);
|
||||
voteModel.setContent(map.getString("question"));
|
||||
voteModel.setAnswer1(map.getString("answer1"));
|
||||
voteModel.setAnswer2(map.getString("answer2"));
|
||||
voteModel.setAnswer1Num(map.getInteger("num1"));
|
||||
voteModel.setAnswer2Num(map.getInteger("num2"));
|
||||
manager.mLiveRoomViewHolder.setVoteData(voteModel);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
case VOTE_END:
|
||||
try {
|
||||
LiveRoomVoteModel voteModel = JSONObject.parseObject(event.getObject().toString(), LiveRoomVoteModel.class);
|
||||
voteModel = new LiveRoomVoteModel();
|
||||
map = (JSONObject) event.getObject();
|
||||
voteModel.setStatus(map.getInteger("status"));
|
||||
voteModel.setContent(map.getString("question"));
|
||||
voteModel.setAnswer1(map.getString("answer1"));
|
||||
voteModel.setAnswer2(map.getString("answer2"));
|
||||
voteModel.setAnswer1Num(map.getInteger("num1"));
|
||||
voteModel.setAnswer2Num(map.getInteger("num2"));
|
||||
System.out.println(">>>" + voteModel);
|
||||
String content = voteModel.getResult();
|
||||
if (!StringUtil.isEmpty(voteModel.getOptionText())) {
|
||||
content =voteModel.getResult().replace(voteModel.getOptionText(), "<font color='#FF8E43'>" + voteModel.getOptionText() + "</font>");
|
||||
content = voteModel.getResult().replace(voteModel.getOptionText(), "<font color='#FF8E43'>" + voteModel.getOptionText() + "</font>");
|
||||
}
|
||||
manager.mLiveRoomViewHolder.dismissVote(voteModel.getResult(), content);
|
||||
} catch (Exception e) {
|
||||
|
@ -82,6 +82,8 @@ public class LiveRoomVoteManager {
|
||||
|
||||
private void initClick() {
|
||||
if (isAnchor) {
|
||||
mCancel.setOnClickListener(null);
|
||||
mSubmit.setOnClickListener(null);
|
||||
return;
|
||||
}
|
||||
mSubmit.setOnClickListener(v -> updateVote(true));
|
||||
@ -188,6 +190,9 @@ public class LiveRoomVoteManager {
|
||||
mProgress.setMax(createVoteModel.getAnswer1Num() + createVoteModel.getAnswer2Num());
|
||||
setLength(createVoteModel.getAnswer1Num());
|
||||
}
|
||||
if(isAnchor){
|
||||
mClose.setVisibility(View.VISIBLE);
|
||||
}
|
||||
show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -256,4 +261,14 @@ public class LiveRoomVoteManager {
|
||||
voteLayout.setVisibility(View.GONE);
|
||||
mSubmit.setTag(null);
|
||||
}
|
||||
public void fold(){
|
||||
if(mVoteShow.getVisibility()!=View.VISIBLE){
|
||||
hideAnchorVote();
|
||||
}
|
||||
}
|
||||
public void expansion(){
|
||||
if(mVoteShow.getVisibility()==View.VISIBLE){
|
||||
hideAnchorVote();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1519,7 +1519,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
enterRoomLeave.setVisibility(View.GONE);
|
||||
topBanner1.setVisibility(View.GONE);
|
||||
topBanner2.setVisibility(View.GONE);
|
||||
|
||||
topBanner1.update(mTopBannerList);
|
||||
topBanner2.update(mTopBannerList);
|
||||
removeDetailView();
|
||||
}
|
||||
|
||||
@ -3680,24 +3681,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
}
|
||||
}
|
||||
|
||||
public void setVoteData(String question, String answer1, String answer2, String num1, String num2) {
|
||||
try {
|
||||
LiveRoomVoteModel voteModel = new LiveRoomVoteModel();
|
||||
voteModel.setStatus(1);
|
||||
voteModel.setContent(question);
|
||||
voteModel.setAnswer1(answer1);
|
||||
voteModel.setAnswer2(answer2);
|
||||
voteModel.setAnswer1Num(Integer.parseInt(num1));
|
||||
voteModel.setAnswer2Num(Integer.parseInt(num2));
|
||||
voteModel.setLiveUid(mLiveUid);
|
||||
Log.i("voteManager", voteManager.toString());
|
||||
voteManager.setCreateVoteModel(voteModel);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void dismissVote(String msg, String data) {
|
||||
voteManager.endTimerTask(msg);
|
||||
LiveChatBean bean = new LiveChatBean();
|
||||
@ -3709,6 +3692,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
public void setVoteData(LiveRoomVoteModel voteModel) {
|
||||
Log.i("voteModel", voteModel.toString());
|
||||
voteModel.setLiveUid(mLiveUid);
|
||||
if(voteModel.isVote()){
|
||||
voteManager.fold();
|
||||
}else{
|
||||
voteManager.expansion();
|
||||
}
|
||||
voteManager.setCreateVoteModel(voteModel);
|
||||
}
|
||||
|
||||
@ -4292,14 +4280,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
}
|
||||
dismissVote(voteModel.getResult(), content);
|
||||
} else if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE) {
|
||||
JSONObject map = (JSONObject) event.getObject();
|
||||
setVoteData(
|
||||
map.getString("question"),
|
||||
map.getString("answer1"),
|
||||
map.getString("answer2"),
|
||||
map.getString("num1"),
|
||||
map.getString("num2")
|
||||
);
|
||||
LiveRoomVoteModel voteModel = JSONObject.parseObject(event.getObject().toString(), LiveRoomVoteModel.class);
|
||||
setVoteData(voteModel);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user