diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 164614260..b597b23f7 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -179,6 +179,9 @@ public class Constants { public static final String CUSTOM_FULL_SERVICE_NOTIFY = "customFullServiceNotify";//全服通知 public static final String XYD_COMPLETE = "XydComplete";//心愿单完成通知 public static final String WISH_LIST_PROGRESS = "wishListProgress";//心愿单进度通知 + public static final String LIVE_VOTE_CREATE="createVote"; + public static final String LIVE_VOTE_UPDATE="updateVote"; + public static final String LIVE_VOTE_END="endVote"; //游戏socket public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 diff --git a/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java b/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java index 1a6af9aa9..34e300886 100644 --- a/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java +++ b/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java @@ -104,12 +104,22 @@ public class EnterRoomInfoModel extends BaseModel { private String anchorGoodnum; @SerializedName("jackpot_level") private String jackpotLevel="-1"; + @SerializedName("live_vote") + private LiveRoomVoteModel voteModel; public String getJackpotLevel() { return jackpotLevel; } + public LiveRoomVoteModel getVoteModel() { + return voteModel; + } + + public void setVoteModel(LiveRoomVoteModel voteModel) { + this.voteModel = voteModel; + } + public EnterRoomInfoModel setJackpotLevel(String jackpotLevel) { this.jackpotLevel = jackpotLevel; return this; diff --git a/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java b/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java index 458f6a9ab..a1baad0a0 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveGiftBean.java @@ -18,7 +18,7 @@ public class LiveGiftBean { // public static final int MARK_LUCK = 3; private int id; - private int type;//0 普通礼物 1是豪华礼物 + private int type;//0 普通礼物 1是贵族 2守护 3粉丝团 private int mark;// 0 普通 1热门 2守护 3幸运 private String name; private String price; diff --git a/common/src/main/java/com/yunbao/common/bean/LiveRoomVoteModel.java b/common/src/main/java/com/yunbao/common/bean/LiveRoomVoteModel.java new file mode 100644 index 000000000..c9de60a77 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/LiveRoomVoteModel.java @@ -0,0 +1,178 @@ +package com.yunbao.common.bean; + +import com.alibaba.fastjson.annotation.JSONField; +import com.google.gson.annotations.SerializedName; +import com.yunbao.common.utils.StringUtil; + +import java.util.List; + +/** + * 主播创建投票 + * { + * "live_vote_id": "20", + * "question_content": "123", + * "vote_end_time": 180, + * "option_content_first_num": 0, + * "option_content_second_num": 0, + * "users_id": [] + * } + */ +public class LiveRoomVoteModel extends BaseModel { + @SerializedName("vote_status") + private int status; + @SerializedName("live_vote_id") + private String voteId; + @SerializedName("question_content") + private String content; + @SerializedName("vote_end_time") + private int time; + @SerializedName("option_content_first_num") + private int answer1Num; + @SerializedName("option_content_second_num") + private int answer2Num; + @SerializedName("users_id") + private List userIds; + @SerializedName("option_content_first") + private String answer1; + @SerializedName("option_content_second") + private String answer2; + @SerializedName("result") + private String result; + @SerializedName("option_text") + private String optionText; + @SerializedName("option_content_key") + private String vote; + + private String liveUid; + + public String getLiveUid() { + return liveUid; + } + + public void setLiveUid(String liveUid) { + this.liveUid = liveUid; + } + + public String getAnswer1() { + return answer1; + } + + public void setAnswer1(String answer1) { + this.answer1 = answer1; + } + + public String getAnswer2() { + return answer2; + } + + public void setAnswer2(String answer2) { + this.answer2 = answer2; + } + + public String getVoteId() { + return voteId; + } + + public void setVoteId(String voteId) { + this.voteId = voteId; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public int getTime() { + return time; + } + + public void setTime(int time) { + this.time = time; + } + + public int getAnswer1Num() { + return answer1Num; + } + + public void setAnswer1Num(int answer1Num) { + this.answer1Num = answer1Num; + } + + public int getAnswer2Num() { + return answer2Num; + } + + public void setAnswer2Num(int answer2Num) { + this.answer2Num = answer2Num; + } + + public List getUserIds() { + return userIds; + } + + public void setUserIds(List userIds) { + this.userIds = userIds; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getOptionText() { + return optionText; + } + + public void setOptionText(String optionText) { + this.optionText = optionText; + } + + @Override + public String toString() { + return "LiveRoomVoteModel{" + + "status=" + status + + ", voteId='" + voteId + '\'' + + ", content='" + content + '\'' + + ", time=" + time + + ", answer1Num=" + answer1Num + + ", answer2Num=" + answer2Num + + ", userIds=" + userIds + + ", answer1='" + answer1 + '\'' + + ", answer2='" + answer2 + '\'' + + ", result='" + result + '\'' + + ", optionText='" + optionText + '\'' + + ", vote='" + vote + '\'' + + ", liveUid='" + liveUid + '\'' + + '}'; + } + + public String getVote() { + return vote; + } + + public void setVote(String vote) { + this.vote = vote; + } + + public boolean isVoteLeft() { + return vote.equals("option_content_first_num"); + } + + public boolean isVote() { + return !StringUtil.isEmpty(vote); + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java index 94503aa4b..c74e3ea45 100644 --- a/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogPopupWindow.java @@ -16,6 +16,9 @@ public abstract class AbsDialogPopupWindow extends BottomPopupView { this.mContext = context; } + /** + * 参考配置 + */ public abstract void buildDialog(XPopup.Builder builder); public abstract int bindLayoutId(); diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 881ebe3f7..deaa05d4e 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -17,6 +17,7 @@ import com.yunbao.common.bean.LinkMicUserBeanV2; import com.yunbao.common.bean.ListInfoMessageModel; import com.yunbao.common.bean.LiveAiRobotBean; import com.yunbao.common.bean.LiveAnchorCallMeModel; +import com.yunbao.common.bean.LiveRoomVoteModel; import com.yunbao.common.bean.LiveAnchorSayModel; import com.yunbao.common.bean.LiveDataInfoModel; import com.yunbao.common.bean.LiveInfoModel; @@ -700,4 +701,25 @@ public interface PDLiveApi { */ @GET("/api/public/?service=Task.userInfoTask") Observable>> userInfoTask(); + + /** + * 创建投票 + */ + @GET("/api/public/?service=Live.createLiveVote") + Observable> createLiveVote(@Query("liveuid") String liveUid, + @Query("question_content") String content, + @Query("option_content_first") String first, + @Query("option_content_second") String second); + + /** + * 更新投票 + */ + @GET("/api/public/?service=Live.setLiveVote") + Observable>> updateLiveVote(@Query("liveuid") String liveUid, + @Query("option_content_key") String key); + /** + * 主动结束投票 + */ + @GET("/api/public/?service=Live.endLiveVote") + Observable>> endLiveVote(@Query("liveuid") String liveUid); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 0eeb08137..e463a017a 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -18,6 +18,7 @@ import com.yunbao.common.bean.LinkMicUserBeanV2; import com.yunbao.common.bean.ListInfoMessageModel; import com.yunbao.common.bean.LiveAiRobotBean; import com.yunbao.common.bean.LiveAnchorCallMeModel; +import com.yunbao.common.bean.LiveRoomVoteModel; import com.yunbao.common.bean.LiveAnchorSayModel; import com.yunbao.common.bean.LiveDataInfoModel; import com.yunbao.common.bean.LiveInfoModel; @@ -1427,6 +1428,78 @@ public class LiveNetManager { }).isDisposed(); } + public void createLiveVote(String liveUid, String content, String first, String second, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .createLiveVote(liveUid, content, first, second) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + + public void updateLiveVote(String liveUid, boolean isLeftVote, HttpCallback callback) { + String key; + if (isLeftVote) {//是左边的投票 + key = "option_content_first_num"; + } else { + key = "option_content_second_num"; + } + API.get().pdLiveApi(mContext) + .updateLiveVote(liveUid, key) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(""); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + + public void endLiveVote(String liveUid, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .endLiveVote(liveUid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getMsg()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + public void userInfoTask(HttpCallback callback) { API.get().pdLiveApi(mContext) .userInfoTask() diff --git a/common/src/main/java/com/yunbao/common/utils/AppManager.java b/common/src/main/java/com/yunbao/common/utils/AppManager.java index 7101d3221..5bda4db57 100644 --- a/common/src/main/java/com/yunbao/common/utils/AppManager.java +++ b/common/src/main/java/com/yunbao/common/utils/AppManager.java @@ -121,7 +121,7 @@ public class AppManager { */ public static void runDebugCode(Runnable runnable) { if (BuildConfig.DEBUG) { - // runnable.run(); + runnable.run(); } } diff --git a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java index 0e40c91ba..347023335 100644 --- a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java +++ b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java @@ -8,7 +8,6 @@ import android.os.Handler; import android.os.Looper; import android.text.InputFilter; import android.text.InputType; -import android.text.Spanned; import android.text.TextUtils; import android.text.format.DateFormat; import android.util.SparseArray; @@ -331,7 +330,7 @@ public class DialogUitl { private Context mContext; private String mTitle; private String mContent; - private String mConfrimString; + private String mConfirmString; private String mCancelString; private boolean mCancelable; private boolean mBackgroundDimEnabled;//显示区域以外是否使用黑色半透明背景 @@ -371,8 +370,8 @@ public class DialogUitl { return this; } - public Builder setConfrimString(String confrimString) { - mConfrimString = confrimString; + public Builder setConfirmString(String confirmString) { + mConfirmString = confirmString; return this; } @@ -460,8 +459,8 @@ public class DialogUitl { content.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mLength)}); } TextView btnConfirm = (TextView) dialog.findViewById(R.id.btn_confirm); - if (!TextUtils.isEmpty(mConfrimString)) { - btnConfirm.setText(mConfrimString); + if (!TextUtils.isEmpty(mConfirmString)) { + btnConfirm.setText(mConfirmString); } TextView btnCancel = (TextView) dialog.findViewById(R.id.btn_cancel); if (!TextUtils.isEmpty(mCancelString)) { diff --git a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java index 6527c7fc4..0bea8f7e9 100644 --- a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java @@ -50,7 +50,7 @@ public class VersionUtil { DialogUitl.Builder builder = new DialogUitl.Builder(context); builder.setTitle(context.getString(R.string.version_update)) .setContent(configBean.getUpdateDes()) - .setConfrimString(context.getString(R.string.version_immediate_use)) + .setConfirmString(context.getString(R.string.version_immediate_use)) .setCancelString(context.getString(R.string.version_not_update)) .setCancelable(false) .setClickCallback(new DialogUitl.SimpleCallback2() { @@ -81,7 +81,7 @@ public class VersionUtil { DialogUitl.Builder builder = new DialogUitl.Builder(context); builder.setTitle(context.getString(R.string.version_update)) .setContent(configBean.getUpdateDes()) - .setConfrimString(context.getString(R.string.version_immediate_use)) + .setConfirmString(context.getString(R.string.version_immediate_use)) .setCancelString(context.getString(R.string.version_not_update)) .setCancelable(false) .setClickCallback(new DialogUitl.SimpleCallback2() { @@ -111,7 +111,7 @@ public class VersionUtil { DialogUitl.Builder builder = new DialogUitl.Builder(context); builder.setTitle(context.getString(R.string.version_update)) .setContent(configBean.getUpdateDes()) - .setConfrimString(context.getString(R.string.version_immediate_use)) + .setConfirmString(context.getString(R.string.version_immediate_use)) .setCancelString(context.getString(R.string.version_not_update)) .setCancelable(false) .setClickCallback(new DialogUitl.SimpleCallback2() { @@ -134,7 +134,7 @@ public class VersionUtil { DialogUitl.Builder builder = new DialogUitl.Builder(context); builder.setTitle(context.getString(R.string.version_update)) .setContent(configBean.getUpdateDes()) - .setConfrimString(context.getString(R.string.version_immediate_use)) + .setConfirmString(context.getString(R.string.version_immediate_use)) .setCancelString(context.getString(R.string.version_not_update)) .setCancelable(false) .setClickCallback(new DialogUitl.SimpleCallback2() { diff --git a/common/src/main/res/layout/dialog_live_new_function.xml b/common/src/main/res/layout/dialog_live_new_function.xml index 7a444507f..8a1234d84 100644 --- a/common/src/main/res/layout/dialog_live_new_function.xml +++ b/common/src/main/res/layout/dialog_live_new_function.xml @@ -246,140 +246,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index 664697b1d..7e64d4ebd 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -872,6 +872,7 @@ Limited ride And limited avatar frame Activity Basic tools Effect settings + Font settings Shield gift effect Shield car effect You are in the current live room @@ -1125,6 +1126,11 @@ Limited ride And limited avatar frame Where is the host doing badly~\nBrother, are you sure you want to unfollow? follow Heat Add + LOW + DEFAULT + HIGH + Select font size + confirm Private chat prompt A private buoy on the side of the broadcast room Dynamic message @@ -1143,5 +1149,22 @@ Limited ride And limited avatar frame Do you want to delete the account After clicking delete, it will take effect immediately and cannot be restored. Are you sure you want to continue? Confirm deletion + This gift is exclusive to the nobility~ + "This gift is exclusive to guardianship~ " + This gift is exclusive to the fan group~ + VIP + Open Guard + Open Fan group + QA + submit + cancel + question: + answer: + Do you want to end this voting early? + Yes + No + VOTE + %s \n box disappears after %s seconds + Please complete the form. 完整填寫領大禮 diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index aac081a1b..aca95a68b 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1144,4 +1144,21 @@ 是否刪除賬號 點擊刪除後即刻生效,且不可恢復,您確認要繼續嗎? 確認刪除 + 該禮物是貴族專屬禮物噢~ + 該禮物是守護專屬禮物噢~ + "該禮物是粉絲團專屬禮物噢~ " + 開通貴族 + 開通守護 + 開通粉絲團 + 發啟問答 + 發啟問答 + 取消 + 問題設置: + 答案設置: + 是否提前結束本次投票? + + + 投票中 + %s \n 問答框%s秒后消失 + 請完整填寫 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index d46e5a539..c41ee0c59 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1143,4 +1143,21 @@ 是否刪除賬號 點擊刪除後即刻生效,且不可恢復,您確認要繼續嗎? 確認刪除 + 該禮物是貴族專屬禮物噢~ + 該禮物是守護專屬禮物噢~ + "該禮物是粉絲團專屬禮物噢~ " + 開通貴族 + 開通守護 + 開通粉絲團 + 發啟問答 + 發啟問答 + 取消 + 問題設置: + 答案設置: + 是否提前結束本次投票? + + + 投票中 + %s \n 問答框%s秒后消失 + 請完整填寫 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 01f3f5c42..855a066ce 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1145,4 +1145,21 @@ 點擊刪除後即刻生效,且不可恢復,您確認要繼續嗎? 確認刪除 完整填寫領大禮 + 該禮物是貴族專屬禮物噢~ + 該禮物是守護專屬禮物噢~ + "該禮物是粉絲團專屬禮物噢~ " + 開通貴族 + 開通守護 + 開通粉絲團 + 發啟問答 + 發啟問答 + 取消 + 問題設置: + 答案設置: + 是否提前結束本次投票? + + + 投票中 + %s \n 問答框%s秒后消失 + 請完整填寫 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 77c57258f..62463aead 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1150,15 +1150,21 @@ Limited ride And limited avatar frame Do you want to delete the account After clicking delete, it will take effect immediately and cannot be restored. Are you sure you want to continue? Confirm deletion - 完整填寫領大禮 - 填寫“*”的選項可完成 - 真愛粉\n頭像框(7天) - 128金豆 - 真愛粉\n勛章(7天) - 男生 - 女生 - 已將獎勵發送至您的背包,請注意查看。 - 離開會讓您失去獎勵,您確認離開嗎? - 愛你,愛你 - 指導下我好嗎 + This gift is exclusive to the nobility~ + This gift is exclusive to guardianship~ + This gift is exclusive to the fan group~ + VIP + Open Guard + Open Fan group + QA + submit + cancel + question: + answer: + Do you want to end this voting early? + Yes + No + VOTE + %s \n box disappears after %s seconds + Please complete the form. diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 877c33374..8b2728324 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1,5 +1,6 @@ package com.yunbao.live.activity; + import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Intent; @@ -47,6 +48,7 @@ import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; +import com.yunbao.common.bean.LiveRoomVoteModel; import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.LiveUserMailBoxModel; import com.yunbao.common.bean.SlideInfoModel; @@ -1047,7 +1049,11 @@ public class LiveAudienceActivity extends LiveActivity { liveFansFragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment"); break; case GUARD: - openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity); + if (event.getObject() == null) { + openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity); + } else { + openNewBuyGuardWindow(true); + } break; case LIVE_WKS://周星榜 String weeklyStarUrl = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" @@ -1332,6 +1338,45 @@ public class LiveAudienceActivity extends LiveActivity { manager.showXydComplete(event.getXydCompleteModel(), event.getLiveReceiveGiftBean()); } break; + case VOTE_CREATE: + case VOTE_UPDATE: + LiveRoomVoteModel voteModel = new LiveRoomVoteModel(); + JSONObject map = (JSONObject) event.getObject(); + 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 { + 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(), "" + voteModel.getOptionText() + ""); + } + manager.mLiveRoomViewHolder.dismissVote(voteModel.getResult(), content); + } catch (Exception e) { + e.printStackTrace(); + } + + break; } diff --git a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java index e4511553d..af28b0cf5 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -46,6 +46,7 @@ import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; +import com.yunbao.share.ui.InvitePopDialog; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -369,6 +370,10 @@ public class ZhuangBanActivity extends AbsActivity { } catch (MalformedURLException e) { e.printStackTrace(); } + }else if (event.getMethod().equals("androidInviteShare")) { + new InvitePopDialog(mContext) + .setUrl(event.getData()) + .showDialog(); } } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index 3022cd9c5..06c2750fe 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -5,6 +5,7 @@ import static com.yunbao.live.bean.LiveChatBean.LUCKY_100_CHECK; import static com.yunbao.live.bean.LiveChatBean.LUCKY_ANGEL; import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import static com.yunbao.live.bean.LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY; +import static com.yunbao.live.bean.LiveChatBean.SYSTEM3_COLOR; import static com.yunbao.live.bean.LiveChatBean.WISH_LIST_PROGRESS; import static com.yunbao.live.bean.LiveChatBean.XYD_COMPLETE; @@ -13,6 +14,7 @@ import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.text.Html; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -47,6 +49,7 @@ import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.SpUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ClipPathCircleImage; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; @@ -82,7 +85,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { private int mPosition; private boolean isBottom = false; - private int fountSize=13; + private int fountSize = 13; public LiveChatAdapter(Context context) { mContext = context; @@ -100,10 +103,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } } }; - if(SpUtil.getInstance().isExists("pd_live_room_fount_size")){ + if (SpUtil.getInstance().isExists("pd_live_room_fount_size")) { try { - fountSize=Integer.parseInt(SpUtil.getStringValue("pd_live_room_fount_size")); - }catch (Exception ignored){ + fountSize = Integer.parseInt(SpUtil.getStringValue("pd_live_room_fount_size")); + } catch (Exception ignored) { } } @@ -173,8 +176,8 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } public void switchFount(int fount) { - fountSize=fount; - SpUtil.setStringValue("pd_live_room_fount_size",fountSize+""); + fountSize = fount; + SpUtil.setStringValue("pd_live_room_fount_size", fountSize + ""); notifyDataSetChanged(); } @@ -198,7 +201,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { class Vh extends RecyclerView.ViewHolder { LinearLayout mBg, view_follow, view_action_game, view_zg, xydComplete; - TextView mTextView, tv_chat_active_into, tv_chat_avtive_name, tv_zg_anchorname, textTxt2,automatic_chat; + TextView mTextView, tv_chat_active_into, tv_chat_avtive_name, tv_zg_anchorname, textTxt2, automatic_chat; RoundedImageView avatar; View v_chat_active_close; RecyclerView rv_chat_active; @@ -477,6 +480,8 @@ public class LiveChatAdapter extends RecyclerView.Adapter { new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1); new LiveTextRender().lucky100(mContext, mTextView, bean.getMsgModel()); } + } else if (bean.getType() == SYSTEM3_COLOR) { + mTextView.setText(Html.fromHtml(bean.getContent())); } else { if (bean.getBubble() != null && !bean.getBubble().equals("")) { //加载.9图聊天气泡 diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java index 82aabb89c..68a9c66ff 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveUserAnchorMailBoxAdapter.java @@ -1,6 +1,5 @@ package com.yunbao.live.adapter; -import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Build; @@ -13,14 +12,11 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.LiveUserMailBoxModel; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.DialogUitl; -import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog; @@ -94,7 +90,7 @@ public class LiveUserAnchorMailBoxAdapter extends RecyclerView.AdapterYYY public static final int XYD_COMPLETE = 207;//心愿单完成通知 public static final int WISH_LIST_PROGRESS = 307;//心愿单进度通知 diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveAnchorCreateQADialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveAnchorCreateQADialog.java new file mode 100644 index 000000000..243f2a568 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveAnchorCreateQADialog.java @@ -0,0 +1,75 @@ +package com.yunbao.live.dialog; + +import android.content.Context; +import android.widget.Button; +import android.widget.EditText; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; +import com.yunbao.live.utils.LiveAnchorVoteManager; + +/** + * 主播创建问答弹框 + */ +public class LiveAnchorCreateQADialog extends AbsDialogPopupWindow { + private EditText question, answer1, answer2; + private Button submit, cancel; + + private String liveUid; + + public LiveAnchorCreateQADialog setLiveUid(String liveUid) { + this.liveUid = liveUid; + return this; + } + + + public LiveAnchorCreateQADialog(@NonNull Context context) { + super(context); + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.dismissOnTouchOutside(false); + builder.autoFocusEditText(false); + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_live_anchor_create_qa; + } + + @Override + protected void onCreate() { + super.onCreate(); + question = findViewById(R.id.edit_question); + answer1 = findViewById(R.id.edit_answer1); + answer2 = findViewById(R.id.edit_answer2); + submit = findViewById(R.id.submit); + cancel = findViewById(R.id.cancel); + cancel.setOnClickListener(v -> dismiss()); + submit.setOnClickListener(v -> { + if (question.getText().toString().trim().length() == 0 || + answer1.getText().toString().trim().length() == 0 || + answer2.getText().toString().trim().length() == 0 + ) { + ToastUtil.show(getContext().getString(R.string.live_anchor_vote_tip)); + return; + } + createVote(question.getText().toString(), answer1.getText().toString(), answer2.getText().toString()); + }); + } + + private void createVote(String question, String answer1, String answer2) { + LiveAnchorVoteManager.getInstance().createVote(liveUid, question, answer1, answer2, (bean, position) -> { + if(position!=0){ + ToastUtil.show(bean.getContent()); + return; + } + dismiss(); + }); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java index 4ccb32f71..feaf72076 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java @@ -45,7 +45,9 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.GiftCacheUtil; import com.yunbao.common.utils.NobleUtil; @@ -59,6 +61,7 @@ import com.yunbao.live.adapter.LiveGiftPagerAdapter; import com.yunbao.live.bean.GiftTopBean; import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.custom.GiftViewPager; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.utils.ToolsButton; @@ -816,6 +819,45 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On isGetNewWrap = true; refreshWrapListAfterSend(); } + } else if (code == 1007 && mLiveGiftBean.getType() != 0) { + hideLianBtn(); + dismiss(); + LiveAudienceEvent.LiveAudienceType type = null; + String confirmString = mContext.getString(R.string.dialog_fount_submit); + String tips = msg; + switch (mLiveGiftBean.getType()) { + case 1: + type = LiveAudienceEvent.LiveAudienceType.NOBLE; + tips = mContext.getString(R.string.dialog_live_gift_noble); + confirmString = mContext.getString(R.string.dialog_live_gift_open_noble); + break; + case 2: + type = LiveAudienceEvent.LiveAudienceType.GUARD; + tips = mContext.getString(R.string.dialog_live_gift_guard); + confirmString = mContext.getString(R.string.dialog_live_gift_open_guard); + break; + case 3: + type = LiveAudienceEvent.LiveAudienceType.FAN_CLUB; + tips = mContext.getString(R.string.dialog_live_gift_fans); + confirmString = mContext.getString(R.string.dialog_live_gift_open_fans); + } + LiveAudienceEvent.LiveAudienceType finalType = type; + new DialogUitl.Builder(mContext) + .setView(R.layout.dialog_live_unfollow) + .setConfirmString(confirmString) + .setContent(tips) + .setClickCallback((dialog, content) -> { + LiveAudienceEvent event = new LiveAudienceEvent() + .setType(finalType); + if (finalType == LiveAudienceEvent.LiveAudienceType.GUARD) { + event = event.setObject(""); + } + Bus.get().post(event); + }).build().show(); + + AppManager.runDebugCode(() -> { + Log.i("gifBean", mLiveGiftBean.toString()); + }); } else { hideLianBtn(); ToastUtil.show(msg); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewFunctionDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewFunctionDialogFragment.java index 12a8fd209..00aca5d9c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveNewFunctionDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewFunctionDialogFragment.java @@ -120,6 +120,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements findViewById(R.id.live_tool_robot).setOnClickListener(this); findViewById(R.id.live_tool_call_me).setOnClickListener(this); findViewById(R.id.live_tool_anchor_say).setOnClickListener(this); + findViewById(R.id.live_tool_qa).setOnClickListener(this); if (leave == 0) { ((ImageView) mLeaveView.findViewById(R.id.live_tool_leave_img)).setImageResource(R.mipmap.icon_leave); @@ -198,7 +199,9 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements new LiveAnchorEditCallMeDialog(mContext).setLiveUid(liveUid).showDialog(); } else if (id == R.id.live_tool_anchor_say) { new LiveAnchorSayPopDialog(mContext).setLiveUid(liveUid).setOnItemClickListener((bean, position) - -> mLiveRoomHandler.postDelayed(()-> ((LiveRyAnchorActivity)(mContext)).mLiveRoomViewHolder.initAnchorSayData(),1000)).showDialog(); + -> mLiveRoomHandler.postDelayed(() -> ((LiveRyAnchorActivity) (mContext)).mLiveRoomViewHolder.initAnchorSayData(), 1000)).showDialog(); + } else if (id == R.id.live_tool_qa) { + new LiveAnchorCreateQADialog(mContext).setLiveUid(liveUid).showDialog(); } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java index b84836937..5f4629551 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java @@ -1,6 +1,5 @@ package com.yunbao.live.dialog; -import android.annotation.SuppressLint; import android.app.Dialog; import android.os.Bundle; import android.text.Html; @@ -35,7 +34,6 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; @@ -438,7 +436,7 @@ public class LiveNewGuardBuyDialogFragment extends AbsDialogFragment implements .setView(R.layout.dialog_live_random_pk) .setTitle(mContext.getString(R.string.dialog_tip)) .setCancelString(mContext.getString(R.string.live_use_discount_no)) - .setConfrimString(mContext.getString(R.string.live_use_discount_yes)) + .setConfirmString(mContext.getString(R.string.live_use_discount_yes)) .setClickCallback(new DialogUitl.SimpleCallback2() { @Override public void onCancelClick() { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 44a868bb7..844af5d14 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -5,8 +5,6 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; -import androidx.core.content.ContextCompat; - import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -46,29 +44,22 @@ import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveReportActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; -import com.yunbao.live.bean.GuardUserBean; -import com.yunbao.live.bean.ImpressBean; import com.yunbao.common.bean.LiveBean; -import com.yunbao.live.custom.MyTextView; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveRoomChangeEvent; -import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.utils.LiveTextRender; -import com.yunbao.live.views.LiveRoomViewHolder; import org.greenrobot.eventbus.EventBus; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import io.rong.imlib.IRongCoreCallback; @@ -534,7 +525,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On if (mFollowing) { DialogUitl.Builder builder = new DialogUitl.Builder(mContext) .setContent(mContext.getString(R.string.unfollow)) - .setConfrimString(mContext.getString(R.string.unfollow_confrim)) + .setConfirmString(mContext.getString(R.string.unfollow_confrim)) .setCancelString(mContext.getString(R.string.unfollow_cancel)) .setView(R.layout.dialog_live_unfollow) .setClickCallback3(new DialogUitl.SimpleCallback3() { diff --git a/live/src/main/java/com/yunbao/live/event/LiveAnchorEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAnchorEvent.java new file mode 100644 index 000000000..5138ce67c --- /dev/null +++ b/live/src/main/java/com/yunbao/live/event/LiveAnchorEvent.java @@ -0,0 +1,295 @@ +package com.yunbao.live.event; + +import com.alibaba.fastjson.JSONArray; +import com.yunbao.common.bean.ActiveModel; +import com.yunbao.common.bean.AiAutomaticSpeechModel; +import com.yunbao.common.bean.AnchorRecommendItemModel; +import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.WishModel; +import com.yunbao.common.bean.XydCompleteModel; +import com.yunbao.common.event.CustomFullServiceNotifyEvent; +import com.yunbao.live.bean.LivePKUserListBean; +import com.yunbao.live.bean.LiveReceiveGiftBean; +import com.yunbao.live.bean.OpenParametersModel; + + +public class LiveAnchorEvent extends BaseModel { + private LiveAnchorType type; + private ActiveModel model = new ActiveModel(); + private String avatar = ""; + private OpenParametersModel parametersModel = new OpenParametersModel(); + private AnchorRecommendItemModel anchorRecommendItemModel = new AnchorRecommendItemModel(); + private int micIng = 0;//连麦状态 + private LiveBean bean; + private Object object; + private int liveType; + private int liveTypeVal; + private MsgModel msgModel;//全服消息 + private AiAutomaticSpeechModel aiAutomaticSpeechModel;//机器人消息 + private boolean voicePress = false; + private boolean isActivity = false;//是否展示趣味活动和增值权益 + private JSONArray pkScores; + private String uid; + private int time; + private CustomFullServiceNotifyEvent customFullServiceNotifyEvent; + private LivePKUserListBean livePKUserListBean; + private String votes; + private String length; + private int nums; + private String uname; + private WishModel wishListProgress; + private XydCompleteModel xydCompleteModel; + private LiveReceiveGiftBean liveReceiveGiftBean; + + public LiveReceiveGiftBean getLiveReceiveGiftBean() { + return liveReceiveGiftBean; + } + + public LiveAnchorEvent setLiveReceiveGiftBean(LiveReceiveGiftBean liveReceiveGiftBean) { + this.liveReceiveGiftBean = liveReceiveGiftBean; + return this; + } + + public XydCompleteModel getXydCompleteModel() { + return xydCompleteModel; + } + + public LiveAnchorEvent setXydCompleteModel(XydCompleteModel xydCompleteModel) { + this.xydCompleteModel = xydCompleteModel; + return this; + } + + public WishModel getWishListProgress() { + return wishListProgress; + } + + public LiveAnchorEvent setWishListProgress(WishModel wishListProgress) { + this.wishListProgress = wishListProgress; + return this; + } + + public String getVotes() { + return votes; + } + + public LiveAnchorEvent setVotes(String votes) { + this.votes = votes; + return this; + } + + public String getLength() { + return length; + } + + public LiveAnchorEvent setLength(String length) { + this.length = length; + return this; + } + + public int getNums() { + return nums; + } + + public LiveAnchorEvent setNums(int nums) { + this.nums = nums; + return this; + } + + public String getUname() { + return uname; + } + + public LiveAnchorEvent setUname(String uname) { + this.uname = uname; + return this; + } + + public LivePKUserListBean getLivePKUserListBean() { + return livePKUserListBean; + } + + public LiveAnchorEvent setLivePKUserListBean(LivePKUserListBean livePKUserListBean) { + this.livePKUserListBean = livePKUserListBean; + return this; + } + + public CustomFullServiceNotifyEvent getCustomFullServiceNotifyEvent() { + return customFullServiceNotifyEvent; + } + + public LiveAnchorEvent setCustomFullServiceNotifyEvent(CustomFullServiceNotifyEvent customFullServiceNotifyEvent) { + this.customFullServiceNotifyEvent = customFullServiceNotifyEvent; + return this; + } + + public JSONArray getPkScores() { + return pkScores; + } + + public LiveAnchorEvent setPkScores(JSONArray pkScores) { + this.pkScores = pkScores; + return this; + } + + public String getUid() { + return uid; + } + + public LiveAnchorEvent setUid(String uid) { + this.uid = uid; + return this; + } + + public int getTime() { + return time; + } + + public LiveAnchorEvent setTime(int time) { + this.time = time; + return this; + } + + public boolean isActivity() { + return isActivity; + } + + public LiveAnchorEvent setActivity(boolean activity) { + isActivity = activity; + return this; + } + + public boolean isVoicePress() { + return voicePress; + } + + public LiveAnchorEvent setVoicePress(boolean voicePress) { + this.voicePress = voicePress; + return this; + } + + public AiAutomaticSpeechModel getAiAutomaticSpeechModel() { + return aiAutomaticSpeechModel; + } + + public LiveAnchorEvent setAiAutomaticSpeechModel(AiAutomaticSpeechModel aiAutomaticSpeechModel) { + this.aiAutomaticSpeechModel = aiAutomaticSpeechModel; + return this; + } + + public MsgModel getMsgModel() { + return msgModel; + } + + public LiveAnchorEvent setMsgModel(MsgModel msgModel) { + this.msgModel = msgModel; + return this; + } + + public int getLiveType() { + return liveType; + } + + public LiveAnchorEvent setLiveType(int liveType) { + this.liveType = liveType; + return this; + } + + public int getLiveTypeVal() { + return liveTypeVal; + } + + public LiveAnchorEvent setLiveTypeVal(int liveTypeVal) { + this.liveTypeVal = liveTypeVal; + return this; + } + + public LiveBean getBean() { + return bean; + } + + public LiveAnchorEvent setBean(LiveBean bean) { + this.bean = bean; + return this; + } + + public int getMicIng() { + return micIng; + } + + public LiveAnchorEvent setMicIng(int micIng) { + this.micIng = micIng; + return this; + } + + public AnchorRecommendItemModel getAnchorRecommendItemModel() { + return anchorRecommendItemModel; + } + + public LiveAnchorEvent setAnchorRecommendItemModel(AnchorRecommendItemModel anchorRecommendItemModel) { + this.anchorRecommendItemModel = anchorRecommendItemModel; + return this; + } + + public OpenParametersModel getParametersModel() { + return parametersModel; + } + + public LiveAnchorEvent setParametersModel(OpenParametersModel parametersModel) { + this.parametersModel = parametersModel; + return this; + } + + public String getAvatar() { + return avatar; + } + + public LiveAnchorEvent setAvatar(String avatar) { + this.avatar = avatar; + return this; + } + + public ActiveModel getModel() { + return model; + } + + public LiveAnchorEvent setModel(ActiveModel model) { + this.model = model; + return this; + } + + public LiveAnchorType getType() { + return type; + } + + public LiveAnchorEvent setType(LiveAnchorType type) { + this.type = type; + return this; + } + + public Object getObject() { + return object; + } + + public LiveAnchorEvent setObject(Object object) { + this.object = object; + return this; + } + + public enum LiveAnchorType { + VOTE_CREATE(1, "创建投票"), + VOTE_ANCHOR_END(2, "投票结束"), + VOTE_ANCHOR_UPDATE(3, "投票结束"); + + + private int type; + private String name; + + LiveAnchorType(int type, String name) { + this.type = type; + this.name = name; + } + + } +} diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index bf09ae1e1..7d72304c6 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -341,7 +341,10 @@ public class LiveAudienceEvent extends BaseModel { WISH_LIST_PROGRESS(61, "心愿单进度"), CLOSE_LIVE_ROOM(62, "关闭直播间"), FONT_SIZE(63, "侧边字号设置"), - LIVE_FONT_SIZE(64, "字号设置"); + LIVE_FONT_SIZE(64, "字号设置"), + VOTE_CREATE(65, "创建投票"), + VOTE_UPDATE(66, "更新投票"), + VOTE_END(67, "投票结束"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index 61c3e5d06..409f79daa 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -54,7 +54,6 @@ import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; @@ -1242,7 +1241,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { "有人向您发起PK请求。
" + "若拒绝PK,将会10分钟内不会再收到任何随机PK请求。" )) - .setConfrimString("接受") + .setConfirmString("接受") .setCancelString("拒絕") .setView(R.layout.dialog_live_random_pk) .setSimpleCallbackView(new DialogUitl.SimpleCallbackView() { diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index f86d0ab75..332c18aa8 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -52,6 +52,7 @@ import com.yunbao.live.bean.LiveGiftPrizePoolWinBean; import com.yunbao.live.bean.LiveLuckGiftWinBean; import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.LiveReceiveGiftBean; +import com.yunbao.live.event.LiveAnchorEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.views.LiveEndViewHolder; import com.yunbao.live.views.LivePlayKsyViewHolder; @@ -72,10 +73,10 @@ import io.rong.imlib.chatroom.base.RongChatRoomClient; public class SocketRyClient { - private final String TAG = "socket"; + private final String TAG = "socket"; private String mLiveUid; private String mStream; - public static SocketRyClient.SocketHandler mSocketHandler; + public static SocketRyClient.SocketHandler mSocketHandler; private Context mContext; public SocketRyClient(String mLiveUid, SocketMessageListener listener, Activity mContext) { @@ -111,11 +112,11 @@ public class SocketRyClient { mSocketHandler = null; } - public class SocketHandler extends Handler { + public class SocketHandler extends Handler { - private SocketMessageListener mListener; + private SocketMessageListener mListener; private LivePushRyViewHolder livePushRyViewHolder; - private String mLiveUid; + private String mLiveUid; public SocketHandler(SocketMessageListener listener) { mListener = new WeakReference<>(listener).get(); @@ -621,11 +622,39 @@ public class SocketRyClient { .setGiftType(map.getInteger("giftId")) .setLuid(conString.toString())).setUname(map.getString("userName")).setLiveType(Integer.parseInt(map.getString("level")))); break; + case Constants.LIVE_VOTE_CREATE: + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.VOTE_CREATE) + .setObject(map) + ); + break; + case Constants.LIVE_VOTE_END: + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.VOTE_END) + .setObject(map) + ); + EventBus.getDefault().post(new LiveAnchorEvent() + .setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END) + .setObject(map) + ); + break; + case Constants.LIVE_VOTE_UPDATE: + //通知给观众 + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.VOTE_UPDATE) + .setObject(map) + ); + //通知给主播 + EventBus.getDefault().post(new LiveAnchorEvent() + .setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE) + .setObject(map) + ); + break; } } - private void buyGuardInSameRoom(JSONObject map) { + private void buyGuardInSameRoom(JSONObject map) { LiveBuyGuardMsgBean buyGuardMsgBean = new LiveBuyGuardMsgBean(); buyGuardMsgBean.setUid(map.getString("uid")); buyGuardMsgBean.setUserName(map.getString("ct")); @@ -635,7 +664,7 @@ public class SocketRyClient { mListener.onBuyGuard(buyGuardMsgBean); } - private void buyGuardByNotify(JSONObject map) { + private void buyGuardByNotify(JSONObject map) { if (mLiveUid.equals(map.getString("liveuid"))) { buyGuardInSameRoom(map); //同一直播间,玩家自己开通,也能看到全服通知 @@ -668,7 +697,7 @@ public class SocketRyClient { } - private void buyZuoJiByNotify(JSONObject map) { + private void buyZuoJiByNotify(JSONObject map) { LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean(); receiveGiftBean.setUserNiceName(map.getString("nickname")); receiveGiftBean.setCarName(map.getString("carname")); @@ -677,7 +706,7 @@ public class SocketRyClient { } - private void buyLiangNameByNotify(JSONObject map) { + private void buyLiangNameByNotify(JSONObject map) { LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean(); receiveGiftBean.setUserNiceName(map.getString("nickname")); receiveGiftBean.setLiangName(map.getString("liangname")); @@ -685,7 +714,7 @@ public class SocketRyClient { mListener.onBuyLiangName(receiveGiftBean); } - private void buyVipByNotify(JSONObject map) { + private void buyVipByNotify(JSONObject map) { LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean(); receiveGiftBean.setUserNiceName(map.getString("nicename")); receiveGiftBean.setVipName(map.getString("ct")); @@ -709,7 +738,7 @@ public class SocketRyClient { mListener.onBuyVip(receiveGiftBean); } - private void sendActiveMsg(JSONObject map, SocketReceiveBean received) { + private void sendActiveMsg(JSONObject map, SocketReceiveBean received) { String msgtype = map.getString("msgtype"); if ("1".equals(msgtype)) {//新年大作战活动 LiveChatBean chatBean = new LiveChatBean(); @@ -900,7 +929,7 @@ public class SocketRyClient { } } - private void xydComplete(JSONObject map) { + private void xydComplete(JSONObject map) { LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean(); receiveGiftBean.setAvatar(map.getString("uhead") + ""); receiveGiftBean.setUserNiceName(map.getString("uname")); @@ -1014,7 +1043,7 @@ public class SocketRyClient { /** * 接收到系统消息,显示在聊天栏中 */ - private void systemChatMessage(String content) { + private void systemChatMessage(String content) { LiveChatBean bean = new LiveChatBean(); bean.setContent(content); bean.setType(LiveChatBean.SYSTEM); @@ -1024,7 +1053,7 @@ public class SocketRyClient { /** * 接收到系统消息,显示在聊天栏中 */ - private void systemChatMessage2(String content) { + private void systemChatMessage2(String content) { LiveChatBean bean = new LiveChatBean(); bean.setContent(content); bean.setType(LiveChatBean.SYSTEM2); @@ -1034,7 +1063,7 @@ public class SocketRyClient { /** * 处理观众与主播连麦逻辑 */ - private void processLinkMic(JSONObject map) { + private void processLinkMic(JSONObject map) { int action = map.getIntValue("action"); switch (action) { case 1://主播收到观众连麦的申请 @@ -1089,7 +1118,7 @@ public class SocketRyClient { * * @param map */ - private void processLinkMicAnchor(JSONObject map) { + private void processLinkMicAnchor(JSONObject map) { int action = map.getIntValue("action"); switch (action) { case 1://收到其他主播连麦的邀请的回调 @@ -1128,7 +1157,7 @@ public class SocketRyClient { * * @param map */ - private void processAnchorLinkMicPk(JSONObject map) { + private void processAnchorLinkMicPk(JSONObject map) { int action = map.getIntValue("action"); Log.i("Socket", "action = " + action + " json = " + map.toString()); diff --git a/live/src/main/java/com/yunbao/live/utils/LiveAnchorVoteManager.java b/live/src/main/java/com/yunbao/live/utils/LiveAnchorVoteManager.java new file mode 100644 index 000000000..8ea230e2a --- /dev/null +++ b/live/src/main/java/com/yunbao/live/utils/LiveAnchorVoteManager.java @@ -0,0 +1,121 @@ +package com.yunbao.live.utils; + +import android.os.Handler; +import android.os.Looper; + +import com.yunbao.common.CommonAppContext; +import com.yunbao.common.bean.LiveRoomVoteModel; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.event.LiveAnchorEvent; + +import org.greenrobot.eventbus.EventBus; + +import java.util.Timer; +import java.util.TimerTask; + +/** + * 主播投票管理器,可以创建投票和手动结束投票 + */ +public class LiveAnchorVoteManager { + private static LiveAnchorVoteManager manager; + private String liveUid; + private boolean isVoting = false; + private LiveRoomVoteModel vote; + private TimerTask task; + + + private LiveAnchorVoteManager() { + } + + + public static LiveAnchorVoteManager getInstance() { + if (manager == null) { + manager = new LiveAnchorVoteManager(); + } + return manager; + } + + + public void createVote(String liveUid, String question, String answer1, String answer2, OnItemClickListener listener) { + if (isVoting) { + return; + } + this.liveUid = liveUid; + LiveNetManager.get(CommonAppContext.getTopActivity()) + .createLiveVote(liveUid, question, answer1, answer2, new HttpCallback() { + @Override + public void onSuccess(LiveRoomVoteModel data) { + data.setAnswer1(answer1); + data.setAnswer2(answer2); + data.setLiveUid(liveUid); + vote = data; + createTimerTask(); + EventBus.getDefault().post(new LiveAnchorEvent() + .setType(LiveAnchorEvent.LiveAnchorType.VOTE_CREATE) + .setObject(data) + ); + listener.onItemClick(vote, 0); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + LiveRoomVoteModel voteModel = new LiveRoomVoteModel(); + voteModel.setContent(error); + listener.onItemClick(voteModel, -1); + } + }); + } + + private void createTimerTask() { + if (isVoting) { + task.cancel(); + } + task = new TimerTask() { + @Override + public void run() { + isVoting = true; + new Handler(Looper.getMainLooper()).post(() -> { + entVote((bean, position) -> { + EventBus.getDefault().post(new LiveAnchorEvent() + .setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END) + .setObject(bean) + ); + }); + }); + } + }; + new Timer().schedule(task, vote.getTime() * 1000L); + + } + + public void entVote(OnItemClickListener msg) { + if (isVoting) { + task.cancel(); + } + LiveNetManager.get(CommonAppContext.getTopActivity()) + .endLiveVote(liveUid, new HttpCallback() { + @Override + public void onSuccess(String data) { + isVoting = false; + msg.onItemClick(data, 0); + } + + @Override + public void onError(String error) { + msg.onItemClick(error, -1); + } + }); + + } + + public void clear() { + if (task != null) { + task.cancel(); + task = null; + } + } +} diff --git a/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java b/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java new file mode 100644 index 000000000..1ed2c70b9 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java @@ -0,0 +1,274 @@ +package com.yunbao.live.utils; + +import android.content.Context; +import android.graphics.Color; +import android.os.Handler; +import android.os.Looper; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.yunbao.common.bean.LiveRoomVoteModel; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; +import com.yunbao.live.activity.LiveRyAnchorActivity; + +import java.util.Timer; +import java.util.TimerTask; + +/** + * 直播间投票控件管理器 + */ +public class LiveRoomVoteManager { + private final Context mContext; + private final View voteLayout; + private final View voteRoot; + private final View mVoteShow; + private final View mClose; + private final ImageView mAnchorVoteHide; + private final boolean isAnchor; + + private final TextView mTitle; + private final TextView mSubmit; + private final TextView mCancel; + private final ProgressBar mProgress; + + + LiveRoomVoteModel createVoteModel; + + public LiveRoomVoteManager(Context mContext, View root) { + this.mContext = mContext; + mAnchorVoteHide = root.findViewById(R.id.vote_hide); + mVoteShow = root.findViewById(R.id.vote_show); + mClose = root.findViewById(R.id.vote_close); + voteLayout = root.findViewById(R.id.vote_layout); + voteRoot = root.findViewById(R.id.live_room_vote); + mTitle = root.findViewById(R.id.title); + mSubmit = root.findViewById(R.id.vote_sub1); + mCancel = root.findViewById(R.id.vote_sub2); + mProgress = root.findViewById(R.id.vote_progress); + mAnchorVoteHide.setOnClickListener(v -> hideAnchorVote()); + mVoteShow.setOnClickListener(v -> hideAnchorVote()); + mClose.setOnClickListener(v -> close()); + if (mContext instanceof LiveRyAnchorActivity) { + isAnchor = true; + } else { + isAnchor = false; + mClose.setVisibility(View.INVISIBLE); + } + hide(); + initClick(); + } + + private void close() { + mTitle.setText(R.string.live_vote_close_title); + mSubmit.setText(R.string.live_vote_close_yes); + mCancel.setText(R.string.live_vote_close_no); + mCancel.setOnClickListener(v -> { + mTitle.setText(createVoteModel.getContent()); + mSubmit.setText(createVoteModel.getAnswer1()); + mCancel.setText(createVoteModel.getAnswer2()); + initClick(); + }); + mSubmit.setOnClickListener(v -> endAnchorVote()); + } + + private void initClick() { + if (isAnchor) { + mCancel.setOnClickListener(null); + mSubmit.setOnClickListener(null); + return; + } + mSubmit.setOnClickListener(v -> updateVote(true)); + mCancel.setOnClickListener(v -> updateVote(false)); + } + + private void updateVote(boolean isSubmit) { + LiveNetManager.get(mContext) + .updateLiveVote(createVoteModel.getLiveUid(), isSubmit, new HttpCallback() { + @Override + public void onSuccess(String data) { + mCancel.setOnClickListener(null); + mSubmit.setOnClickListener(null); + + if (isSubmit) { + mSubmit.setTextColor(Color.parseColor("#FFB800")); + mCancel.setTextColor(Color.parseColor("#999999")); + } else { + mCancel.setTextColor(Color.parseColor("#FFB800")); + mSubmit.setTextColor(Color.parseColor("#999999")); + } + mSubmit.setTag(createVoteModel.getLiveUid()); + + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + + private void endAnchorVote() { + LiveAnchorVoteManager.getInstance().entVote((bean, position) -> { + if (position == -1) { + ToastUtil.show(bean); + return; + } + mClose.setVisibility(View.INVISIBLE); + }); + } + + public void endTimerTask(String msg) { + if (isAnchor) { + LiveAnchorVoteManager.getInstance().clear(); + } + mCancel.setOnClickListener(null); + mSubmit.setOnClickListener(null); + + mSubmit.setText(createVoteModel.getAnswer1()); + mCancel.setText(createVoteModel.getAnswer2()); + + new Timer().schedule(new TimerTask() { + int time = 6; + + @Override + public void run() { + new Handler(Looper.getMainLooper()).post(() -> { + if (--time == 0) { + hide(); + cancel(); + return; + } + mTitle.setText(String.format(mContext.getString(R.string.live_room_vote_over_tip), msg, time + "")); + }); + } + }, 0, 1000); + } + + public void setCreateVoteModel(LiveRoomVoteModel createVoteModel) { + try { + if (createVoteModel.getStatus() == 0) { + hide(); + return; + } + this.createVoteModel = createVoteModel; + mTitle.setText(createVoteModel.getContent()); + mSubmit.setText(createVoteModel.getAnswer1()); + mCancel.setText(createVoteModel.getAnswer2()); + mCancel.setOnClickListener(null); + mSubmit.setOnClickListener(null); + if (mSubmit.getTag() == null || !mSubmit.getTag().equals(createVoteModel.getLiveUid())) { + mSubmit.setTextColor(Color.WHITE); + mCancel.setTextColor(Color.WHITE); + initClick(); + } + if (!StringUtil.isEmpty(createVoteModel.getVote())) { + mCancel.setOnClickListener(null); + mSubmit.setOnClickListener(null); + + if (createVoteModel.isVoteLeft()) { + mSubmit.setTextColor(Color.parseColor("#FFB800")); + mCancel.setTextColor(Color.parseColor("#999999")); + } else { + mCancel.setTextColor(Color.parseColor("#FFB800")); + mSubmit.setTextColor(Color.parseColor("#999999")); + } + mSubmit.setTag(createVoteModel.getLiveUid()); + } + if (createVoteModel.getAnswer1Num() == 0 && createVoteModel.getAnswer2Num() == 0) { + mProgress.setMax(20); + setLength(10); + } else { + mProgress.setMax(createVoteModel.getAnswer1Num() + createVoteModel.getAnswer2Num()); + setLength(createVoteModel.getAnswer1Num()); + } + if(isAnchor){ + mClose.setVisibility(View.VISIBLE); + } + show(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public void setLength(int length) { + length = mProgress.getMax() - length; + mProgress.setProgress(length); + } + + private void hideAnchorVote() { + boolean hide = mAnchorVoteHide.getTag() == null || (boolean) mAnchorVoteHide.getTag(); + Animation animation; + if (hide) { + animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_vote_out); + } else { + animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_vote_in); + } + animation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + if (!hide) { + voteRoot.setVisibility(View.VISIBLE); + mAnchorVoteHide.setVisibility(View.VISIBLE); + mVoteShow.setVisibility(View.GONE); + if (isAnchor) { + mClose.setVisibility(View.VISIBLE); + } + } + } + + @Override + public void onAnimationEnd(Animation animation) { + if (hide) { + voteRoot.setVisibility(View.INVISIBLE); + mAnchorVoteHide.setVisibility(View.GONE); + mVoteShow.setVisibility(View.VISIBLE); + if (isAnchor) { + mClose.setVisibility(View.INVISIBLE); + } + } + mAnchorVoteHide.setTag(!hide); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + voteRoot.startAnimation(animation); + } + + public void setMarginPosition(int position) { + RelativeLayout.LayoutParams voteLayoutParams = (RelativeLayout.LayoutParams) voteLayout.getLayoutParams(); + voteLayoutParams.topMargin = position; + voteLayout.setLayoutParams(voteLayoutParams); + } + + public void show() { + voteLayout.setVisibility(View.VISIBLE); + } + + public void hide() { + 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(); + } + } +} diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java index c8ac7930a..6630f9411 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -46,7 +46,6 @@ import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.common.views.LiveClarityCustomPopup; import com.yunbao.common.views.LiveNewWishListPopup; @@ -62,7 +61,6 @@ import com.yunbao.live.dialog.LiveAnchorSayPopDialog; import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment; import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment; -import com.yunbao.live.dialog.LiveNewWishListDialogFragment; import com.yunbao.live.dialog.LiveTimeDialogFragment; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; @@ -664,7 +662,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl new DialogUitl.Builder(mContext) .setContent(mContext.getString(R.string.live_location_close_3)) .setCancelable(true) - .setConfrimString(mContext.getString(R.string.live_location_close_2)) + .setConfirmString(mContext.getString(R.string.live_location_close_2)) .setClickCallback(new DialogUitl.SimpleCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index b55dfe006..9d6867df3 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -7,25 +7,19 @@ import android.app.Dialog; import android.content.Context; import android.graphics.Color; import android.media.AudioManager; -import android.os.Bundle; import android.os.Handler; import android.os.Looper; -import android.os.SystemClock; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.ui.StyledPlayerView; @@ -35,10 +29,8 @@ import com.lxj.xpopup.core.BasePopupView; import com.lxj.xpopup.interfaces.XPopupCallback; import com.lzf.easyfloat.EasyFloat; import com.lzy.okserver.OkDownload; -import com.yunbao.common.Constants; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.dialog.LiveFontSizeSettingDialog; -import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.interfaces.OnItemClickListener; @@ -50,14 +42,11 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.SpUtil; -import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.LiveClarityCustomPopup; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.utils.LiveExoPlayerManager; @@ -700,7 +689,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { DialogUitl.Builder builder = new DialogUitl.Builder(mContext) .setContent("邀請您進行語音連麥") .setTitle(mLiveBean.getUserNiceName()) - .setConfrimString("接受") + .setConfirmString("接受") .setCancelString("拒絕") .setView(R.layout.dialog_live_mic_invite) .setClickCallback(new DialogUitl.SimpleCallback() { diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java index 24ad829a7..99eff8d70 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java @@ -29,7 +29,6 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -231,7 +230,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick new DialogUitl.Builder(mContext) .setContent(mContext.getString(R.string.live_location_close_3)) .setCancelable(true) - .setConfrimString(mContext.getString(R.string.live_location_close_2)) + .setConfirmString(mContext.getString(R.string.live_location_close_2)) .setClickCallback(new DialogUitl.SimpleCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java index 3d965ee08..4b157a36f 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java @@ -41,7 +41,6 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -255,7 +254,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi new DialogUitl.Builder(mContext) .setContent(mContext.getString(R.string.live_location_close_3)) .setCancelable(true) - .setConfrimString(mContext.getString(R.string.live_location_close_2)) + .setConfirmString(mContext.getString(R.string.live_location_close_2)) .setClickCallback(new DialogUitl.SimpleCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 912fecbe0..536312a86 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -71,6 +71,7 @@ import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveAnchorCallMeModel; +import com.yunbao.common.bean.LiveRoomVoteModel; import com.yunbao.common.bean.LiveAnchorSayModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; @@ -99,6 +100,7 @@ import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.RandomPkManager; +import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DialogUitl; @@ -148,6 +150,7 @@ import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; +import com.yunbao.live.event.LiveAnchorEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpConsts; @@ -157,6 +160,7 @@ import com.yunbao.live.presenter.LiveEnterRoomAnimPresenter; import com.yunbao.live.presenter.LiveGiftAnimPresenter; import com.yunbao.live.presenter.LiveLightAnimPresenter; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; +import com.yunbao.live.utils.LiveRoomVoteManager; import com.yunbao.live.utils.LiveTextRender; import com.yunbao.live.utils.LoadDian9TuUtil; @@ -352,6 +356,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private TextView mAnchorSayText; private ImageView mAnchorSayHide; //----!主播说组件---// + //----投票组件---// + private LiveRoomVoteManager voteManager; + //----!投票组件---// private Banner topBanner1, topBanner2;//心愿单&联系方式 public SVGAImageView svga_new_user_gif, svga_new_user_double, svga_new_user_follow; private String mAnchorName;//主播名字 @@ -996,6 +1003,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }; mRoot = (ViewGroup) findViewById(R.id.root); + voteManager = new LiveRoomVoteManager(mContext, mRoot); mAvatar = (ImageView) findViewById(R.id.avatar); mLevelAnchor = (ImageView) findViewById(R.id.level_anchor); @@ -1085,6 +1093,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams(); msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50); msgLayout.setLayoutParams(msgLayoutLayoutParams); + voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50)); RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) mChatRecyclerView.getLayoutParams(); @@ -1475,6 +1484,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if (!IMLoginManager.get(mContext).hintChat()) { msgLayout.setVisibility(View.VISIBLE); } + AppManager.runDebugCode(() -> msgLayout.setVisibility(View.GONE)); + voteManager.hide(); if (d_pk_view != null) { d_pk_view.setVisibility(View.GONE); } @@ -3106,7 +3117,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if (mContext instanceof LiveAudienceActivity) { int type = 0; GuardUserModel model = new GuardUserModel(); - if (TextUtils.isEmpty(guardUserModel.getGuardType())) { + if (guardUserModel != null && TextUtils.isEmpty(guardUserModel.getGuardType())) { type = Integer.parseInt(guardUserModel.getGuardType()); } if (chatBean.getGuardType() != 0 && chatBean.getGuardType() > type) { @@ -3671,6 +3682,26 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + public void dismissVote(String msg, String data) { + voteManager.endTimerTask(msg); + LiveChatBean bean = new LiveChatBean(); + bean.setType(LiveChatBean.SYSTEM3_COLOR); + bean.setContent(data); + mLiveChatAdapter.insertItem(bean); + } + + public void setVoteData(LiveRoomVoteModel voteModel) { + Log.i("voteModel", voteModel.toString()); + voteModel.setLiveUid(mLiveUid); + if(voteModel.isVote()){ + voteManager.fold(); + }else{ + voteManager.expansion(); + } + voteManager.setCreateVoteModel(voteModel); + } + + private static class LiveRoomHandler extends Handler { private LiveRoomViewHolder mLiveRoomViewHolder; @@ -4234,6 +4265,27 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + @Subscribe(threadMode = ThreadMode.MAIN) + public void updateSubForAnchor(LiveAnchorEvent event) { + if (mContext instanceof LiveAudienceActivity) { + return; + } + if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_CREATE) { + voteManager.setCreateVoteModel((LiveRoomVoteModel) event.getObject()); + } else if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END) { + LiveRoomVoteModel voteModel = JSONObject.parseObject(event.getObject().toString(), LiveRoomVoteModel.class); + Log.i(">>>", voteModel.toString()); + String content = voteModel.getResult(); + if (!StringUtil.isEmpty(voteModel.getOptionText())) { + content = voteModel.getResult().replace(voteModel.getOptionText(), "" + voteModel.getOptionText() + ""); + } + dismissVote(voteModel.getResult(), content); + } else if (event.getType() == LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE) { + LiveRoomVoteModel voteModel = JSONObject.parseObject(event.getObject().toString(), LiveRoomVoteModel.class); + setVoteData(voteModel); + } + } + @Subscribe(threadMode = ThreadMode.MAIN) public void updateSub(LiveAudienceEvent event) { switch (event.getType()) { @@ -4916,6 +4968,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void onBannerClick(List datas, int position) { if (datas.size() > 0) { + if (position >= mTopBannerList.size()) { + position = 0; + } if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) { Dialog loading = DialogUitl.loadingDialog(mContext); loading.show(); @@ -5002,9 +5057,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis call.setType(TopBannerCustomViewHolder.TYPE_CALL_ANCHOR); mTopBannerList.add(0, call); topBanner1.update(mTopBannerList); - if (topBanner2.getVisibility() == View.VISIBLE) { - topBanner2.update(mTopBannerList); - } + topBanner2.update(mTopBannerList); + } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index ec5f3a44d..40aff0c3d 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -269,6 +269,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void run() { + try{ + Log.e("ImgLoader1", data.getAvatar()); if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.clearData(); @@ -364,6 +366,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveLinkMicPresenter.setSocketClient(mSocketClient); } enterRoomNew(); + + }catch (Exception e){ + e.printStackTrace(); + } } }); @@ -497,6 +503,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //初始化顶部banner mLiveRoomViewHolder.initTopBanner(); mLiveRoomViewHolder.updateTopBanner(); + mLiveRoomViewHolder.setVoteData(data.getEnterRoomInfo().getVoteModel()); isattention = Integer.parseInt(data.getEnterRoomInfo().getIsattention()); if (isattention == 0) { diff --git a/live/src/main/res/anim/view_live_anchor_vote_in.xml b/live/src/main/res/anim/view_live_anchor_vote_in.xml new file mode 100644 index 000000000..66653d76e --- /dev/null +++ b/live/src/main/res/anim/view_live_anchor_vote_in.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/live/src/main/res/anim/view_live_anchor_vote_out.xml b/live/src/main/res/anim/view_live_anchor_vote_out.xml new file mode 100644 index 000000000..7cc876eeb --- /dev/null +++ b/live/src/main/res/anim/view_live_anchor_vote_out.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/background_292929.xml b/live/src/main/res/drawable/background_292929.xml new file mode 100644 index 000000000..1d68201b3 --- /dev/null +++ b/live/src/main/res/drawable/background_292929.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/background_cc000.xml b/live/src/main/res/drawable/background_cc000.xml new file mode 100644 index 000000000..a242d6264 --- /dev/null +++ b/live/src/main/res/drawable/background_cc000.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/background_live_vote_cc000.xml b/live/src/main/res/drawable/background_live_vote_cc000.xml new file mode 100644 index 000000000..985c06422 --- /dev/null +++ b/live/src/main/res/drawable/background_live_vote_cc000.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_room_vote_hide.xml b/live/src/main/res/drawable/bg_live_room_vote_hide.xml new file mode 100644 index 000000000..8fc2af891 --- /dev/null +++ b/live/src/main/res/drawable/bg_live_room_vote_hide.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/live_room_qa_progress.xml b/live/src/main/res/drawable/live_room_qa_progress.xml new file mode 100644 index 000000000..586780551 --- /dev/null +++ b/live/src/main/res/drawable/live_room_qa_progress.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_anchor_call_edit_app.xml b/live/src/main/res/layout/dialog_anchor_call_edit_app.xml index 329aea0e5..5002ca0bd 100644 --- a/live/src/main/res/layout/dialog_anchor_call_edit_app.xml +++ b/live/src/main/res/layout/dialog_anchor_call_edit_app.xml @@ -69,7 +69,7 @@ android:layout_marginTop="16dp" android:layout_marginEnd="16dp" android:background="@drawable/bg_live_ready_btn2" - android:text="保存" + android:text="@string/save" android:textColor="@color/white" android:textSize="16sp" app:layout_constraintEnd_toEndOf="parent" diff --git a/live/src/main/res/layout/dialog_live_anchor_create_qa.xml b/live/src/main/res/layout/dialog_live_anchor_create_qa.xml new file mode 100644 index 000000000..a88e63a8c --- /dev/null +++ b/live/src/main/res/layout/dialog_live_anchor_create_qa.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + +