6.6.9版本
This commit is contained in:
@@ -59,6 +59,7 @@ import com.yunbao.main.R;
|
||||
import com.yunbao.main.event.EditProfileEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.yunbao.common.utils.ListUtils;
|
||||
import com.yunbao.common.utils.RandomUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ViewPageIndicatorUtils;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MainMsgAddressBookListAdapter;
|
||||
@@ -224,7 +225,7 @@ public class MsgAddressBookActivity extends AbsActivity {
|
||||
}
|
||||
});
|
||||
mIndicator.setNavigator(commonNavigator);
|
||||
bind(mIndicator, mViewPager);
|
||||
ViewPageIndicatorUtils.bind(mIndicator, mViewPager,null);
|
||||
}
|
||||
|
||||
private void initViewPager() {
|
||||
@@ -311,27 +312,7 @@ public class MsgAddressBookActivity extends AbsActivity {
|
||||
});
|
||||
}
|
||||
|
||||
public static void bind(final MagicIndicator magicIndicator, ViewPager2 viewPager) {
|
||||
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
magicIndicator.onPageSelected(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
super.onPageScrollStateChanged(state);
|
||||
magicIndicator.onPageScrollStateChanged(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<MessageChatUserBean> createTempData(int type) {
|
||||
List<MessageChatUserBean> list = new ArrayList<>();
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
@@ -53,6 +54,7 @@ import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.ViewUtils;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.live.dialog.MenuPopuwWindow;
|
||||
import com.yunbao.live.event.InputPanelViewHolderEvent;
|
||||
@@ -63,7 +65,6 @@ import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MessageChatTopImageListAdapter;
|
||||
import com.yunbao.main.adapter.MessageChatTopTopListAdapter;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -262,8 +263,11 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
||||
|
||||
}
|
||||
});
|
||||
ViewUtils.findViewById(card, R.id.rc_conversation_portrait, ImageView.class).setOnClickListener(view -> {
|
||||
RouteUtil.forwardUserHome(targetId);
|
||||
ViewClicksAntiShake.clicksAntiShake(ViewUtils.findViewById(card, R.id.rc_conversation_portrait, ImageView.class), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteUtil.forwardUserHome(targetId);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -297,10 +301,10 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
||||
showBanner();
|
||||
showTag();
|
||||
if (data.getUser().getAttention() <= 1) {
|
||||
ViewUtils.findViewById(card, R.id.follow, Button.class).setOnClickListener(new View.OnClickListener() {
|
||||
ViewClicksAntiShake.clicksAntiShake(ViewUtils.findViewById(card, R.id.follow, Button.class), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
follow((Button) view, userInfoBean.getUser().getId() + "");
|
||||
public void onViewClicks() {
|
||||
follow(ViewUtils.findViewById(card, R.id.follow, Button.class), userInfoBean.getUser().getId() + "");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -313,30 +317,33 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
||||
public void onSuccess(List<Integer> data) {
|
||||
if (data.contains(Integer.parseInt(targetId))) {
|
||||
ViewUtils.findViewById(card, R.id.liveStatus).setVisibility(View.VISIBLE);
|
||||
ViewUtils.findViewById(card, R.id.liveStatus).setOnClickListener(view -> {
|
||||
LiveHttpUtil.getLiveInfo(targetId, new com.yunbao.common.http.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);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
ViewClicksAntiShake.clicksAntiShake(ViewUtils.findViewById(card, R.id.liveStatus), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
LiveHttpUtil.getLiveInfo(targetId, new com.yunbao.common.http.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);
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
liveBean.setParams(new HashMap<>());
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
liveBean.setParams(new HashMap<>());
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -413,7 +420,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
||||
JSONArray array = JSONArray.parseArray(Arrays.toString(info));
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject json = array.getJSONObject(0);
|
||||
if (json.containsKey(targetId)) {
|
||||
if (json.containsKey(targetId) && !StringUtil.isEmpty(json.getString(targetId))) {
|
||||
titleView.setText(json.getString(targetId));
|
||||
ViewUtils.findViewById(card, R.id.userName, TextView.class).setText(json.getString(targetId));
|
||||
return;
|
||||
|
||||
@@ -14,25 +14,42 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.yunbao.common.bean.MainMessageChatListTimer;
|
||||
import com.yunbao.common.dialog.DebugDialog;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnRecyclerListRefreshListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.message.content.MessageChatCardContent;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.DateFormatUtil;
|
||||
import com.yunbao.common.utils.ListUtils;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.ViewUtils;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.main.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.conversationlist.ConversationListAdapter;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.MessageContent;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
public static final int TYPE_SEARCH_TITLE = 500;
|
||||
@@ -40,12 +57,18 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
public static final int TYPE_SEARCH_CHAT = 520;
|
||||
private List<BaseUiConversation> srcList;
|
||||
private Context mContext;
|
||||
private boolean isChat=true;
|
||||
private boolean isChat = true;
|
||||
private OnRecyclerListRefreshListener<List<BaseUiConversation>> onRefreshListener;
|
||||
private Map<String, Integer> timerMap = new HashMap<>();
|
||||
|
||||
public MainConversationListAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setOnRefreshListener(OnRecyclerListRefreshListener<List<BaseUiConversation>> onRefreshListener) {
|
||||
this.onRefreshListener = onRefreshListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
@@ -92,7 +115,7 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
if (isEmpty() || mDataList.isEmpty()) {
|
||||
bindEmpty(holder, position);
|
||||
bindEmpty(holder, position);
|
||||
return;
|
||||
}
|
||||
if (getItemViewType(position) == TYPE_SEARCH_USER) {
|
||||
@@ -104,28 +127,90 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
} else if (getItemViewType(position) != -200) {
|
||||
super.onBindViewHolder(holder, position);
|
||||
}
|
||||
if (getItemViewType(position) != -200) {
|
||||
bindDefault(holder, position);
|
||||
}
|
||||
}
|
||||
|
||||
private void bindDefault(ViewHolder holder, int position) {
|
||||
BaseUiConversation conversation = mDataList.get(position);
|
||||
Log.i("列表", "bindDefault: 用户头像:" + conversation.mCore.getPortraitUrl());
|
||||
Log.i("列表", "bindDefault: 用户名字:" + conversation.mCore.getConversationTitle());
|
||||
ImgLoader.display(holder.getContext(), conversation.mCore.getPortraitUrl(), holder.getView(R.id.rc_conversation_portrait));
|
||||
holder.setText(R.id.rc_conversation_title, conversation.mCore.getConversationTitle());
|
||||
if (conversation.mCore.getSentTime() != -1 && holder.getView(R.id.rc_conversation_date) != null) {
|
||||
holder.setText(R.id.rc_conversation_date, DateFormatUtil.getDateTimeString(conversation.mCore.getSentTime(), true, holder.getContext()));
|
||||
holder.getView(R.id.rc_conversation_date).setVisibility(View.VISIBLE);
|
||||
} else if (holder.getView(R.id.rc_conversation_date) != null) {
|
||||
holder.getView(R.id.rc_conversation_date).setVisibility(View.GONE);
|
||||
}
|
||||
if (holder.getView(R.id.rc_conversation_live_status) == null || IMLoginManager.get(holder.getContext()).getAnchorB() != 1) {
|
||||
return;
|
||||
}
|
||||
Integer timer = timerMap.get(mDataList.get(position).mCore.getTargetId());
|
||||
if (timer == null) {
|
||||
holder.getView(R.id.rc_conversation_live_status).setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (timer >= 10) {
|
||||
holder.setText(R.id.rc_conversation_live_status,
|
||||
String.format(WordUtil.getNewString(R.string.message_chat_msg_look_live), timer)
|
||||
);
|
||||
holder.getView(R.id.rc_conversation_live_status).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.getView(R.id.rc_conversation_live_status).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void bindEmpty(ViewHolder holder, int position) {
|
||||
if(isChat){
|
||||
ViewUtils.findViewById(holder.itemView,R.id.imageView, ImageView.class).setImageResource(R.mipmap.ic_message_not_chat_list);
|
||||
ViewUtils.findViewById(holder.itemView,R.id.textView, TextView.class).setText(R.string.not_data_message_chat_list);
|
||||
}else{
|
||||
ViewUtils.findViewById(holder.itemView,R.id.imageView, ImageView.class).setImageResource(R.mipmap.ic_message_not_search);
|
||||
ViewUtils.findViewById(holder.itemView,R.id.textView, TextView.class).setText(R.string.not_data_message_chat_list_search);
|
||||
if (isChat) {
|
||||
ViewUtils.findViewById(holder.itemView, R.id.imageView, ImageView.class).setImageResource(R.mipmap.ic_message_not_chat_list);
|
||||
ViewUtils.findViewById(holder.itemView, R.id.textView, TextView.class).setText(R.string.not_data_message_chat_list);
|
||||
} else {
|
||||
ViewUtils.findViewById(holder.itemView, R.id.imageView, ImageView.class).setImageResource(R.mipmap.ic_message_not_search);
|
||||
ViewUtils.findViewById(holder.itemView, R.id.textView, TextView.class).setText(R.string.not_data_message_chat_list_search);
|
||||
}
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
if (onRefreshListener != null) {
|
||||
Log.i("聊天数据源", "设置数据源: " + mDataList.size());
|
||||
onRefreshListener.onFinish(mDataList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataCollection(List<BaseUiConversation> data) {
|
||||
List<BaseUiConversation> tmp = new ArrayList<>();
|
||||
Log.i("聊天数据源", "setDataCollection: " + data.hashCode());
|
||||
List<String> urls = new ArrayList<>();
|
||||
if (srcList == null) {
|
||||
srcList = new ArrayList<>();
|
||||
}
|
||||
mDataList.clear();
|
||||
srcList.clear();
|
||||
if (mContext == null)
|
||||
mContext = AppManager.getInstance().getLastActivity();
|
||||
for (BaseUiConversation item : data) {
|
||||
if (urls.contains(item.mCore.getTargetId())) continue;
|
||||
if (item.mConversationContent != null && item.mConversationContent.toString().contains("_method_")) {
|
||||
IMCenter.getInstance().deleteMessages(Conversation.ConversationType.PRIVATE,
|
||||
item.mCore.getTargetId(),
|
||||
new int[]{item.mCore.getLatestMessageId()},
|
||||
new RongIMClient.ResultCallback<Boolean>() {
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
Log.i("PDMessageInterceptor", "onSuccess: 删除成功:" + aBoolean + " " + item.mCore.getLatestMessageId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
Log.i("PDMessageInterceptor", "onSuccess: 删除失败:" + errorCode);
|
||||
}
|
||||
}
|
||||
);
|
||||
IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, item.mCore.getTargetId(), null);
|
||||
}
|
||||
urls.add(item.mCore.getTargetId());
|
||||
Log.i("聊天数据源", item.mCore.getConversationTitle() + "|" + item.mCore.getPortraitUrl() + "|" + item.mCore.getTargetId());
|
||||
BaseUiConversation cn = new SingleConversation(mContext, item.mCore);
|
||||
srcList.add(cn);
|
||||
|
||||
@@ -134,9 +219,17 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
item.mConversationContent = new SpannableString(WordUtil.getNewString(R.string.activity_msg_chat_list_card));
|
||||
}
|
||||
}
|
||||
tmp.add(item);
|
||||
}
|
||||
// ToastUtil.showDebug("消息数:"+data.size());
|
||||
super.setDataCollection(tmp);
|
||||
}
|
||||
|
||||
super.setDataCollection(data);
|
||||
public void clear() {
|
||||
mDataList.clear();
|
||||
if (srcList != null) {
|
||||
srcList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseUiConversation> getSrcList() {
|
||||
@@ -172,8 +265,11 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
||||
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
|
||||
}
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
RouteUtils.routeToConversationActivity(view.getContext(), mDataList.get(position).mCore.getConversationType(), mDataList.get(position).mCore.getTargetId());
|
||||
ViewClicksAntiShake.clicksAntiShake(holder.itemView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteUtils.routeToConversationActivity(holder.itemView.getContext(), mDataList.get(position).mCore.getConversationType(), mDataList.get(position).mCore.getTargetId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,16 +295,57 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
||||
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
|
||||
}
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
RouteUtils.routeToConversationActivity(view.getContext(), mDataList.get(position).mCore.getConversationType(), mDataList.get(position).mCore.getTargetId());
|
||||
ViewClicksAntiShake.clicksAntiShake(holder.itemView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
RouteUtils.routeToConversationActivity(holder.itemView.getContext(), mDataList.get(position).mCore.getConversationType(), mDataList.get(position).mCore.getTargetId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setChat() {
|
||||
isChat=true;
|
||||
isChat = true;
|
||||
}
|
||||
|
||||
public void setSearch() {
|
||||
isChat=false;
|
||||
isChat = false;
|
||||
}
|
||||
|
||||
public void setTimerMap(Map<String, Integer> timerMap) {
|
||||
this.timerMap.putAll(timerMap);
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public int getMessageId(String senderUserId) {
|
||||
for (int i = 0; i < mDataList.size(); i++) {
|
||||
if (mDataList.get(i).mCore.getTargetId().equals(senderUserId)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void update(Message bean, int id) {
|
||||
RongIMClient.getInstance().getUnreadCount(Conversation.ConversationType.PRIVATE, bean.getTargetId(), new RongIMClient.ResultCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer integer) {
|
||||
BaseUiConversation conversation = mDataList.get(id);
|
||||
conversation.mCore.setSentTime(bean.getSentTime());
|
||||
conversation.mCore.setUnreadMessageCount(integer);
|
||||
conversation.mConversationContent = new SpannableString(((TextMessage) bean.getContent()).getContent());
|
||||
mDataList.set(id, conversation);
|
||||
notifyItemChanged(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
BaseUiConversation conversation = mDataList.get(id);
|
||||
conversation.mCore.setSentTime(bean.getSentTime());
|
||||
conversation.mConversationContent = new SpannableString(((TextMessage) bean.getContent()).getContent());
|
||||
mDataList.set(id, conversation);
|
||||
notifyItemChanged(id);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.MainMessageChatListTimer;
|
||||
import com.yunbao.common.dialog.DebugDialog;
|
||||
import com.yunbao.common.event.MessageIMEvent;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnRecyclerListRefreshListener;
|
||||
import com.yunbao.common.manager.base.ACache;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.main.adapter.MainConversationListAdapter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imlib.RongCoreClient;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.ReceivedProfile;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
public abstract class AbsMainMessageChatListFragment extends Fragment {
|
||||
RecyclerView recyclerView;
|
||||
MainConversationListAdapter mAdapter;
|
||||
SmartRefreshLayout refreshLayout;
|
||||
|
||||
public void setAdapter(MainConversationListAdapter mAdapter) {
|
||||
this.mAdapter = mAdapter;
|
||||
}
|
||||
|
||||
|
||||
public abstract void onChatList();
|
||||
|
||||
public abstract void search(String string);
|
||||
|
||||
public abstract void updateList();
|
||||
|
||||
public void onTest() {
|
||||
}
|
||||
|
||||
public void onRefreshFinished() {
|
||||
if (refreshLayout != null) {
|
||||
refreshLayout.finishRefresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onLoadMoreFinished() {
|
||||
if (refreshLayout != null) {
|
||||
refreshLayout.finishLoadMore(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
private static long lastTime;
|
||||
private static boolean isNet = false;
|
||||
Map<String, BaseUiConversation> map = new HashMap<>();
|
||||
|
||||
public void loadLiveLookTime(List<BaseUiConversation> srcList, OnRecyclerListRefreshListener<Map<String, Integer>> onRefreshListener) {
|
||||
/* if (System.currentTimeMillis() - lastTime > 200 || isNet) {
|
||||
for (BaseUiConversation conversation : srcList) {
|
||||
if (map.containsKey(conversation.mCore.getTargetId())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
lastTime = System.currentTimeMillis();
|
||||
isNet = true;
|
||||
List<String> uids = new ArrayList<>();
|
||||
for (BaseUiConversation conversation : srcList) {
|
||||
map.put(conversation.mCore.getTargetId(), conversation);
|
||||
if (conversation.mCore.getConversationType() == Conversation.ConversationType.PRIVATE) {
|
||||
uids.add(conversation.mCore.getTargetId());
|
||||
}
|
||||
}
|
||||
LiveNetManager.get(getContext())
|
||||
.getIsLook(String.join(",", uids), new HttpCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(List<MainMessageChatListTimer> data) {
|
||||
Map<String, Integer> timerMap = new HashMap<>();
|
||||
for (MainMessageChatListTimer timer : data) {
|
||||
timerMap.put(timer.getUid(), timer.getTime());
|
||||
}
|
||||
onRefreshListener.onFinish(timerMap);
|
||||
isNet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
isNet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void sendMessage(io.rong.imlib.model.Message bean) {
|
||||
int id1 = mAdapter.getMessageId(bean.getSenderUserId());
|
||||
int id2 = mAdapter.getMessageId(bean.getTargetId());
|
||||
if (id1 != -1) {
|
||||
mAdapter.update(bean, id1);
|
||||
}
|
||||
if (id2 != -1) {
|
||||
mAdapter.update(bean, id2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
@@ -17,36 +19,72 @@ import com.yunbao.main.adapter.MainConversationListAdapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.common.rlog.RLog;
|
||||
import io.rong.imkit.conversationlist.ConversationListAdapter;
|
||||
import io.rong.imkit.conversationlist.ConversationListFragment;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.event.Event;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.SearchConversationResult;
|
||||
|
||||
public class MainMessageChatFragment extends ConversationListFragment {
|
||||
|
||||
private static final String TAG = "融云列表";
|
||||
int listHashCode = 0;
|
||||
|
||||
@Nullable
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
Log.i(TAG, "onCreateView: 创建融云");
|
||||
return inflater.inflate(R.layout.rc_conversationlist_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Log.i(TAG, "onViewCreated:创建融云页面");
|
||||
mConversationListViewModel.getConversationListLiveData().observe(this.getViewLifecycleOwner(), new Observer<List<BaseUiConversation>>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onChanged(List<BaseUiConversation> uiConversations) {
|
||||
if (listHashCode != uiConversations.hashCode()) {
|
||||
listHashCode = uiConversations.hashCode();
|
||||
((MainConversationListAdapter) mAdapter).onFinish();
|
||||
}
|
||||
}
|
||||
});
|
||||
mConversationListViewModel.getRefreshEventLiveData().observe(this.getViewLifecycleOwner(), new Observer<Event.RefreshEvent>() {
|
||||
@Override
|
||||
public void onChanged(Event.RefreshEvent refreshEvent) {
|
||||
listHashCode = 0;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setEmptyView(int viewLayoutMsgId) {
|
||||
super.setEmptyView(viewLayoutMsgId);
|
||||
}
|
||||
public void setEmptyView(View view){
|
||||
|
||||
public void setEmptyView(View view) {
|
||||
super.setEmptyView(view);
|
||||
}
|
||||
|
||||
|
||||
public void search(String search) {
|
||||
((MainConversationListAdapter)mAdapter).setSearch();
|
||||
((MainConversationListAdapter) mAdapter).setSearch();
|
||||
getContactsList(search);
|
||||
}
|
||||
|
||||
public MainConversationListAdapter getAdapter() {
|
||||
return (MainConversationListAdapter) mAdapter;
|
||||
}
|
||||
|
||||
private void getContactsList(String search) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
List<String> uidList = new ArrayList<>();
|
||||
|
||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_contacts));
|
||||
@@ -58,6 +96,8 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
||||
for (BaseUiConversation cn : ((MainConversationListAdapter) mAdapter).getSrcList()) {
|
||||
System.err.println(" ----------------------->" + cn.mCore.getConversationTitle() + "|" + cn.mCore.getSenderUserName());
|
||||
if (StringUtil.isEmpty(cn.mCore.getConversationTitle())) continue;
|
||||
if (uidList.contains(cn.mCore.getTargetId())) continue;
|
||||
uidList.add(cn.mCore.getTargetId());
|
||||
if (cn.mCore.getConversationTitle().contains(search)) {
|
||||
conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_USER" + search);
|
||||
@@ -121,8 +161,12 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
||||
}
|
||||
|
||||
public void onChatList() {
|
||||
((MainConversationListAdapter)mAdapter).setChat();
|
||||
if(mConversationListViewModel==null)return;
|
||||
((MainConversationListAdapter) mAdapter).setChat();
|
||||
((MainConversationListAdapter) mAdapter).clear();
|
||||
System.out.println(">!>!>!>!!>"+mConversationListViewModel);
|
||||
subscribeUi();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.yunbao.common.interfaces.OnRecyclerListRefreshListener;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
|
||||
public class MainMessageChatListFragment extends AbsMainMessageChatListFragment {
|
||||
private static final String TAG = "MainMessageChatListFragment";
|
||||
private Context mContext;
|
||||
|
||||
public MainMessageChatListFragment() {
|
||||
this.mContext = AppManager.getInstance().getMainActivity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_main_message_chat_list, container, false);
|
||||
}
|
||||
|
||||
MainMessageChatFragment conversationListFragment;
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Log.i(TAG, "onViewCreated: 准备创建融云");
|
||||
conversationListFragment = new MainMessageChatFragment();
|
||||
setAdapter(conversationListFragment.getAdapter());
|
||||
FragmentManager manager = ((FragmentActivity) mContext).getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
//conversationListFragment.setEmptyView(emptyView);
|
||||
conversationListFragment.setEmptyView(R.layout.view_layout_msg);
|
||||
conversationListFragment.getAdapter().setOnRefreshListener(new OnRecyclerListRefreshListener<List<BaseUiConversation>>() {
|
||||
@Override
|
||||
public void onFinish(List<BaseUiConversation> baseUiConversations) {
|
||||
loadLiveLookTime(baseUiConversations, new OnRecyclerListRefreshListener<Map<String, Integer>>() {
|
||||
@Override
|
||||
public void onFinish(Map<String, Integer> stringIntegerMap) {
|
||||
conversationListFragment.getAdapter().setTimerMap(stringIntegerMap);
|
||||
updateList();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void onChatList() {
|
||||
if (conversationListFragment == null) {
|
||||
return;
|
||||
}
|
||||
ToastUtil.showDebug("清空");
|
||||
conversationListFragment.onChatList();
|
||||
}
|
||||
|
||||
public void search(String string) {
|
||||
if (conversationListFragment == null) {
|
||||
return;
|
||||
}
|
||||
conversationListFragment.search(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateList() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.yunbao.common.bean.MessageChatUserBean;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnRecyclerListRefreshListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.InstructorRemarkManager;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MainConversationListAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imkit.userinfo.UserDataProvider;
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.adapter.BaseAdapter;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.SearchConversationResult;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
public class MainMessageChatListSystemFragment extends AbsMainMessageChatListFragment {
|
||||
private static final String TAG = "系统列表";
|
||||
|
||||
private List<String> needLoadInfo = new ArrayList<>();
|
||||
|
||||
|
||||
public MainMessageChatListSystemFragment() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.rc_conversationlist_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
refreshLayout = view.findViewById(R.id.rc_refresh);
|
||||
recyclerView = view.findViewById(R.id.rc_conversation_list);
|
||||
refreshLayout.setNestedScrollingEnabled(false);
|
||||
refreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
refreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
mAdapter = new MainConversationListAdapter(view.getContext());
|
||||
mAdapter.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
mAdapter.setItemClickListener(new BaseAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, ViewHolder holder, int position) {
|
||||
BaseUiConversation conversation = mAdapter.getSrcList().get(position);
|
||||
RouteUtils.routeToConversationActivity(view.getContext(), Conversation.ConversationType.PRIVATE, conversation.mCore.getTargetId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, ViewHolder holder, int position) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mAdapter.setOnRefreshListener(new OnRecyclerListRefreshListener<List<BaseUiConversation>>() {
|
||||
@Override
|
||||
public void onFinish(List<BaseUiConversation> baseUiConversations) {
|
||||
loadLiveLookTime(baseUiConversations, new OnRecyclerListRefreshListener<Map<String, Integer>>() {
|
||||
@Override
|
||||
public void onFinish(Map<String, Integer> stringIntegerMap) {
|
||||
mAdapter.setTimerMap(stringIntegerMap);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
initRefresh();
|
||||
init();
|
||||
}
|
||||
|
||||
private void initRefresh() {
|
||||
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
Log.i(TAG, "onLoadMore: 加载更多");
|
||||
checkList();
|
||||
}
|
||||
});
|
||||
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
Log.i(TAG, "onRefresh: 刷新");
|
||||
init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private synchronized void checkList() {
|
||||
System.out.println("needLoadInfo = " + needLoadInfo.size());
|
||||
if (needLoadInfo.size() < 20) {
|
||||
getUserInfo(needLoadInfo);
|
||||
refreshLayout.setEnableLoadMore(false);
|
||||
} else {
|
||||
List<String> tmp = new ArrayList<>();
|
||||
System.out.println("tmp.size() = " + tmp.size());
|
||||
for (int i = 0; i < 20; i++) {
|
||||
tmp.add(needLoadInfo.get(i));
|
||||
}
|
||||
needLoadInfo.subList(0, 20).clear();
|
||||
System.out.println("tmp.size() = " + tmp.size());
|
||||
getUserInfo(tmp);
|
||||
refreshLayout.setEnableLoadMore(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChatList() {
|
||||
if(mAdapter==null) return;
|
||||
mAdapter.setChat();
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(String search) {
|
||||
mAdapter.setSearch();
|
||||
getContactsList(search);
|
||||
}
|
||||
|
||||
private void getContactsList(String search) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
|
||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_contacts));
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
list.add(conversation);
|
||||
|
||||
List<BaseUiConversation> data = new ArrayList<>();
|
||||
System.err.println(" ----------------------->" + mAdapter.getData().size());
|
||||
for (BaseUiConversation cn : ((MainConversationListAdapter) mAdapter).getSrcList()) {
|
||||
if (StringUtil.isEmpty(cn.mCore.getConversationTitle())) continue;
|
||||
System.err.println(" ----------------------->" + cn.mCore.getConversationTitle() + "|" + cn.mCore.getTargetId());
|
||||
if (cn.mCore.getConversationTitle().contains(search)) {
|
||||
conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_USER" + search);
|
||||
conversation.mCore.setConversationTitle(cn.mCore.getConversationTitle());
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
conversation.mCore.setPortraitUrl(cn.mCore.getPortraitUrl());
|
||||
conversation.mCore.setTargetId(cn.mCore.getTargetId());
|
||||
conversation.mCore.setSenderUserId(cn.mCore.getSenderUserId());
|
||||
data.add(conversation);
|
||||
}
|
||||
}
|
||||
if (data.size() == 1) {
|
||||
data.get(0).mCore.setMentionedCount(3);
|
||||
} else if (data.size() != 0) {
|
||||
data.get(0).mCore.setMentionedCount(1);
|
||||
data.get(data.size() - 1).mCore.setMentionedCount(2);
|
||||
} else {
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
list.addAll(data);
|
||||
getChatRecordList(list, search);
|
||||
}
|
||||
|
||||
private void getChatRecordList(List<BaseUiConversation> list, String search) {
|
||||
Conversation.ConversationType[] conversationTypes = {Conversation.ConversationType.PRIVATE};
|
||||
String[] messageTypeObjectNames = {"RC:TxtMsg"};
|
||||
|
||||
RongIMClient.getInstance().searchConversations(search, conversationTypes, messageTypeObjectNames, new RongIMClient.ResultCallback<List<SearchConversationResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SearchConversationResult> searchConversationResults) {
|
||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_chat_records));
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
list.add(conversation);
|
||||
List<BaseUiConversation> data = new ArrayList<>();
|
||||
for (SearchConversationResult result : searchConversationResults) {
|
||||
BaseUiConversation cn = new SingleConversation(getContext(), result.getConversation());
|
||||
cn.mCore.setObjectName("SEARCH_CHAT" + search);
|
||||
data.add(cn);
|
||||
}
|
||||
if (data.size() == 1) {
|
||||
data.get(0).mCore.setMentionedCount(3);
|
||||
} else if (data.size() != 0) {
|
||||
data.get(0).mCore.setMentionedCount(1);
|
||||
data.get(data.size() - 1).mCore.setMentionedCount(2);
|
||||
} else {
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
list.addAll(data);
|
||||
mAdapter.setDataCollection(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
ToastUtil.show("搜索出错了:" + e.getMessage());
|
||||
mAdapter.setDataCollection(list);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateList() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void getUserInfo(List<String> uidList) {
|
||||
String uids = String.join(",", uidList);
|
||||
LiveNetManager.get(getContext())
|
||||
.getOtherList(uids, new HttpCallback<List<MessageChatUserBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MessageChatUserBean> data) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
for (MessageChatUserBean datum : data) {
|
||||
Conversation conversation = new Conversation();
|
||||
BaseUiConversation baseUiConversation = new SingleConversation(getContext(), conversation);
|
||||
baseUiConversation.mCore.setTargetId(datum.getId());
|
||||
baseUiConversation.mCore.setSenderUserId(IMLoginManager.get(getContext()).getUserInfo().getId() + "");
|
||||
baseUiConversation.mCore.setSentStatus(Message.SentStatus.CANCELED);
|
||||
baseUiConversation.mCore.setSentTime(-1);
|
||||
baseUiConversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
baseUiConversation.mCore.setPortraitUrl(datum.getAvatar());
|
||||
String remark = InstructorRemarkManager.get(getContext()).getInstructorRemark().get(datum.getId());
|
||||
baseUiConversation.mCore.setConversationTitle(StringUtil.isEmpty(remark) ? datum.getUserNiceName() : remark);
|
||||
|
||||
list.add(baseUiConversation);
|
||||
|
||||
UserInfo userInfo = new UserInfo(baseUiConversation.mCore.getTargetId(),
|
||||
baseUiConversation.mCore.getConversationTitle(),
|
||||
Uri.parse(baseUiConversation.mCore.getPortraitUrl()));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
List<BaseUiConversation> srcList = new ArrayList<>(mAdapter.getSrcList());
|
||||
srcList.addAll(list);
|
||||
Log.i(TAG, "onSuccess: 增加用户数:" + list.size() + "||总用户数:" + srcList.size());
|
||||
for (BaseUiConversation conversation : srcList) {
|
||||
Log.i(TAG, "onSuccess: 用户id:" + conversation.mCore.getTargetId() + "||用户名:" + conversation.mCore.getConversationTitle() + "||用户头像:" + conversation.mCore.getPortraitUrl());
|
||||
}
|
||||
int position = 0;
|
||||
try {
|
||||
position = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
mAdapter.setDataCollection(srcList);
|
||||
mAdapter.onFinish();
|
||||
recyclerView.scrollToPosition(position);
|
||||
}
|
||||
onRefreshFinished();
|
||||
onLoadMoreFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
onLoadMoreFinished();
|
||||
onRefreshFinished();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
LiveNetManager.get(getContext())
|
||||
.getRelation("1", new HttpCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> data) {
|
||||
if (!data.isEmpty()) {
|
||||
getRongList(data);
|
||||
} else {
|
||||
onRefreshFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
onRefreshFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getRongList(List<String> uidList) {
|
||||
RongIMClient.getInstance().getConversationList(new RongIMClient.ResultCallback<List<Conversation>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Conversation> conversations) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
needLoadInfo = new ArrayList<>(uidList);
|
||||
Log.i(TAG, "融云列表:" + conversations.size());
|
||||
for (Conversation conversation : conversations) {
|
||||
Log.i(TAG, "融云匹配:" + conversation.getTargetId());
|
||||
if (uidList.contains(conversation.getTargetId())) {
|
||||
BaseUiConversation _conversation = new SingleConversation(getContext(), conversation);
|
||||
list.add(_conversation);
|
||||
needLoadInfo.remove(conversation.getTargetId());
|
||||
}
|
||||
}
|
||||
Log.i(TAG, "成功匹配数:" + list.size());
|
||||
refreshLayout.setEnableLoadMore(!needLoadInfo.isEmpty());
|
||||
int position = 0;
|
||||
try {
|
||||
position = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
mAdapter.clear();
|
||||
mAdapter.setDataCollection(list);
|
||||
recyclerView.scrollToPosition(position);
|
||||
if (!needLoadInfo.isEmpty()) {
|
||||
checkList();
|
||||
} else {
|
||||
onRefreshFinished();
|
||||
mAdapter.onFinish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
Log.i(TAG, "onError: 匹配失败:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.MessageChatUserBean;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnRecyclerListRefreshListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.MainConversationListAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imkit.utils.RouteUtils;
|
||||
import io.rong.imkit.widget.adapter.BaseAdapter;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.SearchConversationResult;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
public class MainMessageChatListUserFragment extends AbsMainMessageChatListFragment {
|
||||
private static final String TAG = "系统列表";
|
||||
|
||||
private List<String> needLoadInfo = new ArrayList<>();
|
||||
|
||||
|
||||
public MainMessageChatListUserFragment() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.rc_conversationlist_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
recyclerView = view.findViewById(R.id.rc_conversation_list);
|
||||
refreshLayout = view.findViewById(R.id.rc_refresh);
|
||||
refreshLayout.setNestedScrollingEnabled(false);
|
||||
refreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
refreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
mAdapter = new MainConversationListAdapter(view.getContext());
|
||||
mAdapter.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
mAdapter.setOnRefreshListener(new OnRecyclerListRefreshListener<List<BaseUiConversation>>() {
|
||||
@Override
|
||||
public void onFinish(List<BaseUiConversation> baseUiConversations) {
|
||||
loadLiveLookTime(baseUiConversations, new OnRecyclerListRefreshListener<Map<String, Integer>>() {
|
||||
@Override
|
||||
public void onFinish(Map<String, Integer> stringIntegerMap) {
|
||||
mAdapter.setTimerMap(stringIntegerMap);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
mAdapter.setItemClickListener(new BaseAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, ViewHolder holder, int position) {
|
||||
BaseUiConversation conversation = mAdapter.getSrcList().get(position);
|
||||
RouteUtils.routeToConversationActivity(view.getContext(), Conversation.ConversationType.PRIVATE, conversation.mCore.getTargetId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(View view, ViewHolder holder, int position) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
initRefresh();
|
||||
init();
|
||||
}
|
||||
|
||||
private void initRefresh() {
|
||||
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
checkList();
|
||||
}
|
||||
});
|
||||
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkList() {
|
||||
if (needLoadInfo.size() < 20) {
|
||||
getUserInfo(needLoadInfo);
|
||||
refreshLayout.setEnableLoadMore(false);
|
||||
} else {
|
||||
List<String> tmp = needLoadInfo.subList(0, 20);
|
||||
needLoadInfo.subList(0, 20).clear();
|
||||
getUserInfo(tmp);
|
||||
refreshLayout.setEnableLoadMore(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChatList() {
|
||||
if(mAdapter==null) return;
|
||||
mAdapter.setChat();
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(String search) {
|
||||
mAdapter.setSearch();
|
||||
getContactsList(search);
|
||||
}
|
||||
private void getContactsList(String search) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
List<String> uidList=new ArrayList<>();
|
||||
|
||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_contacts));
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
list.add(conversation);
|
||||
|
||||
List<BaseUiConversation> data = new ArrayList<>();
|
||||
System.err.println(" ----------------------->" + mAdapter.getData().size());
|
||||
for (BaseUiConversation cn : ((MainConversationListAdapter) mAdapter).getSrcList()) {
|
||||
System.err.println(" ----------------------->" + cn.mCore.getConversationTitle() + "|" + cn.mCore.getSenderUserName());
|
||||
if (StringUtil.isEmpty(cn.mCore.getConversationTitle())) continue;
|
||||
if(uidList.contains(cn.mCore.getTargetId())) continue;
|
||||
uidList.add(cn.mCore.getTargetId());
|
||||
if (cn.mCore.getConversationTitle().contains(search)) {
|
||||
conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_USER" + search);
|
||||
conversation.mCore.setConversationTitle(cn.mCore.getConversationTitle());
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
conversation.mCore.setPortraitUrl(cn.mCore.getPortraitUrl());
|
||||
conversation.mCore.setTargetId(cn.mCore.getTargetId());
|
||||
conversation.mCore.setSenderUserId(cn.mCore.getSenderUserId());
|
||||
data.add(conversation);
|
||||
}
|
||||
}
|
||||
if (data.size() == 1) {
|
||||
data.get(0).mCore.setMentionedCount(3);
|
||||
} else if (data.size() != 0) {
|
||||
data.get(0).mCore.setMentionedCount(1);
|
||||
data.get(data.size() - 1).mCore.setMentionedCount(2);
|
||||
} else {
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
list.addAll(data);
|
||||
getChatRecordList(list, search);
|
||||
}
|
||||
private void getChatRecordList(List<BaseUiConversation> list, String search) {
|
||||
Conversation.ConversationType[] conversationTypes = {Conversation.ConversationType.PRIVATE};
|
||||
String[] messageTypeObjectNames = {"RC:TxtMsg"};
|
||||
|
||||
RongIMClient.getInstance().searchConversations(search, conversationTypes, messageTypeObjectNames, new RongIMClient.ResultCallback<List<SearchConversationResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SearchConversationResult> searchConversationResults) {
|
||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_chat_records));
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
list.add(conversation);
|
||||
List<BaseUiConversation> data = new ArrayList<>();
|
||||
for (SearchConversationResult result : searchConversationResults) {
|
||||
BaseUiConversation cn = new SingleConversation(getContext(), result.getConversation());
|
||||
cn.mCore.setObjectName("SEARCH_CHAT" + search);
|
||||
data.add(cn);
|
||||
}
|
||||
if (data.size() == 1) {
|
||||
data.get(0).mCore.setMentionedCount(3);
|
||||
} else if (data.size() != 0) {
|
||||
data.get(0).mCore.setMentionedCount(1);
|
||||
data.get(data.size() - 1).mCore.setMentionedCount(2);
|
||||
} else {
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
list.addAll(data);
|
||||
mAdapter.setDataCollection(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
ToastUtil.show("搜索出错了:" + e.getMessage());
|
||||
mAdapter.setDataCollection(list);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateList() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void getUserInfo(List<String> uidList) {
|
||||
String uids = String.join(",", uidList);
|
||||
LiveNetManager.get(getContext())
|
||||
.getOtherList(uids, new HttpCallback<List<MessageChatUserBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MessageChatUserBean> data) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
for (MessageChatUserBean datum : data) {
|
||||
Conversation conversation = new Conversation();
|
||||
BaseUiConversation baseUiConversation = new SingleConversation(getContext(), conversation);
|
||||
baseUiConversation.mCore.setTargetId(datum.getId());
|
||||
baseUiConversation.mCore.setSenderUserId(IMLoginManager.get(getContext()).getUserInfo().getId() + "");
|
||||
baseUiConversation.mCore.setSentStatus(Message.SentStatus.CANCELED);
|
||||
baseUiConversation.mCore.setSentTime(-1);
|
||||
baseUiConversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
baseUiConversation.mCore.setPortraitUrl(datum.getAvatar());
|
||||
baseUiConversation.mCore.setConversationTitle(datum.getUserNiceName());
|
||||
list.add(baseUiConversation);
|
||||
UserInfo userInfo = new UserInfo(baseUiConversation.mCore.getTargetId(),
|
||||
baseUiConversation.mCore.getConversationTitle(),
|
||||
Uri.parse(baseUiConversation.mCore.getPortraitUrl()));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
|
||||
}
|
||||
if (!list.isEmpty()) {
|
||||
List<BaseUiConversation> srcList = new ArrayList<>(mAdapter.getSrcList());
|
||||
srcList.addAll(list);
|
||||
Log.i(TAG, "onSuccess: 增加用户数:" + list.size() + "||总用户数:" + srcList.size());
|
||||
int position = 0;
|
||||
try {
|
||||
position = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
mAdapter.setDataCollection(srcList);
|
||||
mAdapter.onFinish();
|
||||
recyclerView.scrollToPosition(position);
|
||||
}
|
||||
onRefreshFinished();
|
||||
onLoadMoreFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
LiveNetManager.get(getContext())
|
||||
.getRelation("2", new HttpCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> data) {
|
||||
if (!data.isEmpty()) {
|
||||
getRongList(data);
|
||||
} else {
|
||||
onRefreshFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
onRefreshFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getRongList(List<String> uidList) {
|
||||
RongIMClient.getInstance().getConversationList(new RongIMClient.ResultCallback<List<Conversation>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Conversation> conversations) {
|
||||
List<BaseUiConversation> list = new ArrayList<>();
|
||||
needLoadInfo = new ArrayList<>(uidList);
|
||||
Log.i(TAG, "融云列表:" + conversations.size());
|
||||
for (Conversation conversation : conversations) {
|
||||
Log.i(TAG, "融云匹配:" + conversation.getTargetId());
|
||||
if (uidList.contains(conversation.getTargetId())) {
|
||||
BaseUiConversation _conversation = new SingleConversation(getContext(), conversation);
|
||||
list.add(_conversation);
|
||||
needLoadInfo.remove(conversation.getTargetId());
|
||||
}
|
||||
}
|
||||
Log.i(TAG, "成功匹配数:" + list.size());
|
||||
refreshLayout.setEnableLoadMore(!needLoadInfo.isEmpty());
|
||||
int position = 0;
|
||||
try {
|
||||
position = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
mAdapter.clear();
|
||||
mAdapter.setDataCollection(list);
|
||||
recyclerView.scrollToPosition(position);
|
||||
if (!needLoadInfo.isEmpty()) {
|
||||
checkList();
|
||||
} else {
|
||||
onRefreshFinished();
|
||||
mAdapter.onFinish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
Log.i(TAG, "onError: 匹配失败:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,9 @@ import com.yunbao.main.utils.PDSightMessageItemProvider;
|
||||
import com.yunbao.main.views.MessageChatExtensionConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.RongIM;
|
||||
@@ -71,6 +73,7 @@ public class ConversationIMListManager {
|
||||
private String targetId;
|
||||
private String topContent;
|
||||
private Handler conversationIMListHandler = new Handler();
|
||||
private Map<String, SearchUserBean> userCache = new HashMap<>();
|
||||
|
||||
private ConversationIMListManager(Context context) {
|
||||
mContext = context;
|
||||
@@ -151,39 +154,37 @@ public class ConversationIMListManager {
|
||||
|
||||
}
|
||||
|
||||
public void clearUserCache() {
|
||||
userCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新用户信息(异步)
|
||||
*/
|
||||
public void addUserInfoProvider() {
|
||||
Log.i("刷新用户", "addUserInfoProvider: 准备刷新用户信息");
|
||||
RongUserInfoManager.getInstance().setUserInfoProvider(userId -> {
|
||||
Log.i("刷新用户", "1>" + userId);
|
||||
Log.i("刷新用户99", "1>" + userId);
|
||||
/*if (userCache.get(userId) != null) {
|
||||
return buildUser(userId, userCache.get(userId));
|
||||
}*/
|
||||
if (TextUtils.equals("__system__", userId)) {
|
||||
return null;
|
||||
}
|
||||
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0 && !TextUtils.equals("__system__", userId)) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||
Log.i("刷新用户2", "2>" + userBean.getId() + "|" + userId + "|" + userBean.getAvatar());
|
||||
String userNiceName = "";
|
||||
String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
|
||||
if (!TextUtils.isEmpty(remark)) {
|
||||
userNiceName = remark;
|
||||
} else {
|
||||
userNiceName = userBean.getUserNiceName();
|
||||
userCache.put(userId, userBean);
|
||||
UserInfo userInfo = buildUser(userId, userBean);
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
|
||||
if (userInfo != null && TextUtils.equals(userBean.getIs_admin(), "1")) {
|
||||
setConversationToTop(userInfo.getUserId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(userNiceName) && !TextUtils.isEmpty(userBean.getAvatar())) {
|
||||
UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
|
||||
//使用空白字段存储自己服务器用户的所有的信息
|
||||
userInfo.setExtra(GsonUtils.toJson(userBean));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
|
||||
if (TextUtils.equals(userBean.getIs_admin(), "1")) {
|
||||
setConversationToTop(userInfo.getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.i("刷新用户", "3>" + code + "|" + msg + "|" + info.length);
|
||||
Log.i("刷新用户", "3>" + code + "|" + msg + "|" + info.length + "|" + userId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -194,6 +195,27 @@ public class ConversationIMListManager {
|
||||
|
||||
}
|
||||
|
||||
private UserInfo buildUser(String userId, SearchUserBean userBean) {
|
||||
if (userBean == null) {
|
||||
return null;
|
||||
}
|
||||
Log.i("刷新用户2", "2>" + userBean.getId() + "|" + userId + "|" + userBean.getAvatar());
|
||||
String userNiceName = "";
|
||||
String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
|
||||
if (!TextUtils.isEmpty(remark)) {
|
||||
userNiceName = remark;
|
||||
} else {
|
||||
userNiceName = userBean.getUserNiceName();
|
||||
}
|
||||
if (!TextUtils.isEmpty(userNiceName) && !TextUtils.isEmpty(userBean.getAvatar())) {
|
||||
UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
|
||||
//使用空白字段存储自己服务器用户的所有的信息
|
||||
userInfo.setExtra(GsonUtils.toJson(userBean));
|
||||
return userInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String mUserId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider {
|
||||
String cn = WordUtil.getChineseString(def);
|
||||
String en = WordUtil.getEnglishString(def);
|
||||
String content = uiConversation.mConversationContent.toString();
|
||||
Log.i("列表----", "bindViewHolder: " + str + " | " + uiConversation.mConversationContent+" | "+WordUtil.isNewZh());
|
||||
Log.i("列表----", "bindViewHolder: " + str + " | " + uiConversation.mConversationContent + " | " + WordUtil.isNewZh());
|
||||
if (WordUtil.isNewZh()) {
|
||||
if (en.equals(content)) {
|
||||
uiConversation.mConversationContent = new SpannableString(WordUtil.getNewString(def));
|
||||
@@ -114,9 +114,13 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider {
|
||||
}
|
||||
|
||||
//设置时间
|
||||
String date = new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date(uiConversation.mCore.getSentTime()));
|
||||
date = DateFormatUtil.getDateTimeString(uiConversation.mCore.getSentTime(), true, holder.getContext());
|
||||
holder.setText(R.id.rc_conversation_date, date);
|
||||
if (uiConversation.mCore.getSentTime() > 0) {
|
||||
String date = new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date(uiConversation.mCore.getSentTime()));
|
||||
date = DateFormatUtil.getDateTimeString(uiConversation.mCore.getSentTime(), true, holder.getContext());
|
||||
holder.setText(R.id.rc_conversation_date, date);
|
||||
} else {
|
||||
holder.getView(R.id.rc_conversation_date).setVisibility(View.GONE);
|
||||
}
|
||||
holder.getView(R.id.rc_conversation_portrait).setOnClickListener(view -> {
|
||||
RouteUtil.forwardUserHome(targetId);
|
||||
});
|
||||
|
||||
@@ -320,9 +320,7 @@ public class MainMeViewHolder extends AbsMainViewHolder implements OnItemClickLi
|
||||
}
|
||||
String singnature = u.getSignature();
|
||||
if (TextUtils.equals(singnature, "這個人很懶,什麼也沒留下") || TextUtils.equals(singnature, "这家伙很懒,什么都没留下") || TextUtils.isEmpty(singnature)) {
|
||||
String ct = Locale.getDefault().getCountry();
|
||||
ct = TextUtils.equals("CN", ct) ? "HK" : ct;
|
||||
if (TextUtils.equals(ct, "CN")) {
|
||||
if (WordUtil.isNewZh()) {
|
||||
singnature = "這個人很懶,什麼也沒留下";
|
||||
} else {
|
||||
singnature = "The guy was lazy and didn't write anything.";
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
package com.yunbao.main.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.binioter.guideview.Guide;
|
||||
@@ -29,6 +35,11 @@ import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.dialog.DebugDialog;
|
||||
import com.yunbao.common.manager.base.ACache;
|
||||
import com.yunbao.common.utils.DateFormatUtil;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.bean.ImUserInfoModel;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
@@ -37,7 +48,6 @@ import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
@@ -46,6 +56,7 @@ import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.ViewPageIndicatorUtils;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.AbsMainViewHolder;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
@@ -57,15 +68,28 @@ import com.yunbao.main.R;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
import com.yunbao.main.adapter.SystemMessageAdapter;
|
||||
import com.yunbao.main.dialog.MsgMoreDialog;
|
||||
import com.yunbao.main.fragment.MainMessageChatFragment;
|
||||
import com.yunbao.main.fragment.AbsMainMessageChatListFragment;
|
||||
import com.yunbao.main.fragment.MainMessageChatListFragment;
|
||||
import com.yunbao.main.fragment.MainMessageChatListSystemFragment;
|
||||
import com.yunbao.main.fragment.MainMessageChatListUserFragment;
|
||||
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -74,8 +98,7 @@ import java.util.List;
|
||||
*/
|
||||
public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
|
||||
private MainMessageChatFragment conversationListFragment;
|
||||
private FrameLayout container;
|
||||
private static final String TAG = "消息中心";
|
||||
private SystemMessageAdapter messageAdapter;
|
||||
private TextView textNewsNotice, textNewsInteraction, textNewsOnline, textSystemMessages;
|
||||
private String type = null;
|
||||
@@ -90,6 +113,10 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
XPopup.Builder moreXPopup;
|
||||
private String homeZdyPop;
|
||||
|
||||
private ViewPager2 viewPager;
|
||||
private MagicIndicator mIndicator;
|
||||
private List<AbsMainMessageChatListFragment> fragmentList;
|
||||
|
||||
public MainMessageViewHolder setHomeZdyPop(String homeZdyPop) {
|
||||
this.homeZdyPop = homeZdyPop;
|
||||
if (TextUtils.equals(homeZdyPop, "1")) {
|
||||
@@ -121,7 +148,6 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
public void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
//菜单
|
||||
container = (FrameLayout) findViewById(R.id.container);
|
||||
textNewsNotice = (TextView) findViewById(R.id.text_news_notice);
|
||||
textNewsInteraction = (TextView) findViewById(R.id.text_news_interaction);
|
||||
textNewsOnline = (TextView) findViewById(R.id.text_news_online);
|
||||
@@ -132,6 +158,8 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
imgNewsInteraction = (ImageView) findViewById(R.id.img_news_interaction);
|
||||
imgSystemMessages = (ImageView) findViewById(R.id.img_system_messages);
|
||||
imgNewsOnline = (ImageView) findViewById(R.id.img_news_online);
|
||||
mIndicator = (MagicIndicator) findViewById(R.id.indicator);
|
||||
viewPager = findViewById(R.id.viewPager);
|
||||
contacts = findViewById(R.id.news_icon_contacts);
|
||||
more = findViewById(R.id.news_icon_more);
|
||||
search = findViewById(R.id.search);
|
||||
@@ -141,6 +169,12 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
// mContext.startActivity(new Intent(mContext, com.yunbao.main.activity.CompleteUserInfoActivity.class));
|
||||
// mContext.startActivity(new Intent(mContext, MessageHiConfigRecordActivity.class));
|
||||
});
|
||||
search.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
||||
return i == KeyEvent.KEYCODE_ENTER || i == KeyEvent.KEYCODE_NUMPAD_ENTER;
|
||||
}
|
||||
});
|
||||
search.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
@@ -153,11 +187,12 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (conversationListFragment == null) return;
|
||||
if (fragmentList.isEmpty()) return;
|
||||
if (fragmentList.get(viewPager.getCurrentItem()) == null) return;
|
||||
if (StringUtil.isEmpty(editable.toString())) {
|
||||
conversationListFragment.onChatList();
|
||||
fragmentList.get(viewPager.getCurrentItem()).onChatList();
|
||||
} else {
|
||||
conversationListFragment.search(editable.toString());
|
||||
fragmentList.get(viewPager.getCurrentItem()).search(editable.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -166,6 +201,91 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
more.setOnClickListener(view -> {
|
||||
moreXPopup.asCustom(new MsgMoreDialog(mContext)).show();
|
||||
});
|
||||
initFragment();
|
||||
initIndicator();
|
||||
}
|
||||
|
||||
private void initFragment() {
|
||||
fragmentList = new ArrayList<>();
|
||||
fragmentList.add(new MainMessageChatListFragment());
|
||||
fragmentList.add(new MainMessageChatListSystemFragment());
|
||||
fragmentList.add(new MainMessageChatListUserFragment());
|
||||
|
||||
ToastUtil.showDebug("列表数量x" + fragmentList.size());
|
||||
viewPager.setAdapter(new FragmentStateAdapter((FragmentActivity) AppManager.getInstance().getMainActivity()) {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
Log.i(TAG, "viewpage 列表 getItemCount: " + fragmentList.size());
|
||||
return fragmentList.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int i) {
|
||||
Log.i(TAG, "createFragment: 创建fragment :" + i + " | " + fragmentList.get(i));
|
||||
return fragmentList.get(i);
|
||||
}
|
||||
});
|
||||
viewPager.setCurrentItem(0);
|
||||
viewPager.setUserInputEnabled(false);
|
||||
ConversationIMListManager.get(mContext).addUserInfoProvider();
|
||||
}
|
||||
|
||||
private void initIndicator() {
|
||||
final String[] titles = new String[]{
|
||||
WordUtil.getNewString(R.string.message_chat_msg_all),
|
||||
WordUtil.getNewString(R.string.message_chat_msg_system),
|
||||
WordUtil.getNewString(R.string.message_chat_msg_user)
|
||||
};
|
||||
CommonNavigator commonNavigator = new CommonNavigator(AppManager.getInstance().getMainActivity());
|
||||
commonNavigator.setAdjustMode(true);
|
||||
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return titles.length;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int index) {
|
||||
SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
|
||||
simplePagerTitleView.setNormalColor(Color.parseColor("#777777"));
|
||||
simplePagerTitleView.setSelectedColor(Color.parseColor("#333333"));
|
||||
simplePagerTitleView.setText(titles[index]);
|
||||
simplePagerTitleView.setTextSize(18);
|
||||
simplePagerTitleView.getPaint().setFakeBoldText(true);
|
||||
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (viewPager != null) {
|
||||
viewPager.setCurrentItem(index);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
return simplePagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
|
||||
linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT);
|
||||
linePagerIndicator.setXOffset(DpUtil.dp2px(5));
|
||||
linePagerIndicator.setRoundRadius(DpUtil.dp2px(2));
|
||||
linePagerIndicator.setColors(Color.parseColor("#EB6FFF"), Color.parseColor("#FF83C6"));
|
||||
return linePagerIndicator;
|
||||
}
|
||||
});
|
||||
mIndicator.setNavigator(commonNavigator);
|
||||
ViewPageIndicatorUtils.bind(mIndicator, viewPager, new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
search.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,32 +347,11 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
*/
|
||||
private void initData() {
|
||||
IMLoginManager.get(mContext).checkInstructor();
|
||||
container.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
netHandler.post(imUserInfoRunnable);
|
||||
if (IMLoginManager.get(mContext).hintChat()&&false) {
|
||||
container.setVisibility(View.GONE);
|
||||
ltNodataMsg.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
container.setVisibility(View.VISIBLE);
|
||||
ltNodataMsg.setVisibility(View.GONE);
|
||||
//展示会话列表
|
||||
conversationListFragment = new MainMessageChatFragment();
|
||||
FragmentManager manager = ((FragmentActivity) mContext).getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
//conversationListFragment.setEmptyView(emptyView);
|
||||
conversationListFragment.setEmptyView(R.layout.view_layout_msg);
|
||||
//刷新列表内用户信息
|
||||
ConversationIMListManager.get(mContext).addUserInfoProvider();
|
||||
}
|
||||
//获取一下系统通知
|
||||
MessageIMManager.get(mContext).getSystemMessages();
|
||||
}
|
||||
});
|
||||
netHandler.post(imUserInfoRunnable);
|
||||
//刷新列表内用户信息
|
||||
Log.i(TAG, "initData: 初始化数据");
|
||||
//获取一下系统通知
|
||||
MessageIMManager.get(mContext).getSystemMessages();
|
||||
LiveNetManager.get(mContext)
|
||||
.getIsAnchor(new com.yunbao.common.http.base.HttpCallback<MessageChatIsAnchor>() {
|
||||
@Override
|
||||
@@ -262,7 +361,11 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
});
|
||||
if (data.getIsAnchor() == 1) {
|
||||
more.setVisibility(View.VISIBLE);
|
||||
viewPager.setUserInputEnabled(true);
|
||||
mIndicator.setVisibility(View.VISIBLE);
|
||||
}
|
||||
IMLoginManager.get(mContext)
|
||||
.setAnchorB(data.getIsAnchor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -143,7 +143,6 @@
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="94dp"
|
||||
@@ -289,26 +288,45 @@
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/line"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:background="#FFE9F6" />
|
||||
<!-- 此容器用于动态放置 fragment-->
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
|
||||
<net.lucode.hackware.magicindicator.MagicIndicator
|
||||
android:id="@+id/indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="37dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/line" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="50dp" />
|
||||
android:layout_marginBottom="50dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:overScrollMode="never"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/indicator" />
|
||||
<!-- 此容器用于动态放置 fragment-->
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/lt_nodata_msg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="center"
|
||||
android:visibility="visible">
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -6,26 +6,48 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/relativeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:paddingTop="24dp"
|
||||
android:layout_marginTop="30dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/textColor"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="123" />
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toStartOf="@+id/img_more"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_back"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="20dp"
|
||||
android:clipChildren="true"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxWidth="245dp"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/textColor"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="ID001,主播小丽,用户A先生,28岁,北京,软件工程师,2023-10-23" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_fold"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="40dp"
|
||||
android:onClick="backClick"
|
||||
android:scaleType="center"
|
||||
android:src="@mipmap/ic_fold" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_back"
|
||||
@@ -33,17 +55,10 @@
|
||||
android:layout_height="40dp"
|
||||
android:onClick="backClick"
|
||||
android:scaleType="center"
|
||||
android:src="@mipmap/ic_back" />
|
||||
android:src="@mipmap/ic_back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_fold"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginEnd="331dp"
|
||||
android:layout_toEndOf="@+id/titleView"
|
||||
android:onClick="backClick"
|
||||
android:scaleType="center"
|
||||
android:src="@mipmap/ic_fold" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_more"
|
||||
@@ -53,8 +68,11 @@
|
||||
android:padding="9dp"
|
||||
android:scaleType="center"
|
||||
android:src="@mipmap/btn_more_black"
|
||||
android:visibility="visible" />
|
||||
</RelativeLayout>
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/userCard"
|
||||
@@ -106,45 +124,56 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/rc_conversation_portrait" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="wrap_content"
|
||||
<com.yunbao.common.views.CustomLayout
|
||||
android:id="@+id/userNameLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="-24dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:text="TextView"
|
||||
android:textColor="#333333"
|
||||
android:textSize="16sp"
|
||||
android:gravity="center_vertical"
|
||||
app:layout_constraintEnd_toStartOf="@+id/constraintLayout6"
|
||||
app:layout_constraintStart_toStartOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/userName"
|
||||
app:layout_constraintStart_toEndOf="@+id/userName"
|
||||
app:layout_constraintTop_toTopOf="@+id/userName">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_status"
|
||||
<com.yunbao.common.views.AutoSplitTextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="在线"
|
||||
android:textColor="#AAAAAA"
|
||||
android:textSize="8sp" />
|
||||
android:maxWidth="228dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="#333333"
|
||||
android:textSize="15sp"
|
||||
tools:text="1234567890123456789012345" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/userStatusIcon"
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="5dp"
|
||||
android:layout_gravity="top"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:src="@mipmap/icon_green" />
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="在线"
|
||||
android:textColor="#AAAAAA"
|
||||
android:textSize="8sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/userStatusIcon"
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="5dp"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginStart="5dp"
|
||||
android:src="@mipmap/icon_green" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.yunbao.common.views.CustomLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/info"
|
||||
@@ -154,8 +183,8 @@
|
||||
android:text="@string/activity_msg_chat_top_tip1"
|
||||
android:textColor="#777777"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/userName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/userName" />
|
||||
app:layout_constraintStart_toStartOf="@+id/userNameLayout"
|
||||
app:layout_constraintTop_toBottomOf="@+id/userNameLayout" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@@ -170,15 +199,18 @@
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="4dp"
|
||||
app:srcCompat="@mipmap/bg_msg_chat_title_gift" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/user_auth_status"
|
||||
android:layout_width="84dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:scaleType="fitStart"
|
||||
app:srcCompat="@mipmap/ic_chat_auth"
|
||||
tools:layout_editor_absoluteX="124dp"
|
||||
tools:layout_editor_absoluteY="17dp" />
|
||||
tools:layout_editor_absoluteY="17dp"
|
||||
tools:layout_height="20dp"
|
||||
tools:layout_width="84dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -187,9 +219,9 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:maxLines="2"
|
||||
android:text="个性签名给性签名个性签名给性签名个性签名给性签名"
|
||||
android:textColor="#333333"
|
||||
android:maxLines="2"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/constraintLayout6"
|
||||
app:layout_constraintStart_toStartOf="@+id/info"
|
||||
|
||||
Reference in New Issue
Block a user