修复聊天页面卡顿问题
This commit is contained in:
@@ -13,6 +13,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnRecyclerListRefreshListener;
|
||||
@@ -145,12 +146,12 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
} else if (holder.getView(R.id.rc_conversation_date) != null) {
|
||||
holder.getView(R.id.rc_conversation_date).setVisibility(View.GONE);
|
||||
}
|
||||
if("0".equals(conversation.mCore.getDraft())){
|
||||
holder.setImageDrawable(R.id.rc_conversation_live_online_icon,mContext.getResources().getDrawable(R.mipmap.msg_online));
|
||||
holder.setText(R.id.rc_conversation_live_online,WordUtil.isNewZh()?"在線":"Online");
|
||||
}else{
|
||||
holder.setImageDrawable(R.id.rc_conversation_live_online_icon,mContext.getResources().getDrawable(R.mipmap.msg_off));
|
||||
holder.setText(R.id.rc_conversation_live_online,WordUtil.isNewZh()?"離線":"Offline");
|
||||
if ("0".equals(conversation.mCore.getDraft())) {
|
||||
holder.setImageDrawable(R.id.rc_conversation_live_online_icon, mContext.getResources().getDrawable(R.mipmap.msg_online));
|
||||
holder.setText(R.id.rc_conversation_live_online, WordUtil.isNewZh() ? "在線" : "Online");
|
||||
} else {
|
||||
holder.setImageDrawable(R.id.rc_conversation_live_online_icon, mContext.getResources().getDrawable(R.mipmap.msg_off));
|
||||
holder.setText(R.id.rc_conversation_live_online, WordUtil.isNewZh() ? "離線" : "Offline");
|
||||
}
|
||||
if (holder.getView(R.id.rc_conversation_live_status) == null || IMLoginManager.get(holder.getContext()).getAnchorB() != 1) {
|
||||
return;
|
||||
@@ -187,8 +188,11 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
private int listHashCode = 0;
|
||||
@Override
|
||||
public void setDataCollection(List<BaseUiConversation> data) {
|
||||
public synchronized void setDataCollection(List<BaseUiConversation> data) {
|
||||
if (data.hashCode() == listHashCode) return;
|
||||
listHashCode = data.hashCode();
|
||||
List<BaseUiConversation> tmp = new ArrayList<>();
|
||||
Log.i("聊天数据源", "setDataCollection: " + data.hashCode());
|
||||
List<String> urls = new ArrayList<>();
|
||||
@@ -219,8 +223,11 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
}
|
||||
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);
|
||||
if (!tmpUids.contains(item.mCore.getTargetId())) {
|
||||
BaseUiConversation cn = new SingleConversation(mContext, item.mCore);
|
||||
srcList.add(cn);
|
||||
tmpUids.add(item.mCore.getTargetId());
|
||||
}
|
||||
|
||||
if (item.mCore.getConversationType() == Conversation.ConversationType.PRIVATE) {
|
||||
if (item.mCore.getLatestMessage() instanceof MessageChatCardContent) {
|
||||
@@ -233,6 +240,8 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
super.setDataCollection(tmp);
|
||||
}
|
||||
|
||||
private List<String> tmpUids = new ArrayList<>();
|
||||
|
||||
public void clear() {
|
||||
mDataList.clear();
|
||||
if (srcList != null) {
|
||||
|
||||
@@ -143,7 +143,7 @@ public abstract class AbsMainMessageChatListFragment extends Fragment {
|
||||
isNet = true;
|
||||
for (BaseUiConversation conversation : srcList) {
|
||||
map.put(conversation.mCore.getTargetId(), conversation);
|
||||
if (conversation.mCore.getConversationType() == Conversation.ConversationType.PRIVATE) {
|
||||
if (conversation.mCore.getConversationType() == Conversation.ConversationType.PRIVATE&& !conversation.mCore.getTargetId().equals("__system__")) {
|
||||
uids.add(conversation.mCore.getTargetId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,6 +543,13 @@ public class LiveHttpUtil {
|
||||
HttpClient.getInstance().get("Live.getGiftListApp", LiveHttpConsts.GET_GIFT_LIST)
|
||||
.execute(callback);
|
||||
}
|
||||
/**
|
||||
* 获取礼物列表,同时会返回剩余的钱(新版) -用于获取联系方式时的礼物设置
|
||||
*/
|
||||
public static void getHotGiftList(HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Gift.getHotGiftList", LiveHttpConsts.GET_GIFT_LIST)
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取包裹列表
|
||||
|
||||
@@ -123,6 +123,7 @@ public class InstructorRemarkManager extends BaseCacheManager {
|
||||
@Override
|
||||
public void run() {
|
||||
IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo();
|
||||
if(userInfo==null)return;
|
||||
HttpClient.getInstance().get("User.getInstructorRemark", "getInstructorRemark")
|
||||
.params("uid", userInfo.getId(), true)
|
||||
.params("token", userInfo.getToken(), true)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunbao.common.manager.imrongcloud;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
public class PDRongUserInfoManager {
|
||||
public static void saveUserInfo(UserInfo userInfo) {
|
||||
RongUserInfoManager instance = RongUserInfoManager.getInstance();
|
||||
try {
|
||||
Method method = instance.getClass().getDeclaredMethod("saveUserInfoCache", userInfo.getClass());
|
||||
method.setAccessible(true);
|
||||
method.invoke(instance, userInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,14 +179,6 @@ public class AppManager {
|
||||
activityStack.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅在debug下运行的代码
|
||||
*/
|
||||
public static void runDebugCode(Runnable runnable) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
30
common/src/main/java/com/yunbao/common/utils/DebugUtils.java
Normal file
30
common/src/main/java/com/yunbao/common/utils/DebugUtils.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.yunbao.common.BuildConfig;
|
||||
|
||||
public class DebugUtils {
|
||||
/**
|
||||
* 打印堆栈信息
|
||||
*/
|
||||
public static void showStackTrace(){
|
||||
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (StackTraceElement element : stackTrace) {
|
||||
if(element!=null){
|
||||
sb.append(element).append("\n");
|
||||
}
|
||||
}
|
||||
Log.e("DebugUtils",sb.toString());
|
||||
}
|
||||
/**
|
||||
* 仅在debug下运行的代码
|
||||
*/
|
||||
public static void runDebugCode(Runnable runnable) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user