完成全服通知功能

This commit is contained in:
18401019693 2022-12-12 14:10:09 +08:00
parent 28add09f32
commit b5247df69b
9 changed files with 223 additions and 34 deletions

View File

@ -174,6 +174,7 @@ public class Constants {
public static final String STAR_CHALLENGE_UPGRADE_NOTIFY = "starChallengeUpgradeNotify";//星级挑战成功
public static final String SUPER_VISION = "supervision";//超级发言警告
public static final String PK_RANK_UPDATE = "RankingRankUpdate";//PK排位赛更新数据
public static final String CUSTOM_FULL_SERVICE_NOTIFY = "customFullServiceNotify";//全服通知
//游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花

View File

@ -0,0 +1,89 @@
package com.yunbao.common.event;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.bean.BaseModel;
/**
* 全服通知
*/
public class CustomFullServiceNotifyEvent extends BaseModel {
@SerializedName("_method_")
private String method;
@SerializedName("action")
private String action;
@SerializedName("content")//内容
private String content;
@SerializedName("duration")//展示时长 单位秒
private int duration;
@SerializedName("img")//图片路径
private String img;
@SerializedName("msgtype")
private String msgtype;
@SerializedName("type")//通知类型 1 图片通知 2文字通知
private int type;
public String getMethod() {
return method;
}
public CustomFullServiceNotifyEvent setMethod(String method) {
this.method = method;
return this;
}
public String getAction() {
return action;
}
public CustomFullServiceNotifyEvent setAction(String action) {
this.action = action;
return this;
}
public String getContent() {
return content;
}
public CustomFullServiceNotifyEvent setContent(String content) {
this.content = content;
return this;
}
public int getDuration() {
return duration;
}
public CustomFullServiceNotifyEvent setDuration(int duration) {
this.duration = duration;
return this;
}
public String getImg() {
return img;
}
public CustomFullServiceNotifyEvent setImg(String img) {
this.img = img;
return this;
}
public String getMsgtype() {
return msgtype;
}
public CustomFullServiceNotifyEvent setMsgtype(String msgtype) {
this.msgtype = msgtype;
return this;
}
public int getType() {
return type;
}
public CustomFullServiceNotifyEvent setType(int type) {
this.type = type;
return this;
}
}

View File

@ -1239,6 +1239,7 @@ public class LiveAudienceActivity extends LiveActivity {
}
break;
}
}

View File

@ -1466,6 +1466,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLivePushViewHolder.changeToBig();
}
break;
}
}

View File

@ -7,6 +7,7 @@ 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.event.CustomFullServiceNotifyEvent;
import com.yunbao.live.bean.OpenParametersModel;
public class LiveAudienceEvent extends BaseModel {
@ -27,6 +28,16 @@ public class LiveAudienceEvent extends BaseModel {
private JSONArray pkScores;
private String uid;
private int time;
private CustomFullServiceNotifyEvent customFullServiceNotifyEvent;
public CustomFullServiceNotifyEvent getCustomFullServiceNotifyEvent() {
return customFullServiceNotifyEvent;
}
public LiveAudienceEvent setCustomFullServiceNotifyEvent(CustomFullServiceNotifyEvent customFullServiceNotifyEvent) {
this.customFullServiceNotifyEvent = customFullServiceNotifyEvent;
return this;
}
public JSONArray getPkScores() {
return pkScores;
@ -230,7 +241,8 @@ public class LiveAudienceEvent extends BaseModel {
LEAVE_DR_ROOM(46, "结束多人PK"),
LEAVE_PK_SCORE(47, "PK排名"),
PK_TIME_COUNT(48, "多人PK结束"),
DISCONNEXT_PK_TIME(50, "单人Pk结束");
DISCONNEXT_PK_TIME(50, "单人Pk结束"),
CUSTOM_FULL_SERVICE_NOTIFY(51, "全服通知");
private int type;
private String name;

View File

@ -30,9 +30,11 @@ import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.SocketModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ToastUtil;
@ -50,7 +52,6 @@ import com.yunbao.live.bean.LiveLuckGiftWinBean;
import com.yunbao.live.bean.LivePKUserListBean;
import com.yunbao.live.bean.LiveReceiveGiftBean;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.live.views.LiveEndViewHolder;
import com.yunbao.live.views.LivePlayKsyViewHolder;
import com.yunbao.live.views.LivePlayRyViewHolder;
@ -428,7 +429,7 @@ public class SocketRyClient {
case Constants.SOCKET_GAME_ZJH://游戏 智勇三张
if (CommonAppConfig.GAME_ENABLE) {
mListener.onGameZjh(map);
}
}
break;
case Constants.SOCKET_GAME_HD://游戏 海盗船长
if (CommonAppConfig.GAME_ENABLE) {
@ -461,7 +462,7 @@ public class SocketRyClient {
LiveChatBean chatBean = new LiveChatBean();
chatBean.setId(jsonObject.getString("uid"));
chatBean.setUserNiceName(jsonObject.getString("user_nicename"));
if ("1" .equals(map.getString("msgtype"))) {
if ("1".equals(map.getString("msgtype"))) {
chatBean.setType(-3);
} else {
chatBean.setType(-4);
@ -559,6 +560,14 @@ public class SocketRyClient {
.setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE)
.setObject(pkRankBean));
break;
case Constants.CUSTOM_FULL_SERVICE_NOTIFY:
Log.e("全服通知", map.toString());
CustomFullServiceNotifyEvent customFullServiceNotifyEvent = GsonUtils.fromJson(map.toString(), CustomFullServiceNotifyEvent.class);
EventBus.getDefault().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.CUSTOM_FULL_SERVICE_NOTIFY)
.setCustomFullServiceNotifyEvent(customFullServiceNotifyEvent));
break;
}
}
@ -648,7 +657,7 @@ public class SocketRyClient {
private static void sendActiveMsg(JSONObject map, SocketReceiveBean received) {
String msgtype = map.getString("msgtype");
if ("1" .equals(msgtype)) {//新年大作战活动
if ("1".equals(msgtype)) {//新年大作战活动
LiveChatBean chatBean = new LiveChatBean();
chatBean.setId(map.getString("uid"));
chatBean.setMedalLevelImageUrl(map.getString("monster_str"));//昵称暂时做为活动图片地址
@ -661,14 +670,14 @@ public class SocketRyClient {
private static void wordLightEnterRoom(JSONObject map, SocketReceiveBean received) {
String msgtype = map.getString("msgtype");
if ("2" .equals(msgtype)) {//发言点亮
if ("409002" .equals(received.getRetcode())) {
if ("2".equals(msgtype)) {//发言点亮
if ("409002".equals(received.getRetcode())) {
ToastUtil.show(R.string.live_you_are_shut);
return;
}
//禁言别人,自己发言只能自己看到
if ("409100" .equals(received.getRetcode())) {
if ("409100".equals(received.getRetcode())) {
String uid = map.getString("uid");
if (!uid.equals(CommonAppConfig.getInstance().getUid())) {
return;
@ -713,12 +722,12 @@ public class SocketRyClient {
e.printStackTrace();
}
if (!"" .equals(map.getString("prankIcon")) && map.getString("prankIcon") != null) {
if (!"".equals(map.getString("prankIcon")) && map.getString("prankIcon") != null) {
chatBean.setPrankIcon(map.getString("prankIcon"));
chatBean.setType(-5);
}
mListener.onChat(chatBean, 1);
} else if ("0" .equals(msgtype)) {//用户进入房间
} else if ("0".equals(msgtype)) {//用户进入房间
JSONObject obj = JSON.parseObject(map.getString("ct"));
LiveUserGiftBean u = GsonUtils.fromJson(obj.toJSONString(), LiveUserGiftBean.class);
UserBean.Vip vip = new UserBean.Vip();
@ -865,7 +874,7 @@ public class SocketRyClient {
chatBean.setMedal_new(map.getString("medal_new"));
chatBean.setGood_nub(map.getString("good_num"));
chatBean.setType(LiveChatBean.GIFT);
if (map.get("guard_type") != null && !"" .equals(map.get("guard_type")) && !"null" .equals(map.get("guard_type"))) {
if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
chatBean.setGuardType(map.getInteger("guard_type"));
}
if (CommonAppContext.lang.equals("chinese")) {

View File

@ -20,6 +20,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
@ -77,6 +78,7 @@ import com.yunbao.common.bean.RewardAllModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.TaskModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.API;
import com.yunbao.common.http.CommonHttpConsts;
@ -86,7 +88,6 @@ import com.yunbao.common.http.live.LiveNetManager;
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.Bus;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl;
@ -97,7 +98,6 @@ import com.yunbao.common.utils.SVGAViewUtils;
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.utils.formatBigNum;
import com.yunbao.common.views.AbsViewHolder;
@ -327,6 +327,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private ViewFlipper flipper;
private TextView mRandomPkTimer;
//全服通知
private ImageView customFullServiceNotify;
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
super(context, parentView);
@ -1064,6 +1066,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
findViewById(R.id.btn_follow).setVisibility(View.GONE);
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
}
customFullServiceNotify = (ImageView) findViewById(R.id.custom_full_service_notify);
reloadIM();
initStarChallengeStatus();
}
@ -1186,14 +1189,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
showBanner2();
}
}
public void setRandomPkTimer(String timer){
if(timer==null){
public void setRandomPkTimer(String timer) {
if (timer == null) {
mRandomPkTimer.setVisibility(View.GONE);
return;
}
mRandomPkTimer.setVisibility(View.VISIBLE);
mRandomPkTimer.setText(timer);
}
private synchronized void showBanner2() {
if (mBannerList2 != null && mBanner2 != null) {
btn_event2.setVisibility(View.VISIBLE);
@ -1794,7 +1799,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_l1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uidL1 != null && !"" .equals(uidL1)) {
if (uidL1 != null && !"".equals(uidL1)) {
showUserDialog(uidL1);
}
}
@ -1802,7 +1807,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_l2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uidL2 != null && !"" .equals(uidL2)) {
if (uidL2 != null && !"".equals(uidL2)) {
showUserDialog(uidL2);
}
}
@ -1810,7 +1815,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_l3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uidL3 != null && !"" .equals(uidL3)) {
if (uidL3 != null && !"".equals(uidL3)) {
showUserDialog(uidL3);
}
}
@ -1818,7 +1823,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_r1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uidR1 != null && !"" .equals(uidR1)) {
if (uidR1 != null && !"".equals(uidR1)) {
showUserDialog(uidR1);
}
}
@ -1826,7 +1831,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_r2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uidR2 != null && !"" .equals(uidR2)) {
if (uidR2 != null && !"".equals(uidR2)) {
showUserDialog(uidR2);
}
}
@ -1834,7 +1839,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
avatar_r3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uidR3 != null && !"" .equals(uidR3)) {
if (uidR3 != null && !"".equals(uidR3)) {
showUserDialog(uidR3);
}
}
@ -3031,7 +3036,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
if ("1" .equals(info[0])) {
if ("1".equals(info[0])) {
ft_hot_add.setVisibility(View.VISIBLE);
} else {
ft_hot_add.setVisibility(View.GONE);
@ -3046,7 +3051,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
*/
public static void getIsHot(String isUseHotCard) {
ImgLoader.display2(Contexts, "https://downs.yaoulive.com/img_hot_gif.gif", img_hot_gif);
if ("1" .equals(isUseHotCard)) {
if ("1".equals(isUseHotCard)) {
ft_hot_add.setVisibility(View.VISIBLE);
} else {
ft_hot_add.setVisibility(View.GONE);
@ -3344,7 +3349,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (bean.getActivityId() == 0) {
openWebDialog(bean.getLink());
} else {
LiveGameDialogFragment fragment = new LiveGameDialogFragment("1" .equals(bean.getShow_type()));
LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type()));
fragment.setActivityId(bean.getActivityId());
fragment.setRoomId(mLiveUid);
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment");
@ -3395,7 +3400,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
nowTime = time;
tv_trickery_time.setText("" + nowTime);
openType = 0;
if ("1" .equals(msgtype)) {
if ("1".equals(msgtype)) {
nums = jsonObject.getString("nums");
prankid = jsonObject.getString("prankid");
content = jsonObject.getString("content");
@ -3559,21 +3564,21 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUpdata(String str) {
if ("svga_new_user_gif" .equals(str)) {
if ("svga_new_user_gif".equals(str)) {
if (fastMsgRecyclerView == null) return;
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
fastMsgRecyclerView.getLayoutParams();
params1.rightMargin = DeviceUtils.getScreenWidth((Activity) mContext) / 3;
fastMsgRecyclerView.setLayoutParams(params1);
} else if ("stop_svga_new_user_gif" .equals(str)) {
} else if ("stop_svga_new_user_gif".equals(str)) {
if (fastMsgRecyclerView == null) return;
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
fastMsgRecyclerView.getLayoutParams();
params1.rightMargin = 0;
fastMsgRecyclerView.setLayoutParams(params1);
} else if ("showBanner" .equals(str)) {
} else if ("showBanner".equals(str)) {
showBanner3(bean1);
} else if ("stop_svga_new_user_double" .equals(str) && mBannerList3.size() > 2) {
} else if ("stop_svga_new_user_double".equals(str) && mBannerList3.size() > 2) {
mBannerList3.get(2).setLink("1");
mBanner3.update(mBannerList3);
@ -3584,7 +3589,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
}
}
} else if ("stop_svga_new_user_follow" .equals(str) && mBannerList3.size() > 1) {
} else if ("stop_svga_new_user_follow".equals(str) && mBannerList3.size() > 1) {
mBannerList3.get(1).setLink("1");
mBanner3.update(mBannerList3);
@ -3595,7 +3600,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
}
}
} else if ("stop_new_user_gif" .equals(str) && mBannerList3.size() > 0) {
} else if ("stop_new_user_gif".equals(str) && mBannerList3.size() > 0) {
IMLoginManager.get(mContext).setNewUserGif(false);
mBannerList3.get(0).setLink("1");
mBanner3.update(mBannerList3);
@ -3783,7 +3788,69 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
case PK_TWO_END:
closePkTwo();
break;
case CUSTOM_FULL_SERVICE_NOTIFY:
customFullServiceNotify(event.getCustomFullServiceNotifyEvent());
break;
}
}
/**
* 全服通知
*
* @param customFullServiceNotifyEvent
*/
private void customFullServiceNotify(CustomFullServiceNotifyEvent customFullServiceNotifyEvent) {
if (customFullServiceNotifyEvent.getType() == 1) {
int duration = customFullServiceNotifyEvent.getDuration();
int handlerDuration = 0;
if (duration > 2) {
inAlphaAnimation.setDuration(1000);
outAlphaAnimation.setDuration(1000);
handlerDuration = duration - 2;
} else {
inAlphaAnimation.setDuration(500);
outAlphaAnimation.setDuration(500);
handlerDuration = duration - 1;
}
customFullServiceNotify.startAnimation(inAlphaAnimation);
customFullServiceNotify.setVisibility(View.VISIBLE);
ImgLoader.display(mContext,customFullServiceNotifyEvent.getImg(),customFullServiceNotify);
customFullHandler.postDelayed(customFullRunnable, handlerDuration * 1000);
} else {//文字通知
}
}
//渐出动画
private AlphaAnimation inAlphaAnimation = new AlphaAnimation(0, 1);
private AlphaAnimation outAlphaAnimation = new AlphaAnimation(1, 0);
private Handler customFullHandler = new Handler();
private Runnable customFullRunnable = new Runnable() {
@Override
public void run() {
customFullServiceNotify.startAnimation(outAlphaAnimation);
//这个地方为什么要做动画的监听呢因为隐藏和显示不一样
//必须在动画结束之后再隐藏你的控件这样才不会显得很突兀
outAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
customFullServiceNotify.setVisibility(View.GONE);
customFullHandler.removeCallbacks(customFullRunnable);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
};
}

View File

@ -40,6 +40,7 @@ import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.event.CustomFullServiceNotifyEvent;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.event.LiveFloatEvent;
import com.yunbao.common.glide.ImgLoader;
@ -1738,4 +1739,5 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.endDRGif();
}
}
}

View File

@ -634,8 +634,8 @@
android:gravity="center"
android:text="@string/random_pk_info_btn_ing"
android:textColor="#FFFFFF"
android:visibility="gone"
android:textSize="10sp" />
android:textSize="10sp"
android:visibility="gone" />
<LinearLayout
android:id="@+id/goto_room_view"
@ -2296,9 +2296,16 @@
android:id="@+id/dr_pk_end_gif"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginTop="160dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="160dp"
android:src="@mipmap/drpkend"
android:visibility="gone" />
<ImageView
android:id="@+id/custom_full_service_notify"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:visibility="gone" />
</RelativeLayout>