新用户观播push,im

This commit is contained in:
Martin 2024-08-24 18:28:46 +08:00
parent 13646d64c7
commit f3945e1b21
9 changed files with 240 additions and 17 deletions

View File

@ -284,6 +284,8 @@ public class Constants {
public static final String SOCKET_SEND_NEW_TASK_PUSH="SendNewTaskPush";//直播间-新用户完成任务push
public static final String SOCKET_SEND_NEW_TASK_IM ="SendNewTaskIM"; //直播间新用户领取礼物IM
//视频举报获取位置
public static int xIndex = 0;
public static int yindex = 0;

View File

@ -1585,6 +1585,11 @@ public class LiveAudienceActivity extends LiveActivity {
manager.setNewTaskPush(event.getUid(),event.getHrefUrl());
}
break;
case LIVE_AUTHOR_GIFT_PUSH:
if (manager != null) {
manager.setNewTaskIM(event.getUid());
}
break;
}

View File

@ -8,6 +8,8 @@ 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.TYPE_TO_ANCHOR_PRANK;
import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_ANCHOR_PRANK_GIFT;
import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_TASK_INLET;
import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_TASK_INLET1;
import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_USER_MSG;
import static com.yunbao.live.bean.LiveChatBean.WISH_LIST_PROGRESS;
import static com.yunbao.live.bean.LiveChatBean.XYD_COMPLETE;
@ -564,7 +566,19 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
stringBuffer.append("<font color='#ECB238'>【" + bean.getContent() + "】</font>");
mTextView.setText(Html.fromHtml(stringBuffer.toString()));
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
} else {
} else if(bean.getType() == TYPE_TO_TASK_INLET){
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("<font color='#ffffff'>" + (WordUtil.isNewZh() ? "發送彈幕與主播進行互動吧!完成弹幕互动和点赞任務,还可以领取超多新人豪華禮物哦" : "Send bullet screens to interact with the anchor! Complete the bullet screen interaction and like tasks, and you can also receive many new luxury gifts!") + "</font>");
stringBuffer.append("<font color='#FFFFBD59'>" + (WordUtil.isNewZh() ? "活動入口" : "Event Entrance") + "</font>");
mTextView.setText(Html.fromHtml(stringBuffer.toString()));
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
}else if(bean.getType() == TYPE_TO_TASK_INLET1){
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("<font color='#ffffff'>" + (WordUtil.isNewZh() ? "您有一份獎勵可領取,點擊此處 前往領取禮物吧!" : "You have a reward to claim, click here to claim your gift!") + "</font>");
stringBuffer.append("<font color='#FFFFBD59'>" + (WordUtil.isNewZh() ? "活動入口" : "Event Entrance") + "</font>");
mTextView.setText(Html.fromHtml(stringBuffer.toString()));
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
}else{
/*avatar_gift_svga.setImageDrawable(null);
ImgLoader.display2(mContext, bean.getAvatar(), msg_avatar);
avatarLayout.setVisibility(View.VISIBLE);

View File

@ -32,6 +32,8 @@ public class LiveChatBean {
public static final int TYPE_TO_USER_MSG = 500;//指定信息
public static final int TYPE_TO_ANCHOR_PRANK = 501;//整蠱-開播提示語
public static final int TYPE_TO_ANCHOR_PRANK_GIFT = 502;//整蠱-禮物
public static final int TYPE_TO_TASK_INLET =503;//任务入口
public static final int TYPE_TO_TASK_INLET1 =504;//任务入口
private String id;
private String userNiceName;

View File

@ -4,6 +4,7 @@ package com.yunbao.live.dialog;
import static com.yunbao.live.views.LiveRoomViewHolder.mLiveUid;
import static com.yunbao.live.views.LiveRoomViewHolder.mStream;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Build;
@ -68,11 +69,17 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
private DialogInterface.OnShowListener listener;
private TextView htmlError;
private boolean isSetHeight = false;
OnDisListener onDisListener;
Dialog dialog;
public LiveHDDialogFragment() {
}
public void setOnDisListener(OnDisListener onDisListener) {
this.onDisListener = onDisListener;
}
/**
* 弹出全屏对话框
*
@ -237,6 +244,15 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
});
}
}
dialog = getDialog();
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if(onDisListener!=null){
onDisListener.onDis();
}
}
});
}
@ -314,6 +330,9 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
@Override
public void onDestroy() {
super.onDestroy();
if(onDisListener!=null){
onDisListener.onDis();
}
//结束webview的加载
mWebView.destroy();
}
@ -379,5 +398,10 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
}
}
public interface OnDisListener{
void onDis();
}
}

View File

@ -502,7 +502,8 @@ public class LiveAudienceEvent extends BaseModel {
GuardSpecialEffect(77, "PK排位赛开始"),
LIVE_DIALOG_ANCHOR_TIPS(78, "主播公会赛tips"),
LIVE_REMOVE_LIVEUID(79, "主播退出多人PK"),
LIVE_AUTHOR_NEW_TASK_PUSH(80, "新人任务完成");
LIVE_AUTHOR_NEW_TASK_PUSH(80, "新人任务完成"),
LIVE_AUTHOR_GIFT_PUSH(81, "新人领取礼物");
private int type;
private String name;

View File

@ -802,6 +802,10 @@ public class SocketSwClient {
item = map.getJSONObject("ct");
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_AUTHOR_NEW_TASK_PUSH).setUid(item.getString("uid")).setHrefUrl(item.getString("href")));
break;
case Constants.SOCKET_SEND_NEW_TASK_IM:
item = map.getJSONObject("ct");
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_AUTHOR_GIFT_PUSH).setUid(item.getString("uid")).setHrefUrl(item.getString("href")));
break;
}
}

View File

@ -7,6 +7,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Outline;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -70,7 +71,6 @@ import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.PrankProgressBean;
import com.yunbao.common.utils.DebugUtils;
import com.yunbao.common.utils.L;
@ -479,6 +479,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private TextView new_task_gift_details1;
private ImageView close_task_receive_close1;
//提醒用户免费礼物
private RelativeLayout new_task_send_gift_notify;
private TextView new_task_send_gift_details;
private ImageView close_task_send_gift_close;
public LiveRoomViewHolder setGuardType(int guardType) {
this.guardType = guardType;
return this;
@ -1044,6 +1049,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
new_task_gift_notify.setLayoutParams(params1);
}
});
new_task_gift_details.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showH5Dialog();
}
});
close_task_receive_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1076,7 +1087,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
animator_first_task_details.start();
}
private Handler firstTaskDetailsHandler1 = new Handler();
private Runnable firstTaskDetailsRunnable1 = new Runnable() {
@Override
@ -1101,9 +1111,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
new_task_gift_details1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ZhuangBanActivity.forward(mContext, url, false, 1);
showH5Dialog();
}
});
close_task_receive_close1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1136,6 +1147,119 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
animator_first_task_details1.start();
}
private Handler sendGiftTaskHandler = new Handler();
private Runnable sendGiftTaskRunnable = new Runnable() {
@Override
public void run() {
if (new_task_send_gift_notify != null) {
animatorSendGiftTask(false);
sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
}
}
};
private ObjectAnimator animator_send_gift_task;
public void showSendGiftTaskDetailsNotify() {
new_task_send_gift_notify.post(new Runnable() {
@Override
public void run() {
LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) new_task_send_gift_notify.getLayoutParams();
params1.width = mChatRecyclerView.getWidth() - DpUtil.dp2px(72);
new_task_send_gift_notify.setLayoutParams(params1);
}
});
new_task_send_gift_details.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳转到免费礼物
((LiveAudienceActivity) mContext).openGiftWindow("", "1");
animatorSendGiftTask(false);
sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
}
});
close_task_send_gift_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animatorSendGiftTask(false);
sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
}
});
sendGiftTaskHandler.removeCallbacks(sendGiftTaskRunnable);
sendGiftTaskHandler.postDelayed(sendGiftTaskRunnable, 10000);
new_task_send_gift_notify.setVisibility(View.VISIBLE);
mDp500 = DpUtil.dp2px(-300);
animatorSendGiftTask(true);
}
public void animatorSendGiftTask(boolean isIn) {
if (isIn) {
animator_send_gift_task = ObjectAnimator.ofFloat(new_task_send_gift_notify, "translationX", mDp500, 0);
animator_send_gift_task.setDuration(800);
} else {
animator_send_gift_task = ObjectAnimator.ofFloat(new_task_send_gift_notify, "translationX", 0, mDp500);
animator_send_gift_task.setDuration(800);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
new_task_send_gift_notify.setVisibility(View.GONE);
}
},1000);
}
animator_send_gift_task.setInterpolator(new LinearInterpolator());
animator_send_gift_task.start();
}
public boolean isShowH5Dialog;
public void showH5Dialog(){
Bundle bundle = new Bundle();
bundle.putString("url", CommonAppConfig.HOST+"/h5/activity/pdlNewUes/index.html?1=1");
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
fragment.setOnDisListener(new LiveHDDialogFragment.OnDisListener() {
@Override
public void onDis() {
startTaskInletTime();
}
});
fragment.setArguments(bundle);
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
//向chatList发送一条活动入口消息
public void showSendGiftTaskMsg() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
LiveChatBean bean = new LiveChatBean();
bean.setType(LiveChatBean.TYPE_TO_TASK_INLET);
mLiveChatAdapter.insertItem(bean);
}
}, 1000);
if (mLiveRoomHandler != null) {
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TASK_INLET_LIVE, getNextTime(1000*300));
}
}
//向chatList发送一条活动入口消息
public void showSendGiftTaskIMMsg() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
LiveChatBean bean = new LiveChatBean();
bean.setType(LiveChatBean.TYPE_TO_TASK_INLET1);
mLiveChatAdapter.insertItem(bean);
}
}, 1000);
}
public void startTaskInletTime(){
if(!isShowH5Dialog){
firstTaskInletNotify();
}
isShowH5Dialog = true;
}
private View sudGameMin;
@ -2163,6 +2287,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
new_task_gift_notify1 = findViewById(R.id.new_task_gift_notify1);
new_task_gift_details1 = findViewById(R.id.new_task_gift_details1);
close_task_receive_close1 = findViewById(R.id.close_task_receive_close1);
new_task_send_gift_notify= findViewById(R.id.new_task_send_gift_notify);
new_task_send_gift_details= findViewById(R.id.new_task_send_gift_details);
close_task_send_gift_close= findViewById(R.id.close_task_send_gift_close);
}
/**
@ -4838,9 +4966,37 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
/**
* 首次进入直播间
*/
public void firstLookLiveNotifty() {
public void firstLookLiveNotify() {
if (mLiveRoomHandler != null) {
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_FIRST_LOOK_LIVE, getNextTime(3000));
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_FIRST_LOOK_LIVE, getNextTime(50000));
}
}
/**
* 首次进入直播间
*/
public void firstLook5MinLiveNotify() {
if (mLiveRoomHandler != null) {
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_LOOK_5_MIN_LIVE, getNextTime(1000*5));
}
}
/**
* 打開活動彈窗
*/
public void firstTaskInletNotify() {
if (mLiveRoomHandler != null) {
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TASK_INLET_LIVE, getNextTime(1000*5));
mLiveRoomHandler.removeMessages(LiveRoomHandler.WHAT_TASK_INLET_LIVE);
}
}
/**
* 打開活動彈窗观看200秒之后
*/
public void firstTaskInlet1Notify() {
if (mLiveRoomHandler != null) {
mLiveRoomHandler.sendEmptyMessageAtTime(LiveRoomHandler.WHAT_TASK_INLET_LIVE, getNextTime(1000*200));
}
}
@ -5175,6 +5331,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private static final int WHAT_ANCHOR_LIGHT = 5;//主播飘心
private static final int WHAT_ANCHOR_CHECK_LIVE = 6;//主播checkLive
private static final int WHAT_FIRST_LOOK_LIVE = 7;//用户首次进入该直播间计时
private static final int WHAT_LOOK_5_MIN_LIVE = 8;//用户首次进入该直播间计时
private static final int WHAT_TASK_INLET_LIVE = 9;//打开活动页
public LiveRoomHandler(LiveRoomViewHolder liveRoomViewHolder) {
mLiveRoomViewHolder = new WeakReference<>(liveRoomViewHolder).get();
@ -5206,6 +5364,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mLiveRoomViewHolder.showTaskDetailsNotify();
}
break;
case WHAT_LOOK_5_MIN_LIVE:
mLiveRoomViewHolder.showSendGiftTaskDetailsNotify();
break;
case WHAT_TASK_INLET_LIVE:
mLiveRoomViewHolder.showSendGiftTaskMsg();
break;
}
}
}
@ -5268,9 +5432,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
showBanner3(bean1);
}
}
}
}
/**

View File

@ -15,7 +15,6 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -28,7 +27,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.enums.ShowPattern;
import com.lzf.easyfloat.permission.PermissionUtils;
import com.lzf.easyfloat.utils.LifecycleUtils;
import com.yunbao.common.event.LiveMsgWindowsCloseEvent;
@ -76,7 +74,6 @@ import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L;
@ -119,7 +116,6 @@ import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.utils.LiveTextRender;
import org.greenrobot.eventbus.EventBus;
@ -911,10 +907,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.initPrankProgress(isShowPrank?1:2);
mLiveRoomViewHolder.setComAll(data.getEnterRoomInfo().getIsComAll().equals("1"));
//检测是否是首次观看该直播间
/*if(data.getEnterRoomInfo().getIsFirstEntry().equals("1")&&data.getEnterRoomInfo().getIsNewUser().equals("1")&&data.getEnterRoomInfo().getIsattention().equals("0")){
mLiveRoomViewHolder.firstLookLiveNotifty();
}*/
mLiveRoomViewHolder.firstLookLiveNotifty();
if(data.getEnterRoomInfo().getIsFirstEntry().equals("1")&&data.getEnterRoomInfo().getIsNewUser().equals("1")&&data.getEnterRoomInfo().getIsattention().equals("0")){
mLiveRoomViewHolder.firstLookLiveNotify();
}
//判断是否有免费礼物
if(data.getNewPeopleTask().getTask().getSendgift().equals("0")){
mLiveRoomViewHolder.firstLook5MinLiveNotify();
}
//观看200秒之后推送活动入口im消息
mLiveRoomViewHolder.firstTaskInlet1Notify();
}
@Override
@ -2325,6 +2326,14 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
public void setNewTaskIM(String uid) {
if (mLiveRoomViewHolder != null) {
if(CommonAppConfig.getInstance().getUid().equals(uid)){
mLiveRoomViewHolder.showSendGiftTaskIMMsg();
}
}
}
/**
* 全服喇叭
*