add:直播间新增私信悬浮窗

update:会话页面适配半屏模式
This commit is contained in:
zlzw 2022-09-05 16:49:10 +08:00
parent b5cfb5abc1
commit 5bcbe7cd9a
22 changed files with 542 additions and 38 deletions

View File

@ -40,12 +40,15 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage; import io.rong.message.TextMessage;
import io.rong.push.RongPushClient; import io.rong.push.RongPushClient;
import io.rong.push.pushconfig.PushConfig; import io.rong.push.pushconfig.PushConfig;
import static com.yunbao.live.socket.SocketClient.mSocketHandler; import static com.yunbao.live.socket.SocketClient.mSocketHandler;
import org.greenrobot.eventbus.EventBus;
//import cn.tillusory.sdk.TiSDK; //import cn.tillusory.sdk.TiSDK;
//import com.squareup.leakcanary.LeakCanary; //import com.squareup.leakcanary.LeakCanary;
@ -185,6 +188,8 @@ public class AppContext extends CommonAppContext {
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) { if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg); SocketRyClient.mSocketHandler.sendMessage(msg);
} }
}else if(message.getConversationType()== Conversation.ConversationType.PRIVATE){//私聊信息
EventBus.getDefault().post(message);
} }
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -2,6 +2,7 @@ package com.yunbao.common.activity;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Rect; import android.graphics.Rect;
@ -52,11 +53,14 @@ public abstract class AbsActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
isFullWindow=getIntent().getBooleanExtra("isFull",false); Intent intent=getIntent();
if(isFullWindow){ if(intent!=null) {
isFullWindow = getIntent().getBooleanExtra("isFull", false);
if (isFullWindow) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
} }
}
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mTag = this.getClass().getSimpleName(); mTag = this.getClass().getSimpleName();
setStatusBar(); setStatusBar();

View File

@ -85,6 +85,7 @@
android:name=".activity.PDLiveConversationActivity" android:name=".activity.PDLiveConversationActivity"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/DialogNotTitleActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"/> android:windowSoftInputMode="stateAlwaysHidden|adjustResize"/>
<activity <activity
android:name=".activity.PDLIiveChatActivity" android:name=".activity.PDLIiveChatActivity"

View File

@ -910,7 +910,16 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 打开私信列表窗口 * 打开私信列表窗口
*/ */
public void openChatListWindow() { public void openChatListWindow() {
openChatListWindow(new Bundle());
}
/**
* 打开私信列表窗口
* @param bundle 配置参数
*/
public void openChatListWindow(Bundle bundle) {
Intent intent = new Intent(mContext, PDLIiveChatActivity.class); Intent intent = new Intent(mContext, PDLIiveChatActivity.class);
intent.putExtras(bundle);
mContext.startActivity(intent); mContext.startActivity(intent);
} }

View File

@ -0,0 +1,54 @@
package com.yunbao.live.activity;
import android.os.Bundle;
import android.view.View;
import io.rong.common.RLog;
import io.rong.imkit.config.ConversationListBehaviorListener;
import io.rong.imkit.config.RongConfigCenter;
import io.rong.imkit.conversationlist.ConversationListFragment;
import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imkit.conversationlist.model.GatheredConversation;
import io.rong.imkit.utils.RouteUtils;
import io.rong.imkit.widget.adapter.ViewHolder;
/**
* 会话界面需要配置参数复写onItemClick给view这是bundle的tag在会话界面可以获取该bundle
*/
public class MyConversationListFragment extends ConversationListFragment {
private final String TAG = ConversationListFragment.class.getSimpleName();
private Bundle bundle=new Bundle();
public void setBundle(Bundle bundle) {
this.bundle = bundle;
}
@Override
public void onItemClick(View view, ViewHolder holder, int position) {
if (position >= 0) {
BaseUiConversation baseUiConversation = (BaseUiConversation)this.mAdapter.getItem(position);
ConversationListBehaviorListener listBehaviorListener = RongConfigCenter.conversationListConfig().getListener();
view.setTag(bundle);
if (listBehaviorListener != null && listBehaviorListener.onConversationClick(view.getContext(), view, baseUiConversation)) {
RLog.d(this.TAG, "ConversationList item click event has been intercepted by App.");
} else {
if (baseUiConversation != null && baseUiConversation.mCore != null) {
if (baseUiConversation instanceof GatheredConversation) {
RouteUtils.routeToSubConversationListActivity(view.getContext(),
((GatheredConversation)baseUiConversation).mGatheredType,
baseUiConversation.mCore.getConversationTitle());
} else {
RouteUtils.routeToConversationActivity(view.getContext(),
baseUiConversation.mCore.getConversationType(),
baseUiConversation.mCore.getTargetId(),bundle);
}
} else {
RLog.e(this.TAG, "invalid conversation.");
}
}
view.setTag(null);
}
}
}

View File

@ -1,5 +1,6 @@
package com.yunbao.live.activity; package com.yunbao.live.activity;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
@ -25,12 +26,14 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.InstructorRemarkManager; import com.yunbao.common.manager.InstructorRemarkManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.adapter.SystemChatMessageAdapter; import com.yunbao.live.adapter.SystemChatMessageAdapter;
import com.yunbao.live.bean.ImUserBean; import com.yunbao.live.bean.ImUserBean;
import com.yunbao.live.bean.SearchUserBean; import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.http.ImHttpUtil;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -43,9 +46,11 @@ import io.rong.imlib.model.UserInfo;
* 直播页面聊天列表 * 直播页面聊天列表
*/ */
public class PDLIiveChatActivity extends FragmentActivity { public class PDLIiveChatActivity extends FragmentActivity {
private ConversationListFragment conversationListFragment; private MyConversationListFragment conversationListFragment;
private FrameLayout container; private FrameLayout container;
private PDLIiveChatActivity mContext; private PDLIiveChatActivity mContext;
private boolean isGetSystemMsg=true;//是否展示系统消息默认为true
private boolean isDialogWindow=false;//是否为半屏展示默认为false
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -53,6 +58,14 @@ public class PDLIiveChatActivity extends FragmentActivity {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_pd_chat); setContentView(R.layout.activity_pd_chat);
mContext = this; mContext = this;
Intent intent = getIntent();
if(intent!=null) {
isGetSystemMsg =intent.getBooleanExtra("systemMsg",true);
isDialogWindow =intent.getBooleanExtra("dialogWindow",false);
}else{
isGetSystemMsg=true;
isDialogWindow=false;
}
windowColor(); windowColor();
initView(); initView();
initData(); initData();
@ -91,6 +104,7 @@ public class PDLIiveChatActivity extends FragmentActivity {
private void initData() { private void initData() {
IMLoginManager.get(mContext).checkInstructor(); IMLoginManager.get(mContext).checkInstructor();
//获取系统消息列表 //获取系统消息列表
if(isGetSystemMsg) {
ImHttpUtil.getImUserInfo("", new HttpCallback() { ImHttpUtil.getImUserInfo("", new HttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
@ -105,6 +119,9 @@ public class PDLIiveChatActivity extends FragmentActivity {
} }
} }
}); });
}else{
addSystemMessagesView(new ArrayList<>());
}
//刷新列表内用户信息 //刷新列表内用户信息
addUserInfoProvider(); addUserInfoProvider();
@ -121,7 +138,10 @@ public class PDLIiveChatActivity extends FragmentActivity {
//倒序展示 //倒序展示
Collections.reverse(listUserBean); Collections.reverse(listUserBean);
//展示会话列表 //展示会话列表
conversationListFragment = new ConversationListFragment(); conversationListFragment = new MyConversationListFragment();
Bundle bundle=new Bundle();
bundle.putBoolean("dialogWindow",isDialogWindow);
conversationListFragment.setBundle(bundle);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction(); FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.container, conversationListFragment); transaction.replace(R.id.container, conversationListFragment);

View File

@ -6,10 +6,15 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
@ -32,7 +37,7 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NoviceInstructorManager; import com.yunbao.common.manager.NoviceInstructorManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.bean.SearchUserBean; import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.dialog.MenuPopuwWindow; import com.yunbao.live.dialog.MenuPopuwWindow;
@ -48,16 +53,10 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList; import java.util.ArrayList;
import io.rong.imkit.IMCenter; import io.rong.imkit.IMCenter;
import io.rong.imkit.model.ResultCallback;
import io.rong.imkit.userinfo.RongUserInfoManager; import io.rong.imkit.userinfo.RongUserInfoManager;
import io.rong.imkit.userinfo.UserDataProvider;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.UserInfo; import io.rong.imlib.model.UserInfo;
import okhttp3.internal.http2.ErrorCode;
import static com.yunbao.common.CommonAppContext.logger;
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
/** /**
* 聊天会话界面 * 聊天会话界面
@ -74,6 +73,8 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
private final int SELECT_IMAGE_REQUEST = 0x0001; private final int SELECT_IMAGE_REQUEST = 0x0001;
private ArrayList<ImageEntity> mSelectImages = new ArrayList<>(); private ArrayList<ImageEntity> mSelectImages = new ArrayList<>();
private String targetId = ""; private String targetId = "";
private LinearLayout mRootLayout;
private boolean isDialogWindow=true;
@Override @Override
@ -87,6 +88,11 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
mContext = this; mContext = this;
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Intent intent = getIntent();
if(intent!=null){
isDialogWindow=intent.getBooleanExtra("dialogWindow",false);
}
configWindow();
initView(); initView();
initData(); initData();
WindowSoftModeAdjustResizeExecutor.assistActivity(this); WindowSoftModeAdjustResizeExecutor.assistActivity(this);
@ -94,6 +100,42 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
MessageIMManager.get(this).addConversationClickListener(); MessageIMManager.get(this).addConversationClickListener();
} }
/**
* 配置窗口参数
*/
public void configWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(getResources().getColor(R.color.transparent));
getWindow().setGravity(Gravity.BOTTOM);//设置显示在底部 默认在中间
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;//设置宽度满屏
if(isDialogWindow) {
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
}else{
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
}
getWindow().setAttributes(lp);
setFinishOnTouchOutside(true);//允许点击空白处关闭
}
/**
* ui展示后再调整大小
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus&&isDialogWindow){
ViewGroup.LayoutParams params = mRootLayout.getLayoutParams();
params.height= DpUtil.dp2px(400);
mRootLayout.setLayoutParams(params);
}
}
/** /**
* 数据的设置 * 数据的设置
*/ */
@ -157,6 +199,9 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
titleView = findViewById(R.id.titleView); titleView = findViewById(R.id.titleView);
imgMore = findViewById(R.id.img_more); imgMore = findViewById(R.id.img_more);
imBack = findViewById(R.id.btn_back); imBack = findViewById(R.id.btn_back);
mRootLayout = findViewById(R.id.root_layout);
//来个底部弹出的动画不然太突兀了
mRootLayout.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.bottomview_anim_enter));
imgMore.setOnClickListener(this); imgMore.setOnClickListener(this);
imBack.setOnClickListener(this); imBack.setOnClickListener(this);

View File

@ -310,12 +310,8 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie
} }
for (Object o : rank) { for (Object o : rank) {
JSONObject item= (JSONObject) o; JSONObject item= (JSONObject) o;
UserBean.DressBean dressBean=new UserBean.DressBean();
dressBean.setAvatar_frame(item.getString("dressHead"));
dressBean.setMedal("");
LiveUserRankBean bean=JSON.parseObject(item.getString("userinfo"),LiveUserRankBean.class); LiveUserRankBean bean=JSON.parseObject(item.getString("userinfo"),LiveUserRankBean.class);
bean.setTotal(item.getLong("total")); bean.setTotal(item.getLong("total"));
bean.setDress(dressBean);
data.add(bean); data.add(bean);
} }
if(data.size()==0){ if(data.size()==0){

View File

@ -16,6 +16,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewOutlineProvider; import android.view.ViewOutlineProvider;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -24,6 +26,7 @@ import android.widget.TextView;
import android.widget.ViewFlipper; import android.widget.ViewFlipper;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -119,6 +122,10 @@ import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import io.rong.imkit.userinfo.RongUserInfoManager;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.UserInfo;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.logger;
@ -260,6 +267,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private ViewFlipper wishListFlipper; private ViewFlipper wishListFlipper;
private List<WishlistItemModel> wishlist = new ArrayList<>(); private List<WishlistItemModel> wishlist = new ArrayList<>();
private TextView mHourRank, mHotText; private TextView mHourRank, mHotText;
private LinearLayout msg; //默认悬浮窗布局
private View msg2; //悬浮窗来私信的布局
private ConstraintLayout msgLayout; //悬浮窗
private TextView msgNumber;//悬浮窗左上角数标
private RoundedImageView msgUserIcon; //悬浮窗icon
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
super(context, parentView); super(context, parentView);
@ -635,6 +647,14 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mic_ico2 = (RoundedImageView) findViewById(R.id.mic_ico2); mic_ico2 = (RoundedImageView) findViewById(R.id.mic_ico2);
dr_pk_end_gif = (GifImageView) findViewById(R.id.dr_pk_end_gif); 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);
msgNumber = (TextView) findViewById(R.id.room_msg_num);
msgUserIcon = (RoundedImageView) findViewById(R.id.room_msg_user_icon);
msgLayout= (ConstraintLayout) findViewById(R.id.room_msg_layout);
ViewClicksAntiShake.clicksAntiShake(msg, this::openChatWindow);
ViewClicksAntiShake.clicksAntiShake(msg2, this::openChatWindow);
mHandler = new Handler() { mHandler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -712,11 +732,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
gif_view = (LinearLayout) findViewById(R.id.gif_view); gif_view = (LinearLayout) findViewById(R.id.gif_view);
chat_view = (RelativeLayout) findViewById(R.id.chat_view); chat_view = (RelativeLayout) findViewById(R.id.chat_view);
int topMargin=mScreenWdith * 720 / 960 + 210;
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
chat_view.getLayoutParams(); chat_view.getLayoutParams();
params.topMargin = mScreenWdith * 720 / 960 + 210; params.topMargin = topMargin;
chat_view.setLayoutParams(params); chat_view.setLayoutParams(params);
RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams();
msgLayoutLayoutParams.topMargin=topMargin+DpUtil.dp2px(50);
msgLayout.setLayoutParams(msgLayoutLayoutParams);
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
mChatRecyclerView.getLayoutParams(); mChatRecyclerView.getLayoutParams();
params1.topMargin = 180; params1.topMargin = 180;
@ -945,16 +971,28 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}) })
.start(); .start();
} }
reloadIM();
} }
/**
* 刷新UI
*/
@Override
public void onResume() {
super.onResume();
changeMsgView(msg2,msg);
reloadIM();
}
public void setLiveUid(String liveUid) { public void setLiveUid(String liveUid) {
mLiveUid = liveUid; mLiveUid = liveUid;
LiveHttpUtil.geteEvent(mLiveUid, new HttpCallback() { LiveHttpUtil.geteEvent(mLiveUid, new HttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && imgEvent != null) { if (code == 0 && imgEvent != null) {
for (int i = 0; i < info.length; i++) { for (String s : info) {
JSONObject obj = JSONObject.parseObject(info[i]); JSONObject obj = JSONObject.parseObject(s);
if (obj.getString("is_hidden").equals("0")) { if (obj.getString("is_hidden").equals("0")) {
BannerBean bannerBean = new BannerBean(); BannerBean bannerBean = new BannerBean();
bannerBean.setImageUrl(obj.getString("img")); bannerBean.setImageUrl(obj.getString("img"));
@ -1637,10 +1675,135 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (i == R.id.user_guard) { } else if (i == R.id.user_guard) {
// ((LiveActivity) mContext).openUserMoreListWindow(2, true); // ((LiveActivity) mContext).openUserMoreListWindow(2, true);
((LiveActivity) mContext).openNewGuardListWindow(); ((LiveActivity) mContext).openNewGuardListWindow();
} else if (i==R.id.room_msg){
changeMsgView(msg,msg2);
}else if (i==R.id.room_msg_user){
changeMsgView(msg2,msg);
} }
} }
/**
* 私信的切换动画
* @param out 隐去的view
* @param in 展示的view
*/
private void changeMsgView(View out,View in){
if(in.getVisibility()==View.VISIBLE){
return;
}
Animation animation= AnimationUtils.loadAnimation(mContext,R.anim.view_room_msg_out);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
out.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
out.startAnimation(animation);
Animation start=AnimationUtils.loadAnimation(mContext,R.anim.view_room_msg_in);
start.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
in.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
in.startAnimation(start);
}
/**
* 从右侧私聊悬浮窗打开私聊界面
*/
private void openChatWindow(){
/*LiveChatListDialogFragment chat=new LiveChatListDialogFragment();
chat.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveRoomChatDialogFragment");*/
Bundle bundle=new Bundle();
bundle.putBoolean("systemMsg",false);
bundle.putBoolean("dialogWindow",true);
((LiveActivity) mContext).openChatListWindow(bundle);
}
/**
* 更新左上角数标
* @param number 数字
*/
public void onMessageIMEvent(int number) {
String num="";
if(number!=0){
changeMsgView(msg,msg2);
if(number>99){
num="99+";
}else{
num=number+"";
}
msgNumber.setText(num);
}
}
/**
* 刷新im消息以便更新私信悬浮窗UI
*/
public void reloadIM(){
RongIMClient.getInstance().getConversationListByPage(new RongIMClient.ResultCallback<List<Conversation>>() {
@Override
public void onSuccess(List<Conversation> conversations) {
if(!conversations.isEmpty()){
Conversation conversation = conversations.get(0);
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(conversation.getTargetId());
if(userInfo!=null){
ImgLoader.display(mContext,userInfo.getPortraitUri().toString(),msgUserIcon);
}
}
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
Log.e("IM","IM会话获取失败 = "+errorCode);
}
},0,10, Conversation.ConversationType.PRIVATE);
RongIMClient.getInstance().getUnreadCount(new Conversation.ConversationType[]{Conversation.ConversationType.PRIVATE},true,new RongIMClient.ResultCallback<Integer>() {
@Override
public void onSuccess(Integer integer) {
onMessageIMEvent(integer);
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 私信来消息了刷新悬浮窗UI
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void sendMessage(io.rong.imlib.model.Message bean){
reloadIM();
}
/** /**
* 关注主播 * 关注主播
*/ */

View File

@ -292,6 +292,7 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
@Override @Override
public void onSuccess(List<Message> messages) { public void onSuccess(List<Message> messages) {
Collections.reverse(messages); Collections.reverse(messages);
EventBus.getDefault().post(messages);
if (messages.size() > 0) { if (messages.size() > 0) {
if (messages.size() < 20) { if (messages.size() < 20) {
moretext = false; moretext = false;

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="300"
android:fromXScale="0.3"
android:fromYScale="0.3"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
<alpha
android:duration="200"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="300"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.3"
android:toYScale="0.3" />
<alpha
android:duration="200"
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>
</set>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="42dp" android:height="48dp">
<shape android:shape="rectangle">
<solid android:color="#33ffffff" />
<corners android:topLeftRadius="100dp" android:topRightRadius="0dp" android:bottomLeftRadius="100dp" android:bottomRightRadius="0dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="15dp" android:height="15dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffffff" />
<solid android:color="#ffff4e4e" />
<corners android:radius="8dp" />
</shape>
</item>
</selector>

View File

@ -20,8 +20,15 @@
android:layout_height="0.5dp" android:layout_height="0.5dp"
android:background="@color/gray3" /> android:background="@color/gray3" />
<!--套一层Layout不然控件就透明了-->
<LinearLayout
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="wrap_content">
<com.yunbao.live.views.InputPanelViewHolder <com.yunbao.live.views.InputPanelViewHolder
android:id="@+id/input_panel" android:id="@+id/input_panel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<TextView
android:id="@+id/top_noback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:layout_marginTop="8dp"
android:text="@string/message"
android:textColor="#ff161616"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:checked="true"
android:text="私聊浮标"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chatRecyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/checkBox" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -10,8 +10,9 @@
android:paddingTop="15dp"> android:paddingTop="15dp">
<LinearLayout <LinearLayout
android:id="@+id/bannerLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="216dp"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:orientation="vertical"> android:orientation="vertical">
@ -693,6 +694,87 @@
android:src="@mipmap/icon_red_pack_4" android:src="@mipmap/icon_red_pack_4"
android:visibility="invisible" /> android:visibility="invisible" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/room_msg_layout"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="0dp"
android:background="@drawable/bg_live_room_msg">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/room_msg_user"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/room_msg_user_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="centerInside"
android:src="@drawable/m_chu_xia"
app:riv_oval="true" />
<TextView
android:id="@+id/room_msg_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:background="@drawable/bg_room_msg_unread"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:text="1"
android:textColor="#FFFFFF"
android:textSize="10.5sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/room_msg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_marginStart="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center"
app:srcCompat="@mipmap/icon_live_room_msg" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginTop="2dp"
android:text="@string/room_msg"
android:textColor="#99ffffff"
android:textSize="12sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/chat_view" android:id="@+id/chat_view"
android:layout_width="match_parent" android:layout_width="match_parent"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -10,4 +10,5 @@
<string name="views_rank">Viewers</string> <string name="views_rank">Viewers</string>
<string name="gurad_rank">Guard</string> <string name="gurad_rank">Guard</string>
<string name="fans">Fans</string> <string name="fans">Fans</string>
<string name="room_msg">News</string>
</resources> </resources>

View File

@ -11,4 +11,5 @@
<string name="views_rank">觀眾</string> <string name="views_rank">觀眾</string>
<string name="gurad_rank">觀眾</string> <string name="gurad_rank">觀眾</string>
<string name="fans">粉絲</string> <string name="fans">粉絲</string>
<string name="room_msg">私信</string>
</resources> </resources>

View File

@ -10,4 +10,16 @@
<item name="android:backgroundDimAmount">0.3</item> <item name="android:backgroundDimAmount">0.3</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
</style> </style>
<style name="DialogNotTitleActivity" parent="@style/Theme.AppCompat.Dialog">
<item name="android:windowFrame">@android:color/transparent</item><!--边框-->
<item name="android:windowIsFloating">true</item><!--是否浮如今activity之上-->
<item name="android:windowIsTranslucent">true</item><!--半透明-->
<item name="android:windowNoTitle">true</item><!--无标题-->
<item name="android:windowBackground">@android:color/transparent</item><!--背景透明-->
<item name="android:backgroundDimAmount">0.3</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:activityOpenEnterAnimation">@anim/anim_marquee_in</item>
<item name="android:activityOpenExitAnimation">@anim/anim_marquee_in</item>
</style>
</resources> </resources>

View File

@ -48,6 +48,7 @@ import io.rong.sight.SightExtensionModule;
public class ConversationIMListManager { public class ConversationIMListManager {
private static ConversationIMListManager manager; private static ConversationIMListManager manager;
private Context mContext; private Context mContext;
private Bundle bundle;//用户传输配置给会话界面
private ConversationIMListManager(Context context) { private ConversationIMListManager(Context context) {
mContext = context; mContext = context;
@ -172,7 +173,7 @@ public class ConversationIMListManager {
if (null != userInfo){ if (null != userInfo){
context.runOnUiThread(() -> { context.runOnUiThread(() -> {
Conversation.ConversationType type = Conversation.ConversationType.PRIVATE; Conversation.ConversationType type = Conversation.ConversationType.PRIVATE;
RouteUtils.routeToConversationActivity(context, type, userId, null); RouteUtils.routeToConversationActivity(context, type, userId, bundle);
}); });
}else { }else {
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() { CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
@ -246,6 +247,12 @@ public class ConversationIMListManager {
*/ */
@Override @Override
public boolean onConversationClick(Context context, View view, BaseUiConversation baseUiConversation) { public boolean onConversationClick(Context context, View view, BaseUiConversation baseUiConversation) {
Object tag = view.getTag();
if(tag!=null){
bundle= (Bundle) tag;
}else{
bundle=null;
}
ViewClicksAntiShake.clicksAntiShake(view, () -> jumpConversation((Activity) context, baseUiConversation.mCore.getTargetId())); ViewClicksAntiShake.clicksAntiShake(view, () -> jumpConversation((Activity) context, baseUiConversation.mCore.getTargetId()));
return true; return true;
} }