diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 0978d5b85..a43aa718d 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -205,7 +205,9 @@ public class Constants { public static final String Lucky100Check = "Lucky100Check";//幸运天使 public static final String PrankSendData = "PrankSendData";//整蛊进度 + public static final String SOCKET_SEND_NEW_TASK_PUSH="SendNewTaskPush";//直播间-新用户完成任务push + public static final String SOCKET_SEND_NEW_TASK_IM ="SendNewTaskIM"; //直播间—新用户领取礼物IM public static final int SOCKET_WHAT_CONN = 0; public static final int SOCKET_WHAT_DISCONN = 2; public static final int SOCKET_WHAT_BROADCAST = 1; diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml index 5fe3b1b9b..2ff6b7bd8 100644 --- a/common/src/main/res/values/colors.xml +++ b/common/src/main/res/values/colors.xml @@ -87,4 +87,7 @@ #F4F4F4 #555555 #525252 + + #FFFFBD59 + 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 89382915e..1d4481a2e 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1561,6 +1561,16 @@ public class LiveAudienceActivity extends LiveActivity { manager.setSudName(event.getAvatar(), event.getCreateSudRoomModel()); } break; + case LIVE_AUTHOR_NEW_TASK_PUSH: + if (manager != null) { + manager.setNewTaskPush(event.getUid(),event.getHrefUrl()); + } + break; + case LIVE_AUTHOR_GIFT_PUSH: + if (manager != null) { + manager.setNewTaskIM(event.getUid()); + } + break; } 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 3c739cc9f..faed92ffc 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -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; @@ -19,11 +21,14 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.Html; import android.text.Spannable; +import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; +import android.text.style.AbsoluteSizeSpan; import android.text.style.ForegroundColorSpan; import android.util.Log; +import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -551,6 +556,44 @@ public class LiveChatAdapter extends RecyclerView.Adapter { stringBuffer.append( "【"+bean.getContent()+"】"); mTextView.setText(Html.fromHtml(stringBuffer.toString())); new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); + } else if(bean.getType() == TYPE_TO_TASK_INLET){ + String str = "發送彈幕與主播進行互動吧!完成弹幕互动和点赞任務,还可以领取超多新人豪華禮物哦!活动入口"; + String str_en = "Complete the barrage interaction and like tasks, and you can also receive many new luxury gifts! Event entrance"; + if(WordUtil.isNewZh()){ + SpannableString spannableString = new SpannableString(str); + int start = str.indexOf("活动入口"); + int end = start + "活动入口".length(); + spannableString.setSpan(new ForegroundColorSpan(mContext.getColor(R.color.chat_event_entrance)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + mTextView.setText(spannableString); + }else{ + SpannableString spannableString = new SpannableString(str_en); + int start = str_en.indexOf("Event entrance"); + int end = start + "Event entrance".length(); + spannableString.setSpan(new ForegroundColorSpan(mContext.getColor(R.color.chat_event_entrance)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + mTextView.setText(spannableString); + } + new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); + }else if(bean.getType() == TYPE_TO_TASK_INLET1){ + String str = "您有一份獎勵可領取,點擊此處前往領取禮物吧!"; + String str_en = "You have a reward to claim, click here to claim your gift!"; + if(WordUtil.isNewZh()){ + SpannableString spannableString = new SpannableString(str); + int start = str.indexOf("點擊此處"); + int end = start + "點擊此處".length(); + float size = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, mContext.getResources().getDisplayMetrics()); + spannableString.setSpan(new AbsoluteSizeSpan((int) size), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableString.setSpan(new ForegroundColorSpan(mContext.getColor(R.color.chat_event_entrance)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + mTextView.setText(spannableString); + }else{ + SpannableString spannableString = new SpannableString(str_en); + int start = str_en.indexOf("click here"); + int end = start + "click here".length(); + float size = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, mContext.getResources().getDisplayMetrics()); + spannableString.setSpan(new AbsoluteSizeSpan((int) size), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableString.setSpan(new ForegroundColorSpan(mContext.getColor(R.color.chat_event_entrance)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + mTextView.setText(spannableString); + } + new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); }else{ if (bean.getBubble() != null && !bean.getBubble().equals("")) { //加载.9图聊天气泡 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 470923b0f..d6e8fd86a 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -59,6 +59,16 @@ public class LiveAudienceEvent extends BaseModel { public String mStream; public String mLiveUid, giftId; public SudGameDateModel createSudRoomModel; + private String hrefUrl; + + public String getHrefUrl() { + return hrefUrl; + } + + public LiveAudienceEvent setHrefUrl(String url) { + hrefUrl = url; + return this; + } public SudGameDateModel getCreateSudRoomModel() { return createSudRoomModel; @@ -491,7 +501,9 @@ public class LiveAudienceEvent extends BaseModel { PK_RANK_START(76, "PK排位赛开始"), GuardSpecialEffect(77, "PK排位赛开始"), LIVE_DIALOG_ANCHOR_TIPS(78, "主播公会赛tips"), - LIVE_REMOVE_LIVEUID(79, "主播退出多人PK"); + LIVE_REMOVE_LIVEUID(79, "主播退出多人PK"), + LIVE_AUTHOR_NEW_TASK_PUSH(80, "新人任务完成"), + LIVE_AUTHOR_GIFT_PUSH(81, "新人领取礼物"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java index 4bcc60620..5c43b2bf9 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java @@ -802,6 +802,19 @@ public class SocketSwClient { .setType(LiveAudienceEvent.LiveAudienceType.LIVE_DIALOG_ANCHOR_TIPS) .setObject(WordUtil.isNewZh() ? item.getString("text") : item.getString("text_en"))); + case Constants.SOCKET_SEND_NEW_TASK_PUSH: + item = map.getJSONObject("ct"); + if(CommonAppConfig.getInstance().getUid().equals(item.getString("uid"))){ + 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"); + if(CommonAppConfig.getInstance().getUid().equals(item.getString("uid"))){ + Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_AUTHOR_GIFT_PUSH).setUid(item.getString("uid")).setHrefUrl(item.getString("href"))); + } + break; + } } diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java index 54b00cb34..7d4212813 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java @@ -948,6 +948,10 @@ public class LiveTextRender { } */ + if (bean == null || bean.getContent() == null){ + builder.append("null"); + return builder; + } builder.append(bean.getContent()); //超皇设置渐变色展示昵称 if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getContentColor())) { 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 9e66aeb1d..4b5fb339d 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1,6 +1,8 @@ package com.yunbao.live.views; import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; +import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_TASK_INLET; +import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_TASK_INLET1; import android.animation.ObjectAnimator; import android.app.Activity; @@ -748,11 +750,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis 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 boolean isShowH5Dialog; public void showH5Dialog() { Bundle bundle = new Bundle(); - bundle.putString("url", CommonAppConfig.HOST + "/h5/activity/pdlNewUes/index.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&app_from=PDL"); + bundle.putString("url", CommonAppConfig.HOST + "/h5/activity/pdlNewUes/index.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&app_from=PDLive"); LiveHDDialogFragment fragment = new LiveHDDialogFragment(); fragment.setArguments(bundle); fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); @@ -1817,6 +1833,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if(mContext instanceof LiveSwAnchorActivity){ com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder.closeMenuRed(); } + }else if (bean.getType() == TYPE_TO_TASK_INLET || bean.getType() == TYPE_TO_TASK_INLET1) { + L.e("TYPE_TO_TASK_INLET1=" + bean.getType()); + showH5Dialog(); }else{ showUserDialog(bean.getId()); } @@ -5420,6 +5439,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis RouteUtil.forwardBattlePass(); return; } + if (mBannerList4.get(p).getLink().equals("NewUser") || mBannerList4.get(p).getType() == 999) { + showH5Dialog(); + return; + } + if (TextUtils.equals("特惠首冲", mBannerList4.get(p).getName())) { Map map_ekv = new HashMap(); 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 d53b9d496..85457c53f 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -2285,6 +2285,19 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } } + public void setNewTaskPush(String uid,String url) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.showTaskDetailsNotify1(url); + } + } + + public void setNewTaskIM(String uid) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.showSendGiftTaskIMMsg(); + } + } + + /** * 全服喇叭 *