调整投票展示效果

This commit is contained in:
zlzw 2023-05-18 10:31:52 +08:00
parent 5af061c26f
commit 3454b6f924
2 changed files with 19 additions and 5 deletions

View File

@ -20,6 +20,8 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@ -42,9 +44,11 @@ public class LiveRoomVoteManager {
LiveRoomVoteModel createVoteModel;
private Map<String,Boolean> foldMap;
public LiveRoomVoteManager(Context mContext, View root) {
this.mContext = mContext;
foldMap=new HashMap<>();
mAnchorVoteHide = root.findViewById(R.id.vote_hide);
mVoteShow = root.findViewById(R.id.vote_show);
mClose = root.findViewById(R.id.vote_close);
@ -160,6 +164,15 @@ public class LiveRoomVoteManager {
return;
}
this.createVoteModel = createVoteModel;
if(!createVoteModel.isVote()) {
if (isFold(createVoteModel.getLiveUid())) {
fold();
} else {
expansion();
}
}else {
fold();
}
mTitle.setText(createVoteModel.getContent());
mSubmit.setText(createVoteModel.getAnswer1());
mCancel.setText(createVoteModel.getAnswer2());
@ -209,9 +222,11 @@ public class LiveRoomVoteManager {
boolean hide = mAnchorVoteHide.getTag() == null || (boolean) mAnchorVoteHide.getTag();
Animation animation;
if (hide) {
foldMap.put(createVoteModel.getLiveUid(),true);
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_vote_out);
} else {
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_vote_in);
foldMap.put(createVoteModel.getLiveUid(),false);
}
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
@ -271,4 +286,8 @@ public class LiveRoomVoteManager {
hideAnchorVote();
}
}
public boolean isFold(String mLiveUid) {
return foldMap.containsKey(mLiveUid)&& Boolean.TRUE.equals(foldMap.get(mLiveUid));
}
}

View File

@ -3693,11 +3693,6 @@ 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);
}