From 01bdab01f681bb60c4e3be83771db0bd28124bec Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 21 Jul 2022 15:05:35 +0800 Subject: [PATCH] 11111 --- .../yunbao/common/activity/AbsActivity.java | 1 + .../yunbao/live/activity/LiveActivity.java | 11 - .../live/activity/PDLIiveChatActivity.java | 120 +++++- .../activity/PDLiveConversationActivity.java | 2 + .../adapter/SystemChatMessageAdapter.java | 150 +++++++ .../dialog/LiveChatRoomDialogFragment.java | 107 ----- .../presenter/LiveEnterRoomAnimPresenter.java | 14 - .../com/yunbao/live/views/InputPanel.java | 408 ++++++++++++++++++ .../yunbao/live/views/LiveRoomViewHolder.java | 132 +----- .../views/SystemChatMessageViewHolder.java | 47 ++ live/src/main/res/layout/activity_pd_chat.xml | 5 +- live/src/main/res/layout/view_layout_msg.xml | 1 - .../main/res/layout/view_system_message.xml | 12 + .../res/layout/view_system_message_item.xml | 74 ++++ .../yunbao/main/activity/MainActivity.java | 1 + .../main/activity/MyWebViewActivity.java | 3 +- .../ConversationIMListManager.java | 3 +- .../res/layout/rc_extension_input_panel.xml | 115 ----- 18 files changed, 816 insertions(+), 390 deletions(-) create mode 100644 live/src/main/java/com/yunbao/live/adapter/SystemChatMessageAdapter.java create mode 100644 live/src/main/java/com/yunbao/live/views/InputPanel.java create mode 100644 live/src/main/java/com/yunbao/live/views/SystemChatMessageViewHolder.java create mode 100644 live/src/main/res/layout/view_system_message.xml create mode 100644 live/src/main/res/layout/view_system_message_item.xml delete mode 100644 main/src/main/res/layout/rc_extension_input_panel.xml diff --git a/common/src/main/java/com/yunbao/common/activity/AbsActivity.java b/common/src/main/java/com/yunbao/common/activity/AbsActivity.java index 2c0e076ab..a3ac74556 100644 --- a/common/src/main/java/com/yunbao/common/activity/AbsActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/AbsActivity.java @@ -102,6 +102,7 @@ public abstract class AbsActivity extends AppCompatActivity { * 设置透明状态栏 */ private void setStatusBar() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 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 161fe26d9..7de5f415c 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -490,7 +490,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL mLiveRoomViewHolder.onGuardInfoChanged(bean); LiveChatBean chatBean = new LiveChatBean(); chatBean.setContent(bean.getUserName()); -// chatBean.setType(LiveChatBean.SYSTEM); mLiveRoomViewHolder.insertChat(chatBean, 1); } } @@ -837,23 +836,14 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL @Override public void onGameZjh(JSONObject obj) { -// if (mGamePresenter != null) { -// mGamePresenter.onGameZjhSocket(obj); -// } } @Override public void onGameHd(JSONObject obj) { -// if (mGamePresenter != null) { -// mGamePresenter.onGameHdSocket(obj); -// } } @Override public void onGameZp(JSONObject obj) { -// if (mGamePresenter != null) { -// mGamePresenter.onGameZpSocket(obj); -// } } @Override @@ -918,7 +908,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 打开私信列表窗口 */ public void openChatListWindow() { - RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationActivity, PDLIiveChatActivity.class); Intent intent = new Intent(mContext, PDLIiveChatActivity.class); mContext.startActivity(intent); } diff --git a/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java b/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java index 18e07bc0f..bd41bb821 100644 --- a/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java @@ -1,36 +1,66 @@ package com.yunbao.live.activity; +import android.app.Activity; +import android.net.Uri; import android.os.Bundle; import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; import android.view.Window; import android.view.WindowManager; +import android.widget.FrameLayout; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.blankj.utilcode.util.GsonUtils; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.live.R; +import com.yunbao.live.adapter.SystemChatMessageAdapter; +import com.yunbao.live.bean.ImUserBean; +import com.yunbao.live.bean.SearchUserBean; +import com.yunbao.live.http.ImHttpUtil; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import io.rong.imkit.conversationlist.ConversationListFragment; +import io.rong.imkit.userinfo.RongUserInfoManager; +import io.rong.imlib.model.UserInfo; /** * 直播页面聊天列表 */ -public class PDLIiveChatActivity extends AbsActivity { - @Override - protected int getLayoutId() { - return R.layout.activity_pd_chat; - - } +public class PDLIiveChatActivity extends FragmentActivity { + private ConversationListFragment conversationListFragment; + private FrameLayout container; + private PDLIiveChatActivity mContext; @Override - protected void main(Bundle savedInstanceState) { - super.main(savedInstanceState); + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_NO_TITLE); + setContentView(R.layout.activity_pd_chat); + mContext = this; windowColor(); initView(); + initData(); } + + public void windowColor() { + Window window = getWindow(); //取消设置Window半透明的Flag window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); @@ -47,17 +77,89 @@ public class PDLIiveChatActivity extends AbsActivity { setFinishOnTouchOutside(true);//允许点击空白处关闭 } + /** * 初始化控件 */ private void initView() { + container = findViewById(R.id.container); + } + + /** + * 初始化数据 + */ + private void initData() { + //获取系统消息列表 + ImHttpUtil.getImUserInfo("", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + container.post(new Runnable() { + @Override + public void run() { + List listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class); + addSystemMessagesView(listUserBean); + } + }); + } + } + }); + //刷新列表内用户信息 + addUserInfoProvider(); + + //获取一下系统通知 + MessageIMManager.get(this).getSystemMessages(); + } + + /** + * 添加头部系统消息 + * + * @param listUserBean 数据源 + */ + private void addSystemMessagesView(List listUserBean) { + //倒序展示 + Collections.reverse(listUserBean); //展示会话列表 - ConversationListFragment conversationListFragment = new ConversationListFragment(); + conversationListFragment = new ConversationListFragment(); FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.container, conversationListFragment); transaction.commit(); //自定义空数据背景View conversationListFragment.setEmptyView(com.yunbao.live.R.layout.view_layout_msg); + //初始化系统消息界面 + View rootView = LayoutInflater.from(mContext).inflate(R.layout.view_system_message, null, true); + RecyclerView systemMessageList = rootView.findViewById(R.id.system_message_list); + SystemChatMessageAdapter messageAdapter = new SystemChatMessageAdapter(mContext); + messageAdapter.addDataAll(listUserBean); + systemMessageList.setHasFixedSize(false); + systemMessageList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true)); + systemMessageList.setAdapter(messageAdapter); + conversationListFragment.addHeaderView(rootView); + } + + /** + * 刷新用户信息(异步) + */ + public void addUserInfoProvider() { + RongUserInfoManager.getInstance().setUserInfoProvider(userId -> { + CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class); + UserInfo userInfo = new UserInfo(userId, userBean.getUserNiceName(), Uri.parse(userBean.getAvatar())); + //使用空白字段存储自己服务器用户的所有的信息 + userInfo.setExtra(GsonUtils.toJson(userBean)); + RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo); + } + + } + }); + + return null; + }, true); + } } diff --git a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java index 78d880f34..1ef9e226f 100644 --- a/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/PDLiveConversationActivity.java @@ -81,8 +81,10 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl //新手指导员 if (TextUtils.isEmpty(userBean.getIs_admin()) && TextUtils.equals(userBean.getIs_admin(), "1")) { isAdmin = true; + imgMore.setVisibility(View.GONE); } else {//非指导员 isAdmin = false; + imgMore.setVisibility(View.VISIBLE); } Log.e("PDLiveConversation", userInfo.getExtra()); } diff --git a/live/src/main/java/com/yunbao/live/adapter/SystemChatMessageAdapter.java b/live/src/main/java/com/yunbao/live/adapter/SystemChatMessageAdapter.java new file mode 100644 index 000000000..bd35935ad --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/SystemChatMessageAdapter.java @@ -0,0 +1,150 @@ +package com.yunbao.live.adapter; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.adjust.sdk.Adjust; +import com.adjust.sdk.AdjustEvent; +import com.alibaba.fastjson.JSON; +import com.facebook.appevents.AppEventsLogger; +import com.google.firebase.analytics.FirebaseAnalytics; +import com.yunbao.common.activity.WebViewActivity; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.manager.imrongcloud.MessageIMManager; +import com.yunbao.live.R; +import com.yunbao.live.activity.SystemMessageActivity; +import com.yunbao.live.bean.ImUserBean; +import com.yunbao.live.views.SystemChatMessageViewHolder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * 系统消息适配器 + */ +public class SystemChatMessageAdapter extends RecyclerView.Adapter { + private List listUserBean = new ArrayList<>(); + protected Activity mContext; + protected LayoutInflater mInflater; + + public SystemChatMessageAdapter(Activity mContext) { + this.mContext = mContext; + mInflater = LayoutInflater.from(mContext); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + //view_system_message_item.xml + return new SystemChatMessageViewHolder(mInflater.inflate(R.layout.view_system_message_item, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + ImUserBean model = listUserBean.get(position); + SystemChatMessageViewHolder messageViewHolder = (SystemChatMessageViewHolder) holder; + ImgLoader.displayWithError(mContext, model.getImage(), messageViewHolder.avatarImage, com.yunbao.live.R.mipmap.chat_head_mo); + if (position == 2) { + messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getLink()) ? mContext.getResources().getString(R.string.chat_like) : model.getLink()); + } else { + if (position == 1) { + messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getContent()) ? mContext.getResources().getString(R.string.chat_action_no) : model.getContent()); + } else { + messageViewHolder.userMsg.setText(TextUtils.isEmpty(model.getContent()) ? "" : model.getContent()); + } + } + messageViewHolder.userName.setText(model.getTitle()); + messageViewHolder.lastTime.setText(model.getLastDate()); + String number = model.getNum(); + + if (!TextUtils.isEmpty(number) && !TextUtils.equals(number, "0")) { + messageViewHolder.redPoint.setVisibility(View.VISIBLE); + messageViewHolder.redPoint.setText(number); + } else { + messageViewHolder.redPoint.setVisibility(View.GONE); + } + //系统消息的跳转 + messageViewHolder.setViewHolderOnClickListener((view, model1) -> { + //获取一下系统通知 + MessageIMManager.get(mContext).getSystemMessages(new MessageIMManager.SystemMessagesHttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code==0){ + List listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class); + addSystemMessagesView(listUserBean); + } + } + }); + if (model1.getContent().equals("在線客服")) { + FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null); + AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service"); + AdjustEvent adjustEvent1 = new AdjustEvent("ww5z2p"); + Adjust.trackEvent(adjustEvent1); + } else if (model1.getContent().equals("新手指導員")) { + FirebaseAnalytics.getInstance(mContext).logEvent("FS_guide", null); + AppEventsLogger.newLogger(mContext).logEvent("FB_guide", null); + AdjustEvent adjustEvent1 = new AdjustEvent("m0nfpn"); + Adjust.trackEvent(adjustEvent1); + } + if (!TextUtils.isEmpty(model1.getLink())) { + mContext.startActivity(new Intent(mContext, WebViewActivity.class).putExtra("url", model1.getLink())); + } else if ("1".equals(model1.getType()) || "2".equals(model1.getType())) {//系统消息,互动消息,猜你喜欢 + forward(mContext, model1.getType(), "", model1.getTitle(), ""); + } else if ("3".equals(model1.getType())) { + if (model1.getLink() != null && !"".equals(model1.getLink())) { + WebViewActivity.forward(mContext, model1.getLink()); + } else { + forward(mContext, model1.getType(), "", model1.getTitle(), ""); + } + } + }, model); + } + + @Override + public int getItemCount() { + return listUserBean.size(); + } + + /** + * 添加数据源 + * + * @param mListUserBean 数据源 + */ + public void addDataAll(List mListUserBean) { + listUserBean.clear(); + listUserBean.addAll(mListUserBean); + notifyDataSetChanged(); + } + + private void forward(Context context, String type, String uid, String title, String headImg) { + context.startActivity(new Intent(context, SystemMessageActivity.class) + .putExtra("type", type) + .putExtra("uid", uid) + .putExtra("title", title) + .putExtra("headImg", headImg)); + } + + /** + * 添加头部系统消息 + * + * @param mlistUserBean 数据源 + */ + private void addSystemMessagesView(List mlistUserBean) { + //倒序展示 + Collections.reverse(mlistUserBean); + listUserBean.clear(); + listUserBean.addAll(mlistUserBean); + notifyDataSetChanged(); + + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveChatRoomDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveChatRoomDialogFragment.java index 157e7ac2a..7e612a303 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveChatRoomDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveChatRoomDialogFragment.java @@ -29,8 +29,6 @@ import java.io.File; */ public class LiveChatRoomDialogFragment extends AbsDialogFragment { - -// private ChatRoomDialogViewHolder mChatRoomViewHolder; private int mOriginHeight; private ProcessImageUtil mImageUtil; @@ -73,63 +71,6 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { return; } boolean following = bundle.getBoolean(Constants.FOLLOW); -// mChatRoomViewHolder = new ChatRoomDialogViewHolder(mContext, (ViewGroup) mRootView.findViewById(R.id.container), userBean, following); -// mChatRoomViewHolder.setActionListener(new ChatRoomActionListener() { -// @Override -// public void onCloseClick() { -// dismiss(); -// } -// -// @Override -// public void onPopupWindowChanged(int deltaHeight) { -// addHeight(deltaHeight); -// } -// -// @Override -// public void onChooseImageClick() { -// checkReadWritePermissions(); -// } -// -// @Override -// public void onCameraClick() { -// takePhoto(); -// } -// -// @Override -// public void onVoiceInputClick() { -// checkVoiceRecordPermission(new Runnable() { -// @Override -// public void run() { -// openVoiceInputDialog(); -// } -// }); -// } -// -// @Override -// public void onLocationClick() { -// checkLocationPermission(); -// } -// -// @Override -// public void onVoiceClick() { -// checkVoiceRecordPermission(new Runnable() { -// @Override -// public void run() { -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.clickVoiceRecord(); -// } -// } -// }); -// } -// -// @Override -// public ViewGroup getImageParentView() { -// return ((LiveActivity) mContext).getPageContainer(); -// } -// -// }); -// mChatRoomViewHolder.addToParent(); -// mChatRoomViewHolder.loadData(); } @@ -143,9 +84,6 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { @Override public void onSuccess(File file) { -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.sendImage(file.getAbsolutePath()); -// } } @Override @@ -162,10 +100,6 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { } mImageUtil = null; ((LiveActivity) mContext).setChatRoomOpened(null, false); -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.refreshLastMessage(); -// mChatRoomViewHolder.release(); -// } super.onDestroy(); } @@ -187,9 +121,6 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { public void scrollToBottom() { -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.scrollToBottom(); -// } } /** @@ -218,17 +149,6 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { if (mImageUtil == null) { return; } -// mImageUtil.startActivityForResult(new Intent(mContext, ChatChooseImageActivity.class), new ActivityResultCallback() { -// @Override -// public void onSuccess(Intent intent) { -// if (intent != null) { -// String imagePath = intent.getStringExtra(Constants.SELECT_IMAGE_PATH); -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.sendImage(imagePath); -// } -// } -// } -// }); } /** @@ -264,24 +184,6 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { if (mImageUtil == null) { return; } -// mImageUtil.startActivityForResult(new Intent(mContext, LocationActivity.class), new ActivityResultCallback() { -// @Override -// public void onSuccess(Intent intent) { -// if (intent != null) { -// double lat = intent.getDoubleExtra(Constants.LAT, 0); -// double lng = intent.getDoubleExtra(Constants.LNG, 0); -// int scale = intent.getIntExtra(Constants.SCALE, 0); -// String address = intent.getStringExtra(Constants.ADDRESS); -// if (lat > 0 && lng > 0 && scale > 0 && !TextUtils.isEmpty(address)) { -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.sendLocation(lat, lng, scale, address); -// } -// } else { -// ToastUtil.show(WordUtil.getString(R.string.im_get_location_failed)); -// } -// } -// } -// }); } /** @@ -303,24 +205,15 @@ public class LiveChatRoomDialogFragment extends AbsDialogFragment { * 打开语音输入窗口 */ private void openVoiceInputDialog() { -// ChatVoiceInputDialog fragment = new ChatVoiceInputDialog(); -// fragment.setChatRoomViewHolder(mChatRoomViewHolder); -// fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "ChatVoiceInputDialog"); } @Override public void onPause() { super.onPause(); -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.onPause(); -// } } @Override public void onResume() { super.onResume(); -// if (mChatRoomViewHolder != null) { -// mChatRoomViewHolder.onResume(); -// } } } diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java index 032631201..ad3779404 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java @@ -112,9 +112,6 @@ public class LiveEnterRoomAnimPresenter { enter_room_gif_small = (GifImageView) root.findViewById(R.id.enter_room_gif_small); enter_room_svg_small = (SVGAImageView) root.findViewById(R.id.enter_room_svg_small); tv_enterroom_user = (TextView) root.findViewById(R.id.tv_enterroom_user); - -// enter_room_img_small = (ImageView) root.findViewById(R.id.enter_room_img_small); - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) rt_enterroom_svga.getLayoutParams(); params.topMargin = mScreenWdith * 720 / 960 - 24; @@ -242,11 +239,6 @@ public class LiveEnterRoomAnimPresenter { } private void playHaoHuaGift(File file) { - //测试 -// Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.zuojia_test_new); -// LoadDian9TuUtil.setNinePathImage(mContext, tv_enterroom_user, bitmap, 0); -// LoadDian9TuUtil.loadDian9Tu(mContext, tv_enterroom_user, "https://qny.shayucm.com/Car_New/zuojia_test_new.png", 0); - if (carType.contains("gif")) { Log.i("fff", "gif"); playGif(file); @@ -405,10 +397,7 @@ public class LiveEnterRoomAnimPresenter { needAnim = true; mShowGif = true; //直播间进场坐骑 -// mWordText.setText( Html.fromHtml( u.getUserNiceName() + " "+car.getWords() + " ")); -// carType = car.getWords(); carType = car.getSwf(); -// mWordText.setText( u.getUserNiceName() +car.getWords() ); mWordText.setVisibility(View.GONE); String[] arr = url.split("/"); @@ -547,9 +536,6 @@ public class LiveEnterRoomAnimPresenter { if (enter_room_gif_small != null) { enter_room_gif_small.setImageDrawable(null); } -// if (enter_room_img_small != null) { -// enter_room_img_small.setImageDrawable(null); -// } if (mGifDrawable != null && !mGifDrawable.isRecycled()) { mGifDrawable.stop(); mGifDrawable.recycle(); diff --git a/live/src/main/java/com/yunbao/live/views/InputPanel.java b/live/src/main/java/com/yunbao/live/views/InputPanel.java new file mode 100644 index 000000000..8a93ea240 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/views/InputPanel.java @@ -0,0 +1,408 @@ +package com.yunbao.live.views; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; + +import com.yunbao.live.R; + +import io.rong.imkit.IMCenter; +import io.rong.imkit.conversation.extension.InputMode; +import io.rong.imkit.conversation.extension.RongExtensionCacheHelper; +import io.rong.imkit.conversation.extension.RongExtensionViewModel; +import io.rong.imkit.manager.AudioPlayManager; +import io.rong.imkit.manager.AudioRecordManager; +import io.rong.imkit.utils.PermissionCheckUtil; +import io.rong.imkit.utils.RongUtils; +import io.rong.imlib.IMLibExtensionModuleManager; +import io.rong.imlib.RongIMClient; +import io.rong.imlib.model.Conversation; +import io.rong.imlib.model.HardwareResource; + +import static android.view.View.VISIBLE; + +public class InputPanel { + private final String TAG = this.getClass().getSimpleName(); + private Conversation.ConversationType mConversationType; + private Context mContext; + private String mTargetId; + private InputPanel.InputStyle mInputStyle; + private Fragment mFragment; + private View mInputPanel; + private boolean mIsVoiceInputMode; + private ImageView mVoiceToggleBtn; + private EditText mEditText; + private TextView mVoiceInputBtn; + private ImageView mEmojiToggleBtn; + private Button mSendBtn; + private ImageView mAddBtn; + private ViewGroup mAddOrSendBtn; + private RongExtensionViewModel mExtensionViewModel; + private String mInitialDraft = ""; + private float mLastTouchY; + private boolean mUpDirection; + private View.OnTouchListener mOnVoiceBtnTouchListener = new View.OnTouchListener() { + public boolean onTouch(View v, MotionEvent event) { + float mOffsetLimit = 70.0F * v.getContext().getResources().getDisplayMetrics().density; + String[] permissions = new String[]{"android.permission.RECORD_AUDIO"}; + if (!PermissionCheckUtil.checkPermissions(v.getContext(), permissions) && event.getAction() == 0) { + PermissionCheckUtil.requestPermissions(InputPanel.this.mFragment, permissions, 100); + return true; + } else { + if (event.getAction() == 0) { + if (AudioPlayManager.getInstance().isPlaying()) { + AudioPlayManager.getInstance().stopPlay(); + } + + if (RongUtils.phoneIsInUse(v.getContext()) || IMLibExtensionModuleManager.getInstance().onRequestHardwareResource(HardwareResource.ResourceType.VIDEO) || IMLibExtensionModuleManager.getInstance().onRequestHardwareResource(HardwareResource.ResourceType.AUDIO)) { + Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.rc_voip_occupying), Toast.LENGTH_SHORT).show(); + return true; + } + + AudioRecordManager.getInstance().startRecord(v.getRootView(), InputPanel.this.mConversationType, InputPanel.this.mTargetId); + InputPanel.this.mLastTouchY = event.getY(); + InputPanel.this.mUpDirection = false; + ((TextView) v).setText(R.string.rc_voice_release_to_send); + ((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_touched_button)); + } else if (event.getAction() == 2) { + if (InputPanel.this.mLastTouchY - event.getY() > mOffsetLimit && !InputPanel.this.mUpDirection) { + AudioRecordManager.getInstance().willCancelRecord(); + InputPanel.this.mUpDirection = true; + ((TextView) v).setText(R.string.rc_voice_press_to_input); + ((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_idle_button)); + } else if (event.getY() - InputPanel.this.mLastTouchY > -mOffsetLimit && InputPanel.this.mUpDirection) { + AudioRecordManager.getInstance().continueRecord(); + InputPanel.this.mUpDirection = false; + ((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_touched_button)); + ((TextView) v).setText(R.string.rc_voice_release_to_send); + } + } else if (event.getAction() == 1 || event.getAction() == 3) { + AudioRecordManager.getInstance().stopRecord(); + ((TextView) v).setText(R.string.rc_voice_press_to_input); + ((TextView) v).setBackground(v.getContext().getResources().getDrawable(R.drawable.rc_ext_voice_idle_button)); + } + + if (InputPanel.this.mConversationType.equals(Conversation.ConversationType.PRIVATE)) { + RongIMClient.getInstance().sendTypingStatus(InputPanel.this.mConversationType, InputPanel.this.mTargetId, "RC:VcMsg"); + } + + return true; + } + } + }; + private View.OnClickListener mOnSendBtnClick = new View.OnClickListener() { + public void onClick(View v) { + InputPanel.this.mExtensionViewModel.onSendClick(); + } + }; + private View.OnFocusChangeListener mOnEditTextFocusChangeListener = new View.OnFocusChangeListener() { + public void onFocusChange(View v, boolean hasFocus) { + if (hasFocus) { + if (InputPanel.this.mExtensionViewModel != null && InputPanel.this.mExtensionViewModel.getInputModeLiveData() != null) { + InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.TextInput); + } + + if (!TextUtils.isEmpty(InputPanel.this.mEditText.getText())) { + InputPanel.this.mSendBtn.setVisibility(VISIBLE); + InputPanel.this.mAddBtn.setVisibility(View.GONE); + } + } else { + EditText editText = InputPanel.this.mExtensionViewModel.getEditTextWidget(); + if (editText.getText() != null && editText.getText().length() == 0) { + InputPanel.this.mSendBtn.setVisibility(View.GONE); + InputPanel.this.mAddBtn.setVisibility(VISIBLE); + } + } + + } + }; + private TextWatcher mEditTextWatcher = new TextWatcher() { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (s != null && s.length() != 0) { + InputPanel.this.mAddOrSendBtn.setVisibility(VISIBLE); + InputPanel.this.mSendBtn.setVisibility(VISIBLE); + InputPanel.this.mAddBtn.setVisibility(View.GONE); + } else { + IMCenter.getInstance().saveTextMessageDraft(InputPanel.this.mConversationType, InputPanel.this.mTargetId, InputPanel.this.mEditText.getText().toString(), (RongIMClient.ResultCallback) null); + if (!InputPanel.this.mInputStyle.equals(InputPanel.InputStyle.STYLE_CONTAINER_EXTENSION) && !InputPanel.this.mInputStyle.equals(InputPanel.InputStyle.STYLE_SWITCH_CONTAINER_EXTENSION)) { + InputPanel.this.mAddOrSendBtn.setVisibility(View.GONE); + } else { + InputPanel.this.mAddOrSendBtn.setVisibility(VISIBLE); + InputPanel.this.mAddBtn.setVisibility(VISIBLE); + InputPanel.this.mSendBtn.setVisibility(View.GONE); + } + } + + int offset; + if (count == 0) { + int var10000 = start + before; + offset = -before; + } else { + offset = count; + } + + if (Conversation.ConversationType.PRIVATE.equals(InputPanel.this.mConversationType) && offset != 0) { + RongIMClient.getInstance().sendTypingStatus(InputPanel.this.mConversationType, InputPanel.this.mTargetId, "RC:TxtMsg"); + } + + } + + public void afterTextChanged(Editable s) { + } + }; + + public InputPanel(Fragment fragment, ViewGroup parent, InputPanel.InputStyle inputStyle, Conversation.ConversationType type, String targetId) { + this.mFragment = fragment; + this.mInputStyle = inputStyle; + this.mConversationType = type; + this.mTargetId = targetId; + this.initView(fragment.getContext(), parent); + this.mExtensionViewModel = (RongExtensionViewModel) (new ViewModelProvider(fragment)).get(RongExtensionViewModel.class); + this.mExtensionViewModel.getInputModeLiveData().observe(fragment.getViewLifecycleOwner(), new Observer() { + public void onChanged(InputMode inputMode) { + InputPanel.this.updateViewByInputMode(inputMode); + } + }); + if (fragment.getContext() != null) { + this.mIsVoiceInputMode = RongExtensionCacheHelper.isVoiceInputMode(fragment.getContext(), this.mConversationType, this.mTargetId); + } + + if (this.mIsVoiceInputMode) { + this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.VoiceInput); + } else { + this.getDraft(); + this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.TextInput); + } + + } + + @SuppressLint({"ClickableViewAccessibility"}) + private void initView(final Context context, ViewGroup parent) { + this.mContext = context; + this.mInputPanel = LayoutInflater.from(context).inflate(R.layout.rc_extension_input_panel, parent, false); + this.mVoiceToggleBtn = (ImageView) this.mInputPanel.findViewById(R.id.input_panel_voice_toggle); + this.mEditText = (EditText) this.mInputPanel.findViewById(R.id.edit_btn); + this.mVoiceInputBtn = (TextView) this.mInputPanel.findViewById((R.id.press_to_speech_btn)); + this.mEmojiToggleBtn = (ImageView) this.mInputPanel.findViewById((R.id.input_panel_emoji_btn)); + this.mAddOrSendBtn = (ViewGroup) this.mInputPanel.findViewById((R.id.input_panel_add_or_send)); + this.mSendBtn = (Button) this.mInputPanel.findViewById((R.id.input_panel_send_btn)); + this.mAddBtn = (ImageView) this.mInputPanel.findViewById((R.id.input_panel_add_btn)); + this.mSendBtn.setOnClickListener(this.mOnSendBtnClick); + this.mEditText.setOnFocusChangeListener(this.mOnEditTextFocusChangeListener); + this.mEditText.addTextChangedListener(this.mEditTextWatcher); + this.mVoiceToggleBtn.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + if (InputPanel.this.mIsVoiceInputMode) { + InputPanel.this.mIsVoiceInputMode = false; + InputPanel.this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.TextInput); + InputPanel.this.mEditText.requestFocus(); + if (TextUtils.isEmpty(InputPanel.this.mInitialDraft)) { + InputPanel.this.getDraft(); + } + } else { + InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.VoiceInput); + InputPanel.this.mIsVoiceInputMode = true; + } + + RongExtensionCacheHelper.saveVoiceInputMode(context, InputPanel.this.mConversationType, InputPanel.this.mTargetId, InputPanel.this.mIsVoiceInputMode); + } + }); + this.mEmojiToggleBtn.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + if (InputPanel.this.mExtensionViewModel != null) { + if (InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue() != null && ((InputMode) InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue()).equals(InputMode.EmoticonMode)) { + InputPanel.this.mEditText.requestFocus(); + InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.TextInput); + } else { + InputPanel.this.mExtensionViewModel.getInputModeLiveData().postValue(InputMode.EmoticonMode); + } + + } + } + }); + this.mAddBtn.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + if (InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue() != null && ((InputMode) InputPanel.this.mExtensionViewModel.getInputModeLiveData().getValue()).equals(InputMode.PluginMode)) { + InputPanel.this.mEditText.requestFocus(); + InputPanel.this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.TextInput); + } + + InputPanel.this.mExtensionViewModel.getInputModeLiveData().setValue(InputMode.PluginMode); + } + }); + this.mVoiceInputBtn.setOnTouchListener(this.mOnVoiceBtnTouchListener); + this.setInputPanelStyle(this.mInputStyle); + } + + private void updateViewByInputMode(InputMode inputMode) { + if (!inputMode.equals(InputMode.TextInput) && !inputMode.equals(InputMode.PluginMode)) { + if (inputMode.equals(InputMode.VoiceInput)) { + this.mVoiceToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_keyboard_btn))); + this.mVoiceInputBtn.setVisibility(VISIBLE); + this.mEditText.setVisibility(View.GONE); + this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_input_panel_emoji))); + } else if (inputMode.equals(InputMode.EmoticonMode)) { + this.mVoiceToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_voice_btn))); + this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_keyboard_btn))); + this.mEditText.setVisibility(View.GONE); + this.mVoiceInputBtn.setVisibility(View.GONE); + } + } else { + if (inputMode.equals(InputMode.TextInput)) { + this.mIsVoiceInputMode = false; + } + + this.mVoiceToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_toggle_voice_btn))); + this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_input_panel_emoji))); + this.mEditText.setVisibility(VISIBLE); + this.mVoiceInputBtn.setVisibility(View.GONE); + this.mEmojiToggleBtn.setImageDrawable(this.mContext.getResources().getDrawable((R.drawable.rc_ext_input_panel_emoji))); + } + + } + + public EditText getEditText() { + return this.mEditText; + } + + public View getRootView() { + return this.mInputPanel; + } + + public void setVisible(int viewId, boolean visible) { + this.mInputPanel.findViewById(viewId).setVisibility(visible ? VISIBLE : View.GONE); + } + + public void setInputPanelStyle(InputPanel.InputStyle style) { + switch (style) { + case STYLE_SWITCH_CONTAINER_EXTENSION: + this.setSCE(); + break; + case STYLE_CONTAINER: + this.setC(); + break; + case STYLE_CONTAINER_EXTENSION: + this.setCE(); + break; + case STYLE_SWITCH_CONTAINER: + this.setSC(); + break; + default: + this.setSCE(); + } + + this.mInputStyle = style; + } + + private void setSCE() { + if (this.mInputPanel != null) { + this.mVoiceToggleBtn.setVisibility(VISIBLE); + this.mEmojiToggleBtn.setVisibility(VISIBLE); + this.mAddBtn.setVisibility(VISIBLE); + } + + } + + private void setC() { + if (this.mInputPanel != null) { + this.mVoiceToggleBtn.setVisibility(View.GONE); + this.mAddOrSendBtn.setVisibility(View.GONE); + this.mEmojiToggleBtn.setVisibility(View.GONE); + this.mAddBtn.setVisibility(View.GONE); + this.mSendBtn.setVisibility(View.GONE); + } + + } + + private void setCE() { + if (this.mInputPanel != null) { + this.mVoiceToggleBtn.setVisibility(View.GONE); + this.mAddOrSendBtn.setVisibility(VISIBLE); + this.mEmojiToggleBtn.setVisibility(VISIBLE); + this.mAddBtn.setVisibility(VISIBLE); + } + + } + + private void setSC() { + if (this.mInputPanel != null) { + this.mVoiceToggleBtn.setVisibility(VISIBLE); + this.mAddOrSendBtn.setVisibility(View.GONE); + this.mAddBtn.setVisibility(View.GONE); + } + + } + + private void getDraft() { + RongIMClient.getInstance().getTextMessageDraft(this.mConversationType, this.mTargetId, new RongIMClient.ResultCallback() { + public void onSuccess(String s) { + if (!TextUtils.isEmpty(s)) { + InputPanel.this.mInitialDraft = s; + InputPanel.this.mEditText.setText(s); + InputPanel.this.mEditText.setSelection(s.length()); + InputPanel.this.mEditText.requestFocus(); + } + + } + + public void onError(RongIMClient.ErrorCode errorCode) { + } + }); + } + + public void onDestroy() { + this.mFragment = null; + this.mExtensionViewModel = null; + if (this.mEditText != null && this.mEditText.getText() != null && !this.mInitialDraft.equals(this.mEditText.getText().toString())) { + IMCenter.getInstance().saveTextMessageDraft(this.mConversationType, this.mTargetId, this.mEditText.getText().toString(), (RongIMClient.ResultCallback) null); + } + + } + + public static enum InputStyle { + STYLE_SWITCH_CONTAINER_EXTENSION(291), + STYLE_SWITCH_CONTAINER(288), + STYLE_CONTAINER_EXTENSION(35), + STYLE_CONTAINER(32); + + int v; + + private InputStyle(int v) { + this.v = v; + } + + public static InputPanel.InputStyle getStyle(int v) { + InputPanel.InputStyle result = null; + InputPanel.InputStyle[] var2 = values(); + int var3 = var2.length; + + for (int var4 = 0; var4 < var3; ++var4) { + InputPanel.InputStyle style = var2[var4]; + if (style.v == v) { + result = style; + break; + } + } + + return result; + } + } +} 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 b832da155..81e899443 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -6,9 +6,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.SystemClock; -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -20,6 +17,10 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; import com.alibaba.fastjson.JSON; @@ -695,8 +696,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); mChatRecyclerView.setAdapter(mLiveChatAdapter); - -// mVotesName.setText(CommonAppConfig.getInstance().getVotesName()); mBtnFollow.setOnClickListener(this); mViewMedal.setOnClickListener(this); findViewById(R.id.btn_close).setOnClickListener(this); @@ -720,7 +719,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } mLightAnimPresenter = new LiveLightAnimPresenter(mContext, mParentView); mLiveEnterRoomAnimPresenter = new LiveEnterRoomAnimPresenter(mContext, mContentView, mScreenWdith); -// LiveAudienceActivity.liveLinkMicDrPkPresenter = new LiveLinkMicDrPkPresenter(mLiveUid,mContext, mLivePlayViewHolder, false, null); mLiveRoomHandler = new LiveRoomHandler(this); mRefreshUserListCallback = new HttpCallback() { @Override @@ -989,12 +987,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 显示直播标题 */ public void setTitle(String title) { -// if (!TextUtils.isEmpty(title)) { -// if (mLiveGiftAnimPresenter == null) { -// mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer); -// } -// mLiveGiftAnimPresenter.showLiveTitleAnim(title); -// } } @@ -1006,11 +998,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis isAttention = attention; if (mBtnFollow != null) { if (attention == 0) { -// if (mBtnFollow.getVisibility() != View.VISIBLE) { mBtnFollow.setVisibility(View.VISIBLE); mViewMedal.setVisibility(View.GONE); -// } - } else { if (mBtnFollow.getVisibility() == View.VISIBLE) { mBtnFollow.setVisibility(View.GONE); @@ -1043,15 +1032,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if (LivePushTxViewHolder.mTRTCCloud != null) { } else { -// touid = touids; -// ImgLoader.displayAvatar(mContext, url, avatarOther); -// tv_avatarOther_name.setText(name); -// goto_room_view.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// showUserDialog(touids); -// } -// }); } } @@ -1059,51 +1039,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis goto_room_view.setVisibility(View.GONE); } -// private LiveRoomCheckLivePresenter mCheckLivePresenter; -// private void gotoLive(final String live_id) { -// LiveHttpUtil.qBackRoom(mLiveUid, mStream, new HttpCallback() { -// @Override -// public void onSuccess(int code, String msg, String[] info) { -// LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() { -// @Override -// public void onSuccess(int code, String msg, String[] info) { -// if (code == 0 && info.length > 0) { -// LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); -// V2TIMManager.getInstance().quitGroup("g" + mLiveUid, new V2TIMCallback() { -// @Override -// public void onSuccess() { -// CommonAppContext.Ingroup = 0; -// if (mCheckLivePresenter == null) { -// mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() { -// @Override -// public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) { -// if (liveBean == null) { -// return; -// } -// -// LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); -//// if (mFromLiveRoom) { -//// ((UserHomeActivity) mContext).onBackPressed(); -// EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal)); -//// } else { -//// LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); -//// } -// } -// }); -// } -// mCheckLivePresenter.checkLive(liveBean); -// } -// -// @Override -// public void onError(int code, String desc) { -// } -// }); -// } -// } -// }); -// } -// }); -// } /** * 显示刷新直播间用户列表 @@ -1118,9 +1053,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 显示主播映票数 */ public void setVotes(String votes) { -// if (mVotes != null) { -// mVotes.setText(votes); -// } } /** @@ -1185,11 +1117,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void onGuardInfoChanged(LiveBuyGuardMsgBean bean) { setGuardNum(bean.getGuardNum()); -// setVotes(bean.getVotes()); -// if (mLiveUserAdapter != null) { -// refreshUserList(); -// mLiveUserAdapter.onGuardChanged(bean.getUid(), bean.getGuardType()); -// } } /** @@ -1371,33 +1298,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis isStayRoomfive = isTrue; } - /** - * 用户进入房间,用户列表添加该用户 - */ -// public void insertUser(LiveUserGiftBean bean) { -// if (mLiveUserAdapter != null) { -//// mLiveUserAdapter.insertItem(bean); -// } -// } - -// /** -// * 用户进入房间,添加僵尸粉 -// */ -// public void insertUser(List list) { -// if (mLiveUserAdapter != null) { -// refreshUserList(); -//// mLiveUserAdapter.insertList(list); -// } -// } - -// /** -// * 用户离开房间,用户列表删除该用户 -// */ -// public void removeUser(String uid) { -// if (mLiveUserAdapter != null) { -// mLiveUserAdapter.removeItem(uid); -// } -// } /** * 刷新用户列表 @@ -1405,11 +1305,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void refreshUserList(JSONObject obj) { List list = JSON.parseArray(obj.getString("userlist"), LiveUserGiftBean.class); mLiveUserAdapter.refreshList(list); -// if (!TextUtils.isEmpty(mLiveUid) && mRefreshUserListCallback != null && mLiveUserAdapter != null) { -// LiveHttpUtil.cancel(LiveHttpConsts.GET_USER_LIST); -// LiveHttpUtil.getUserList(mLiveUid, mStream, "guanzhong",1,mRefreshUserListCallback); -// startRefreshUserList(); -// } } /** @@ -1598,9 +1493,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mVotes.setText(bean.getVotes()); room_hot.setText(formatBigNum.formatBigNum(bean.getHot_num())); mTvMedalRank.setText(bean.getMedalRankNum()); - //开通粉丝勋章成功弹窗 -// if (bean.getMedalFirstGet()!=null && bean.getMedalFirstGet().equals("1")) -// ((LiveAudienceActivity) mContext).openFansMedalOkWindow(); if (mLiveGiftAnimPresenter == null) { mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager); } @@ -1617,21 +1509,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis //开通粉丝勋章成功弹窗 if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1") && bean.getUid().equals(CommonAppConfig.getInstance().getUid())) { -// UserBean userBean = CommonAppConfig.getInstance().getUserBean(); -// userBean.setMedalName(bean.getMedalRankNum()); ((LiveAudienceActivity) mContext).openFansMedalOkWindow(); -// ((LiveAudienceActivity) mContext).openFansMedalOkWindow(); } Log.i("tvss", bean.getDrpk_status() + "是" + mLiveUid + "vsss" + bean.getRoomnum()); if (mLiveGiftAnimPresenter == null) { -// if(bean.getDrpk_status().equals("0")){ -// mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer); -// }else{ -// if(!mLiveUid.equals(bean.getRoomnum())){ mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager); -// } -// } } mLiveGiftAnimPresenter.showGiftAnim(bean, isAncher); } @@ -1639,7 +1522,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis //全服通知 购买守护 public void showGuardGifMessage(LiveReceiveGiftBean bean) { mVotes.setText(bean.getVotes()); -// mTvMedalRank.setText(bean.getMedalRankNum()); if (mLiveGiftAnimPresenter == null) { mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager); } @@ -1824,12 +1706,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 显示奖池按钮 */ public void showPrizePoolLevel(String level) { - /* if (mBtnPrizePool != null && mBtnPrizePool.getVisibility() != View.VISIBLE) { - mBtnPrizePool.setVisibility(View.VISIBLE); - } - if (mPrizePoolLevel != null) { - mPrizePoolLevel.setText(String.format(WordUtil.getString(R.string.live_gift_prize_pool_3), level)); - }*/ } /** diff --git a/live/src/main/java/com/yunbao/live/views/SystemChatMessageViewHolder.java b/live/src/main/java/com/yunbao/live/views/SystemChatMessageViewHolder.java new file mode 100644 index 000000000..971a435a4 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/views/SystemChatMessageViewHolder.java @@ -0,0 +1,47 @@ +package com.yunbao.live.views; + +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.live.R; +import com.yunbao.live.bean.ImUserBean; + +/** + * 系统消息界面 + */ +public class SystemChatMessageViewHolder extends RecyclerView.ViewHolder { + public RoundedImageView avatarImage; + public TextView userName, userMsg, lastTime, redPoint; + private ViewHolderOnClickListener listener; + private ImUserBean model; + + public SystemChatMessageViewHolder(@NonNull View itemView) { + super(itemView); + avatarImage = itemView.findViewById(R.id.avatar); + userName = itemView.findViewById(R.id.name); + userMsg = itemView.findViewById(R.id.msg); + lastTime = itemView.findViewById(R.id.time); + redPoint = itemView.findViewById(R.id.red_point); + itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (null != listener) { + listener.onClick(v, model); + } + } + }); + } + + public interface ViewHolderOnClickListener { + void onClick(View view, ImUserBean model); + } + + public void setViewHolderOnClickListener(ViewHolderOnClickListener listener, ImUserBean model) { + this.listener = listener; + this.model = model; + } +} diff --git a/live/src/main/res/layout/activity_pd_chat.xml b/live/src/main/res/layout/activity_pd_chat.xml index 486208db1..0b134e005 100644 --- a/live/src/main/res/layout/activity_pd_chat.xml +++ b/live/src/main/res/layout/activity_pd_chat.xml @@ -2,13 +2,14 @@ - \ No newline at end of file diff --git a/live/src/main/res/layout/view_layout_msg.xml b/live/src/main/res/layout/view_layout_msg.xml index 4a89af0e8..7ac3a1710 100644 --- a/live/src/main/res/layout/view_layout_msg.xml +++ b/live/src/main/res/layout/view_layout_msg.xml @@ -1,7 +1,6 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_system_message_item.xml b/live/src/main/res/layout/view_system_message_item.xml new file mode 100644 index 000000000..0d14049b3 --- /dev/null +++ b/live/src/main/res/layout/view_system_message_item.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index b8ea29265..d143dd348 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -67,6 +67,7 @@ import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.live.LiveConfig; import com.yunbao.live.activity.LiveAnchorActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.activity.PDLIiveChatActivity; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.http.LiveHttpConsts; diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java index cbd984bbe..0feb0a29b 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java @@ -53,7 +53,7 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveReportActivity; -import com.yunbao.live.activity.SystemMessageActivity; +import com.yunbao.live.activity.PDLiveConversationActivity; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.ReportCommunityBean; import com.yunbao.live.event.LiveRoomChangeEvent; @@ -294,7 +294,6 @@ public class MyWebViewActivity extends AbsActivity { @JavascriptInterface public void androidClickSayHiBack(String uid, String name, String img) { Constants.firstInto = 0; -// SystemMessageActivity.forward(mContext, "-2", uid, name, img); ConversationIMListManager.get(mContext).jumpConversation(mContext, uid); } diff --git a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java index b6ffb3230..e908eb5cb 100644 --- a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java +++ b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java @@ -39,6 +39,7 @@ public class ConversationIMListManager { RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationListActivity, PDLiveConversationListActivity.class); //将自定义会话列表 Activity 注册到 IMKit SDK: RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationListActivity, PDLIiveChatActivity.class); + RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationActivity, PDLiveConversationActivity.class); RongConfigCenter.conversationListConfig().setDataProcessor(new PDLiveMessageProcessor()); //获取会话模板管理器 ProviderManager providerManager = RongConfigCenter.conversationListConfig().getProviderManager(); @@ -92,7 +93,7 @@ public class ConversationIMListManager { * @param targetId 用户id */ public void jumpConversation(Activity context,String targetId) { - RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationActivity, PDLiveConversationActivity.class); + Intent intent = new Intent(context, PDLiveConversationActivity.class); intent.putExtra(RouteUtils.TARGET_ID, targetId); context.startActivity(intent); diff --git a/main/src/main/res/layout/rc_extension_input_panel.xml b/main/src/main/res/layout/rc_extension_input_panel.xml deleted file mode 100644 index b01eea0eb..000000000 --- a/main/src/main/res/layout/rc_extension_input_panel.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - -