diff --git a/common/src/main/res/values-en/strings.xml b/common/src/main/res/values-en/strings.xml
index 388d67d94..90dc179f1 100644
--- a/common/src/main/res/values-en/strings.xml
+++ b/common/src/main/res/values-en/strings.xml
@@ -909,4 +909,9 @@ Limited ride And limited avatar frame
在線觀眾
觀眾
無法@自己
+ 總星值
+ 助力人數
+ %s星挑战
+ 恭喜 %s,完成了%s %s星 挑戰,快去一睹主播芳容吧!
+ 星
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
index 804b5a6fa..c21bb7b84 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
@@ -31,6 +31,7 @@ import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.KeyBoardHeightChangeListener;
+import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.KeyBoardHeightUtil2;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessImageUtil;
@@ -67,6 +68,7 @@ import com.yunbao.live.dialog.LiveRedPackSendDialogFragment;
import com.yunbao.live.dialog.LiveShareDialogFragment;
import com.yunbao.live.dialog.LiveUserDialogFragment;
import com.yunbao.live.dialog.LiveUserMoreDialogFragment;
+import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
@@ -154,14 +156,14 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mCoinName = CommonAppConfig.getInstance().getCoinName();
mIsAnchor = this instanceof LiveAnchorActivity;
- mPageContainer = findViewById(R.id.page_container);
+ mPageContainer = findViewById(R.id.page_container);
EventBus.getDefault().register(this);
mDialogFragmentSet = new HashSet<>();
//解压 美颜模型
try {
CommonAppConfig.VIDEO_TIE_MODEl_PATH = getFilesDir().getAbsolutePath() + "/model";//app安装路径
File model = new File(CommonAppConfig.VIDEO_TIE_MODEl_PATH);
- if(model.exists()&& Objects.requireNonNull(model.listFiles()).length>0){
+ if (model.exists() && Objects.requireNonNull(model.listFiles()).length > 0) {
return;
}
UnzipFromAssets.unZip(LiveActivity.this, "model-all.zip", CommonAppConfig.VIDEO_TIE_MODEl_PATH, false);
@@ -181,7 +183,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
public ProcessImageUtil getProcessImageUtil() {
- if(mImageUtil==null){
+ if (mImageUtil == null) {
mImageUtil = new ProcessImageUtil(this);
}
return mImageUtil;
@@ -948,7 +950,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
}
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
- SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType,atUserID,atUserName);
+ SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType, atUserID, atUserName);
+
}
/**
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 b943e6dd0..d3c4dec5b 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
@@ -856,6 +856,9 @@ public class LiveAudienceActivity extends LiveActivity {
case STAR_CHALLENGE_UPGRADE_NOTIFY:
manager.starChallengeUpgradeNotify(event.getMsgModel());
break;
+ case MESSAGE_BOTTOM:
+ manager.messageBottom();
+ 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 7185487b0..680ad7734 100644
--- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
@@ -339,8 +339,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
LiveTextRender.aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel());
} else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) {
//加载.9图聊天气泡
- LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1);
- LiveTextRender.starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
+ if (!TextUtils.isEmpty(bean.getMsgModel().getSystemBubble())){
+ LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1);
+ LiveTextRender.starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
+ }
} 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 25843a68d..f6b66a7b1 100644
--- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
+++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
@@ -147,8 +147,8 @@ public class LiveAudienceEvent extends BaseModel {
AT_MESSAGE(24, "@消息"),
START_MESSAGE(25, "星级消息"),
AI_AUTOMATIC_SPEECH(26, "机器人助手"),
- STAR_CHALLENGE_UPGRADE_NOTIFY(27, "星级挑战成功")
- ;
+ STAR_CHALLENGE_UPGRADE_NOTIFY(27, "星级挑战成功"),
+ MESSAGE_BOTTOM(28, "聊天消息滚动到底部");
private int type;
private String name;
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSendBean.java b/live/src/main/java/com/yunbao/live/socket/SocketSendBean.java
index f3f0307dd..ddeef224d 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketSendBean.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketSendBean.java
@@ -1,6 +1,8 @@
package com.yunbao.live.socket;
+import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.L;
+import com.yunbao.live.event.LiveAudienceEvent;
import org.json.JSONArray;
import org.json.JSONException;
@@ -65,6 +67,9 @@ public class SocketSendBean {
e.printStackTrace();
}
L.e("发送socket-->" + mResult.toString());
+ //发消息
+ Bus.get().post(new LiveAudienceEvent()
+ .setType(LiveAudienceEvent.LiveAudienceType.MESSAGE_BOTTOM));//自动滚动到底部
return mResult;
}
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 30c1f95b1..9d07832d3 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
@@ -360,54 +360,74 @@ public class LiveTextRender {
private static void renderTMP(Context context, final TextView textView, final LiveChatBean bean) {
final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
- if (levelBean == null) {
- return;
- }
- ImgLoader.displayDrawable(context, levelBean.getThumb(), new ImgLoader.DrawableCallback() {
- @Override
- public void onLoadSuccess(Drawable drawable) {
- if (textView != null) {
- SpannableStringBuilder builder = createPrefix(drawable, bean);
- int color = 0;
- if (bean.isAnchor()) {
- color = 0xffffdd00;
- } else {
- color = Color.parseColor(levelBean.getColor());
- }
- switch (bean.getType()) {
- case LiveChatBean.GIFT:
- builder = renderGift(color, builder, bean);
- break;
- default:
- builder = renderChat(color, builder, bean);
- break;
- }
- textView.setText(builder);
- }
- }
- @Override
- public void onLoadFailed() {
- if (textView != null) {
- SpannableStringBuilder builder = createPrefix(null, bean);
- int color = 0;
- if (bean.isAnchor()) {
- color = 0xffffdd00;
- } else {
- color = Color.parseColor(levelBean.getColor());
- }
- switch (bean.getType()) {
- case LiveChatBean.GIFT:
- builder = renderGift(color, builder, bean);
- break;
- default:
- builder = renderChat(color, builder, bean);
- break;
- }
- textView.setText(builder);
+ if (levelBean == null) {
+ if (textView != null) {
+ SpannableStringBuilder builder = createPrefix(null, bean);
+ int color = 0xffffdd00;
+
+ switch (bean.getType()) {
+ case LiveChatBean.GIFT:
+ builder = renderGift(color, builder, bean);
+ break;
+ default:
+ builder = renderChat(color, builder, bean);
+ break;
}
+ textView.setText(builder);
}
- });
+ }else {
+ ImgLoader.displayDrawable(context, levelBean.getThumb(), new ImgLoader.DrawableCallback() {
+ @Override
+ public void onLoadSuccess(Drawable drawable) {
+ if (textView != null) {
+ SpannableStringBuilder builder = createPrefix(drawable, bean);
+ int color = 0;
+ if (bean.isAnchor()) {
+ color = 0xffffdd00;
+ } else {
+ try {
+ color = Color.parseColor(levelBean.getColor());
+ } catch (Exception e) {
+ color = Color.parseColor("#ffffff");
+ }
+ }
+ switch (bean.getType()) {
+ case LiveChatBean.GIFT:
+ builder = renderGift(color, builder, bean);
+ break;
+ default:
+ builder = renderChat(color, builder, bean);
+ break;
+ }
+ textView.setText(builder);
+ }
+ }
+
+ @Override
+ public void onLoadFailed() {
+ if (textView != null) {
+ SpannableStringBuilder builder = createPrefix(null, bean);
+ int color = 0;
+ if (bean.isAnchor()) {
+ color = 0xffffdd00;
+ } else {
+ color = Color.parseColor(levelBean.getColor());
+ }
+ switch (bean.getType()) {
+ case LiveChatBean.GIFT:
+ builder = renderGift(color, builder, bean);
+ break;
+ default:
+ builder = renderChat(color, builder, bean);
+ break;
+ }
+ textView.setText(builder);
+ }
+ }
+ });
+ }
+
}
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 c1b360f77..82ed493d9 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -1602,4 +1602,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.starChallengeUpgradeNotify(msgModel);
}
}
+ public void messageBottom(){
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.chatScrollToBottom();
+ }
+ }
}