diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index ef6fc179c..62a343db3 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -54,7 +54,7 @@ public class IMLoginManager extends BaseCacheManager { * @return */ public boolean isSlide() { - return getBoolean(IS_SLIDE, true); + return getBoolean(IS_SLIDE, false); } /** 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 d09ee190c..9897a0683 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -201,9 +201,7 @@ public class LiveAudienceActivity extends LiveActivity { manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal); } else { - if (IMLoginManager.get(mContext).isSlide()){ - verticalViewPager.setEnableScroll(true); - } + verticalViewPager.setEnableScroll(IMLoginManager.get(mContext).isSlide()); mCurrentItem = position; Log.e(TAG, "mCurrentItem:" + mCurrentItem); if (mCurrentItem == itemModelList.size() - 1) { @@ -821,12 +819,10 @@ public class LiveAudienceActivity extends LiveActivity { case SLIDE_SETTINGS: SlideSettingsDialog slideSettingsDialog = new SlideSettingsDialog(); slideSettingsDialog.show(getSupportFragmentManager(), "SlideSettingsDialog"); - slideSettingsDialog.setCallBack(new SlideSettingsDialog.SlideSettingsCallBack() { - @Override - public void initSlide(boolean slide) { - verticalViewPager.setEnableScroll(slide); - } - }); + slideSettingsDialog.setCallBack(slide -> verticalViewPager.setEnableScroll(slide)); + break; + case NEW_MESSAGE_REMINDER: + manager.showNewMessage(); 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 ae7081362..94b82ad37 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -1,5 +1,7 @@ package com.yunbao.live.adapter; +import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; + import android.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; @@ -24,10 +26,13 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DpUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.dialog.LiveHDDialogFragment; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.utils.LiveTextRender; import com.yunbao.live.utils.LoadDian9TuUtil; import com.yunbao.live.views.LiveRoomViewHolder; @@ -37,8 +42,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; - /** * Created by cxf on 2018/10/10. */ @@ -161,8 +164,8 @@ public class LiveChatAdapter extends RecyclerView.Adapter { void setData(final LiveChatBean bean, int position) { itemView.setTag(bean); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - params.setMargins(0, 0, 0, 12); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + params.setMargins(0, 0, DpUtil.dp2px(80), 12); mBg.setLayoutParams(params); if (bean.getType() == 6) {//大作战活动 view_action_game.setVisibility(View.VISIBLE); @@ -359,7 +362,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter { size = size - 1; } } - + //设置最大展示99条消息 + if (size == 100) { + mList.remove(1); + } mList.add(bean); notifyItemChanged(size); @@ -368,7 +374,27 @@ public class LiveChatAdapter extends RecyclerView.Adapter { mList.add(beanNull); notifyItemChanged(size + 1); - mRecyclerView.scrollToPosition(size + 1); + if (isSlideToBottom(mRecyclerView)){ + mRecyclerView.scrollToPosition(size + 1); + }else { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.NEW_MESSAGE_REMINDER)); + } + + } + + /** + * 判断是否滚到底部 + * + * @param recyclerView + * @return + */ + public static boolean isSlideToBottom(RecyclerView recyclerView) { + if (recyclerView == null) return false; + if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() + >= recyclerView.computeVerticalScrollRange()) + return true; + return false; } public void removetItem(LiveChatBean bean) { 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 eee6cca27..f2b80de9a 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -131,7 +131,8 @@ public class LiveAudienceEvent extends BaseModel { ONLINE(19, "在线客服"), TRUMPET_NOTIFY(20, "全服喇叭"), RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知"), - SLIDE_SETTINGS(22, "滑動設置") + SLIDE_SETTINGS(22, "滑動設置"), + NEW_MESSAGE_REMINDER(23, "新消息提醒") ; private int type; 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 f97fc0191..dadfb73c0 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1,5 +1,9 @@ package com.yunbao.live.views; +import static com.yunbao.common.CommonAppContext.logger; +import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; +import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; + import android.app.Activity; import android.app.Dialog; import android.content.Context; @@ -133,6 +137,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; @@ -142,10 +147,6 @@ import io.rong.imlib.model.Conversation; import io.rong.imlib.model.UserInfo; import pl.droidsonroids.gif.GifImageView; -import static com.yunbao.common.CommonAppContext.logger; -import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; -import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; - /** * Created by cxf on 2018/10/9. * 直播间公共逻辑 @@ -204,7 +205,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public static String mNameText; public static String mAvatarUrl; public static FrameLayout ft_hot_add; - public static ImageView img_hot_gif; + public static ImageView img_hot_gif, newMessage; //多人PK static TextView time; @@ -670,9 +671,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mic_view2 = (RelativeLayout) findViewById(R.id.mic_view2); mic_ico = (ImageView) findViewById(R.id.mic_ico); + newMessage = (ImageView) findViewById(R.id.new_message); mic_ico1 = (RoundedImageView) findViewById(R.id.mic_ico1); mic_ico2 = (RoundedImageView) findViewById(R.id.mic_ico2); - + ViewClicksAntiShake.clicksAntiShake(newMessage, () -> { + chatScrollToBottom(); + newMessage.setVisibility(View.GONE); + }); dr_pk_end_gif = (GifImageView) findViewById(R.id.dr_pk_end_gif); msg = (LinearLayout) findViewById(R.id.room_msg); msg2 = (View) findViewById(R.id.room_msg_user); @@ -2624,7 +2629,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void changeFaceUnityView() { // faceUnityView.setVisibility(faceUnityView.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext); - // fragment.setManager(manager); + // fragment.setManager(manager); fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "faceUi"); } @@ -3043,4 +3048,22 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); } + + /** + * 展示新消息提示 + */ + public void showNewMessage() { + Locale locale = mContext.getResources().getConfiguration().locale; + String language = locale.getLanguage(); + ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.new_message_cn : R.mipmap.new_message_en, newMessage); + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) newMessage.getLayoutParams(); + if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { + params1.bottomMargin = DpUtil.dp2px(38); + } else { + params1.bottomMargin = DpUtil.dp2px(8); + } + newMessage.setLayoutParams(params1); + newMessage.setVisibility(View.VISIBLE); + + } } 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 38e573e71..1066b35b3 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -1,5 +1,10 @@ package com.yunbao.live.views; +import static com.yunbao.common.CommonAppContext.logger; +import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; +import static com.yunbao.live.views.LivePlayRyViewHolder.Micing; +import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive; + import android.app.Activity; import android.app.Dialog; import android.content.Intent; @@ -98,11 +103,6 @@ import io.rong.imlib.chatroom.base.RongChatRoomClient; import io.rong.imlib.model.Conversation; import io.rong.message.TextMessage; -import static com.yunbao.common.CommonAppContext.logger; -import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; -import static com.yunbao.live.views.LivePlayRyViewHolder.Micing; -import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive; - /** * 竖屏直播间UI逻辑 */ @@ -240,7 +240,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); //直播间背景 - ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack,400,600); + ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); mask.setVisibility(View.VISIBLE); mLivePlayViewHolder.setCover(data.getThumb()); @@ -1526,4 +1526,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.showFullScreen(msgModel); } + /** + * 展示新消息提示 + */ + public void showNewMessage() { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.showNewMessage(); + } + } } diff --git a/live/src/main/res/layout/item_live_chat.xml b/live/src/main/res/layout/item_live_chat.xml index 05c39f36f..b2fe56b56 100644 --- a/live/src/main/res/layout/item_live_chat.xml +++ b/live/src/main/res/layout/item_live_chat.xml @@ -3,14 +3,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/bg" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="6dp" android:orientation="vertical"> @@ -948,7 +947,6 @@ + android:translationX="500dp" + android:visibility="invisible"> + android:translationX="500dp" + android:visibility="invisible"> + android:translationX="500dp" + android:visibility="invisible"> + android:translationX="500dp" + android:visibility="invisible"> + android:translationX="500dp" + android:visibility="invisible"> + android:translationX="500dp" + android:visibility="invisible"> + +