update通讯录搜索

This commit is contained in:
z583819556 2024-03-09 13:37:59 +08:00
parent 5a866e5fc5
commit 0982b9554c
11 changed files with 487 additions and 130 deletions

View File

@ -0,0 +1,93 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.utils.StringUtil;
public class MessageChatUserBean extends UserBean{
private String type;
private int modelType;
@SerializedName("user_nicename")
protected String userNiceName;
@SerializedName("isAttention")
private int attention;//isAttention 1被关注 2已关注 3互相关注
public String getType() {
return type;
}
public void setType(int type){
this.type=type+"";
}
public int getTypeInt(){
if(StringUtil.isEmpty(type)){
return 0;
}
return Integer.parseInt(type);
}
@Override
public String getUserNiceName() {
return userNiceName;
}
public int getModelType() {
return modelType;
}
public void setModelType(int modelType) {
this.modelType = modelType;
}
@Override
public void setUserNiceName(String userNiceName) {
this.userNiceName = userNiceName;
}
public int getAttention() {
return attention;
}
public void setAttention(int attention) {
this.attention = attention;
}
@Override
public String toString() {
return "MessageChatUserBean{" +
"type='" + type + '\'' +
", modelType='" + modelType + '\'' +
", userNiceName='" + userNiceName + '\'' +
", id='" + id + '\'' +
", userNiceName='" + userNiceName + '\'' +
", avatar='" + avatar + '\'' +
", avatarThumb='" + avatarThumb + '\'' +
", sex=" + sex +
", signature='" + signature + '\'' +
", coin='" + coin + '\'' +
", gold='" + gold + '\'' +
", votes='" + votes + '\'' +
", consumption='" + consumption + '\'' +
", votestotal='" + votestotal + '\'' +
", province='" + province + '\'' +
", city='" + city + '\'' +
", location='" + location + '\'' +
", birthday='" + birthday + '\'' +
", level=" + level +
", levelAnchor=" + levelAnchor +
", lives=" + lives +
", follows=" + follows +
", fans=" + fans +
", vip=" + vip +
", liang=" + liang +
", car=" + car +
", medal_level=" + medal_level +
", medal_name='" + medal_name + '\'' +
", Dress=" + Dress +
", noble_id='" + noble_id + '\'' +
", yuanbao='" + yuanbao + '\'' +
", typeMic=" + typeMic +
'}';
}
}

View File

@ -76,6 +76,66 @@ public class UserBean implements Parcelable {
private boolean isRequest = false;
@Override
public String toString() {
return "UserBean{" +
"id='" + id + '\'' +
", userNiceName='" + userNiceName + '\'' +
", avatar='" + avatar + '\'' +
", avatarThumb='" + avatarThumb + '\'' +
", sex=" + sex +
", signature='" + signature + '\'' +
", coin='" + coin + '\'' +
", gold='" + gold + '\'' +
", votes='" + votes + '\'' +
", consumption='" + consumption + '\'' +
", votestotal='" + votestotal + '\'' +
", province='" + province + '\'' +
", city='" + city + '\'' +
", location='" + location + '\'' +
", birthday='" + birthday + '\'' +
", level=" + level +
", levelAnchor=" + levelAnchor +
", lives=" + lives +
", follows=" + follows +
", fans=" + fans +
", vip=" + vip +
", liang=" + liang +
", car=" + car +
", medal_level=" + medal_level +
", medal_name='" + medal_name + '\'' +
", Dress=" + Dress +
", noble_id='" + noble_id + '\'' +
", yuanbao='" + yuanbao + '\'' +
", noble_name='" + noble_name + '\'' +
", islive='" + islive + '\'' +
", medal_no_display_src='" + medal_no_display_src + '\'' +
", hot_num='" + hot_num + '\'' +
", goodnum='" + goodnum + '\'' +
", fans_pic='" + fans_pic + '\'' +
", gifticon='" + gifticon + '\'' +
", department_name='" + department_name + '\'' +
", token_rong='" + token_rong + '\'' +
", noble_end_time='" + noble_end_time + '\'' +
", slide='" + slide + '\'' +
", users_type='" + users_type + '\'' +
", is_bind='" + is_bind + '\'' +
", mobile='" + mobile + '\'' +
", front_task='" + front_task + '\'' +
", is_admin='" + is_admin + '\'' +
", praise=" + praise +
", isHide=" + isHide +
", randomPk=" + randomPk +
", mRankPkImgUrl='" + mRankPkImgUrl + '\'' +
", user_info_complete=" + user_info_complete +
", fansLevel=" + fansLevel +
", typeMic=" + typeMic +
", isMicList=" + isMicList +
", isRequest=" + isRequest +
", fansEnterRoomUrl='" + fansEnterRoomUrl + '\'' +
'}';
}
public boolean isRequest() {
return isRequest;
}

View File

@ -1,5 +1,5 @@
package com.yunbao.common.interfaces;
public interface OnGetItemListener<T> {
T getItems();
T getItems(int p);
}

View File

@ -16,8 +16,13 @@ import androidx.viewpager2.widget.ViewPager2;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.http.API;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.OnGetItemListener;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ListUtils;
import com.yunbao.common.utils.RandomUtil;
@ -46,7 +51,7 @@ public class MsgAddressBookActivity extends AbsActivity {
protected ViewPager2 mViewPager;
private MagicIndicator mIndicator;
private List<MyAddressBookFragment> fragmentList = new ArrayList<>();
List<UserBean> userLists = new ArrayList<>();
List<MessageChatUserBean> userLists = new ArrayList<>();
@Override
@ -89,46 +94,71 @@ public class MsgAddressBookActivity extends AbsActivity {
}
private void search(String key) {
List<UserBean> list = new ArrayList<>();
list.add(createTitleBean(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual)));
list.addAll(getSearchData(key, getDate(MyAddressBookFragment.TYPE_MUTUAL)));
list.add(createTitleBean(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan)));
list.addAll(getSearchData(key, getDate(MyAddressBookFragment.TYPE_FAN)));
list.add(createTitleBean(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_follow)));
list.addAll(getSearchData(key, getDate(MyAddressBookFragment.TYPE_FOLLOW)));
System.out.println("筛选 ");
System.out.println("筛选 ");
System.out.println("筛选--------------------------------------------");
for (UserBean datum : list) {
System.out.println("筛选 " + datum.getUserNiceName() + " ");
}
System.out.println("筛选--------------------------------------------");
fragmentList.get(mViewPager.getCurrentItem()).setSearchData(list);
mViewPager.setUserInputEnabled(false);
}
private List<UserBean> getSearchData(String key, List<UserBean> list) {
List<UserBean> data = new ArrayList<>();
List<UserBean> tmp = ListUtils.cloneList(list);
LiveNetManager.get(mContext)
.addressBookSearch(key, new HttpCallback<List<MessageChatUserBean>>() {
@Override
public void onSuccess(List<MessageChatUserBean> tmp) {
List<MessageChatUserBean> data = new ArrayList<>();
for (int i = 0; i < tmp.size(); i++) {
UserBean userBean = tmp.get(i);
MessageChatUserBean MessageChatUserBean = tmp.get(i);
MessageChatUserBean.setModelType(MainMsgAddressBookListAdapter.TYPE_SEARCH_USER);
if (MessageChatUserBean.getAttention() == 1) {
MessageChatUserBean.setType(MyAddressBookFragment.TYPE_FAN);
} else if (MessageChatUserBean.getAttention() == 2) {
MessageChatUserBean.setType(MyAddressBookFragment.TYPE_FOLLOW);
} else if (MessageChatUserBean.getAttention() == 3) {
MessageChatUserBean.setType(MyAddressBookFragment.TYPE_MUTUAL);
} else {
MessageChatUserBean.setType(-1);
}
if (i == 0) {
if (userBean.getUserNiceName().contains(key)) {
userBean.setMobile("SEARCH_USER" + key);
userBean.setPraise(1);
data.add(userBean);
MessageChatUserBean.setPraise(1);
data.add(MessageChatUserBean);
} else if (i == tmp.size() - 1) {
MessageChatUserBean.setPraise(2);
data.add(MessageChatUserBean);
} else {
data.add(MessageChatUserBean);
}
}
if (data.size() == 1) {
data.get(0).setPraise(3);
}
fragmentList.get(mViewPager.getCurrentItem()).setSearchData(data);
mViewPager.setUserInputEnabled(false);
}
@Override
public void onError(String error) {
}
});
}
private List<MessageChatUserBean> getSearchData(String key, List<MessageChatUserBean> list) {
List<MessageChatUserBean> data = new ArrayList<>();
List<MessageChatUserBean> tmp = ListUtils.cloneList(list);
for (int i = 0; i < tmp.size(); i++) {
MessageChatUserBean MessageChatUserBean = tmp.get(i);
if (i == 0) {
if (MessageChatUserBean.getUserNiceName().contains(key)) {
MessageChatUserBean.setMobile("SEARCH_USER" + key);
MessageChatUserBean.setPraise(1);
data.add(MessageChatUserBean);
}
} else if (i == tmp.size() - 1) {
if (userBean.getUserNiceName().contains(key)) {
userBean.setPraise(2);
userBean.setMobile("SEARCH_USER" + key);
data.add(userBean);
if (MessageChatUserBean.getUserNiceName().contains(key)) {
MessageChatUserBean.setPraise(2);
MessageChatUserBean.setMobile("SEARCH_USER" + key);
data.add(MessageChatUserBean);
}
} else {
if (userBean.getUserNiceName().contains(key)) {
userBean.setMobile("SEARCH_USER" + key);
data.add(userBean);
if (MessageChatUserBean.getUserNiceName().contains(key)) {
MessageChatUserBean.setMobile("SEARCH_USER" + key);
data.add(MessageChatUserBean);
}
}
}
@ -139,8 +169,8 @@ public class MsgAddressBookActivity extends AbsActivity {
return data;
}
private UserBean createTitleBean(String title) {
UserBean mutualTitle = new UserBean();
private MessageChatUserBean createTitleBean(String title) {
MessageChatUserBean mutualTitle = new MessageChatUserBean();
mutualTitle.setUserNiceName(title);
mutualTitle.setMobile("SEARCH_TITLE");
return mutualTitle;
@ -191,26 +221,69 @@ public class MsgAddressBookActivity extends AbsActivity {
}
private void initViewPager() {
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_FOLLOW));
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_FAN));
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_MUTUAL));
userLists = new ArrayList<>();
fragmentList = new ArrayList<>();
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_FOLLOW, new OnGetItemListener<List<UserBean>>() {
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_FOLLOW, new OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>>() {
@Override
public List<UserBean> getItems() {
return getDate(MyAddressBookFragment.TYPE_FOLLOW);
public void onItemClick(OnItemClickListener<List<MessageChatUserBean>> bean, int position) {
LiveNetManager.get(mContext)
.getPdluserFollow(position, new HttpCallback<List<MessageChatUserBean>>() {
@Override
public void onSuccess(List<MessageChatUserBean> data) {
for (MessageChatUserBean item : data) {
item.setType(MyAddressBookFragment.TYPE_FOLLOW);
}
bean.onItemClick(data, position);
userLists.addAll(data);
}
@Override
public void onError(String error) {
}
});
}
}));
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_FAN, new OnGetItemListener<List<UserBean>>() {
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_FAN, new OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>>() {
@Override
public List<UserBean> getItems() {
return getDate(MyAddressBookFragment.TYPE_FAN);
public void onItemClick(OnItemClickListener<List<MessageChatUserBean>> bean, int position) {
LiveNetManager.get(mContext)
.getPdluserFans(position, new HttpCallback<List<MessageChatUserBean>>() {
@Override
public void onSuccess(List<MessageChatUserBean> data) {
for (MessageChatUserBean item : data) {
item.setType(MyAddressBookFragment.TYPE_FAN);
}
bean.onItemClick(data, position);
userLists.addAll(data);
}
@Override
public void onError(String error) {
}
});
}
}));
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_MUTUAL, new OnGetItemListener<List<UserBean>>() {
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_MUTUAL, new OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>>() {
@Override
public List<UserBean> getItems() {
return getDate(MyAddressBookFragment.TYPE_MUTUAL);
public void onItemClick(OnItemClickListener<List<MessageChatUserBean>> bean, int position) {
LiveNetManager.get(mContext)
.getPdluserFriend(position, new HttpCallback<List<MessageChatUserBean>>() {
@Override
public void onSuccess(List<MessageChatUserBean> data) {
for (MessageChatUserBean item : data) {
item.setType(MyAddressBookFragment.TYPE_MUTUAL);
}
bean.onItemClick(data, position);
userLists.addAll(data);
}
@Override
public void onError(String error) {
}
});
}
}));
mViewPager.setAdapter(new FragmentStateAdapter(this) {
@ -250,10 +323,10 @@ public class MsgAddressBookActivity extends AbsActivity {
});
}
private List<UserBean> createTempData(int type) {
List<UserBean> list = new ArrayList<>();
private List<MessageChatUserBean> createTempData(int type) {
List<MessageChatUserBean> list = new ArrayList<>();
for (int i = 0; i < 3; i++) {
UserBean u = new UserBean();
MessageChatUserBean u = new MessageChatUserBean();
u.setUserNiceName(RandomUtil.nextInt(100) + "title" + type);
u.setAvatar("https://downs.yaoulive.com/girltwo.png");
if (type == 0) {
@ -275,9 +348,9 @@ public class MsgAddressBookActivity extends AbsActivity {
return list;
}
private List<UserBean> getDate(int type) {
List<UserBean> list = new ArrayList<>();
for (UserBean bean : userLists) {
private List<MessageChatUserBean> getDate(int type) {
List<MessageChatUserBean> list = new ArrayList<>();
for (MessageChatUserBean bean : userLists) {
if (type == MyAddressBookFragment.TYPE_MUTUAL) {
if (bean.getFollows() == 1 && bean.getFans() == 1) {
list.add(bean);

View File

@ -30,8 +30,11 @@ import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.activity.SelectImageActivity;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.NoviceInstructorModel;
import com.yunbao.common.event.PDChatInputModeEvent;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.OnSendMessageListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NoviceInstructorManager;
@ -169,6 +172,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
//绑定聊天用户id
inputPanel.setTargetId(targetId);
ToastUtil.show("id:"+targetId);
//获取用户信息
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
if (null != userInfo) {
@ -190,8 +194,9 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
Log.e("PDLiveConversation", userInfo.getExtra());
}
} else {
titleView.setText("系統消息");
inputPanel.setVisibility(View.GONE);
/* titleView.setText("系統消息");
inputPanel.setVisibility(View.GONE);*/
setUserCard();
}
getDraft();
@ -241,6 +246,20 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
}
private void setUserCard() {
LiveNetManager.get(mContext)
.getOtherInfo(targetId, new HttpCallback<MessageChatUserBean>() {
@Override
public void onSuccess(MessageChatUserBean data) {
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onClick(View v) {

View File

@ -1,5 +1,6 @@
package com.yunbao.main.adapter;
import android.content.Context;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
@ -12,23 +13,37 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.ListUtils;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.main.R;
import java.util.ArrayList;
import java.util.List;
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;
public class MainConversationListAdapter extends ConversationListAdapter {
public static final int TYPE_SEARCH_TITLE = 500;
public static final int TYPE_SEARCH_USER = 510;
public static final int TYPE_SEARCH_CHAT = 520;
private List<BaseUiConversation> srcList;
private Context mContext;
public MainConversationListAdapter(Context mContext) {
this.mContext = mContext;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ViewHolder holder = null;
mContext=parent.getContext();
if (viewType == TYPE_SEARCH_TITLE) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_title, parent, false);
holder = ViewHolder.createViewHolder(parent.getContext(), view);
@ -73,6 +88,26 @@ public class MainConversationListAdapter extends ConversationListAdapter {
}
}
@Override
public void setDataCollection(List<BaseUiConversation> data) {
super.setDataCollection(data);
if(srcList==null){
srcList=new ArrayList<>();
}
srcList.clear();
for (BaseUiConversation item : data) {
BaseUiConversation cn=new SingleConversation(mContext,item.mCore);
srcList.add(cn);
}
}
public List<BaseUiConversation> getSrcList() {
if(srcList==null){
srcList=new ArrayList<>();
}
return srcList;
}
private void bindTitle(ViewHolder holder, int position) {
holder.setText(R.id.title, mDataList.get(position).mCore.getObjectName().replace("SEARCH_TITLE", ""));
}
@ -98,6 +133,9 @@ 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());
});
}
private void bindChat(ViewHolder holder, int position) {
@ -122,5 +160,8 @@ 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());
});
}
}

View File

@ -6,25 +6,34 @@ import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
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.fragment.MyAddressBookFragment;
import java.util.ArrayList;
import java.util.List;
import io.rong.imkit.conversationlist.ConversationListAdapter;
import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imkit.utils.RouteUtils;
import io.rong.imkit.widget.adapter.BaseAdapter;
import io.rong.imkit.widget.adapter.ViewHolder;
import io.rong.imlib.model.Conversation;
public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
public class MainMsgAddressBookListAdapter extends BaseAdapter<MessageChatUserBean> {
public static final int TYPE_SEARCH_TITLE = 500;
public static final int TYPE_SEARCH_USER = 510;
public static final int TYPE_SEARCH_CHAT = 520;
@ -53,14 +62,7 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
public int getItemViewType(int position) {
int type = super.getItemViewType(position);
if (mDataList.size() > position) {
String objectName = mDataList.get(position).getMobile();
if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_USER")) {
type = TYPE_SEARCH_USER;
} else if (!StringUtil.isEmpty(objectName) && objectName.equals("SEARCH_CHAT")) {
type = TYPE_SEARCH_CHAT;
} else if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_TITLE")) {
type = TYPE_SEARCH_TITLE;
}
type = mDataList.get(position).getModelType();
}
return type;
}
@ -76,45 +78,50 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
} else {
bindList(holder, position);
}
holder.getConvertView().setTag(mDataList.get(position));
holder.getConvertView().setOnClickListener(view -> {
MessageChatUserBean userBean= (MessageChatUserBean) view.getTag();
RouteUtils.routeToConversationActivity(view.getContext(),
Conversation.ConversationType.PRIVATE,
userBean.getId());
});
}
private void bindList(ViewHolder holder, int position) {
ImgLoader.display(holder.getContext(), mDataList.get(position).getAvatar(), holder.getView(R.id.rc_conversation_portrait));
String title = mDataList.get(position).getUserNiceName();
((TextView) holder.getView(R.id.rc_conversation_title)).setText(title);
int type = mDataList.get(position).getPraise();
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
holder.getView(R.id.itemDecorationBottom).setVisibility(View.GONE);
/* if (type == 1) {
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_top);
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
} else if (type == 2) {
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_bottom);
} else if (type == 3) {
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item);
} else {
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
}*/
holder.itemView.setBackground(null);
//holder.setText(R.id.rc_conversation_content,mDataList.get(position).getSignature());
if (mDataList.get(position).getFans()==1 && mDataList.get(position).getFollows()==0) {
holder.setText(R.id.rc_conversation_content, mDataList.get(position).getSignature());
holder.getView(R.id.btn).setTag(mDataList.get(position));
if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_FAN) {
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
holder.getView(R.id.btn).setEnabled(true);
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan2));
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_fan);
}else if(mDataList.get(position).getFans()==1 && mDataList.get(position).getFollows()==1){
} else if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_MUTUAL) {
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
holder.getView(R.id.btn).setEnabled(true);
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual));
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_mutual);
}else if(mDataList.get(position).getFollows()==1){
} else if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_FOLLOW) {
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
holder.getView(R.id.btn).setEnabled(false);
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_follow));
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_follow);
}else{
holder.getView(R.id.btn).setVisibility(View.GONE);
}
holder.getView(R.id.btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MessageChatUserBean bean = (MessageChatUserBean) view.getTag();
Button btn = (Button) view;
follow(btn, bean);
}
});
}
private void bindTitle(ViewHolder holder, int position) {
@ -124,13 +131,14 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
private void bindUser(ViewHolder holder, int position) {
ImgLoader.display(holder.getContext(), mDataList.get(position).getAvatar(), holder.getView(R.id.rc_conversation_portrait));
String title = mDataList.get(position).getUserNiceName();
String key = mDataList.get(position).getMobile().replace("SEARCH_USER", "");
/* String key = mDataList.get(position).getMobile().replace("SEARCH_USER", "");
title = title.replace(key, "<font color='#FF4874'>" + key + "</font>");
Spanned spanned = Html.fromHtml(title);
((TextView) holder.getView(R.id.rc_conversation_title)).setText(spanned);
Spanned spanned = Html.fromHtml(title);*/
((TextView) holder.getView(R.id.rc_conversation_title)).setText(title);
int type = mDataList.get(position).getPraise();
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
holder.getView(R.id.itemDecorationBottom).setVisibility(View.GONE);
holder.setText(R.id.rc_conversation_content, mDataList.get(position).getSignature());
if (type == 1) {
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_top);
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
@ -142,31 +150,61 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
}
if (mDataList.get(position).getFans()==1 && mDataList.get(position).getFollows()==0) {
holder.getView(R.id.btn).setTag(mDataList.get(position));
if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_FAN) {
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
holder.getView(R.id.btn).setEnabled(true);
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan2));
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_fan);
}else if(mDataList.get(position).getFans()==1 && mDataList.get(position).getFollows()==1){
} else if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_MUTUAL) {
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
holder.getView(R.id.btn).setEnabled(true);
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual));
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_mutual);
}else if(mDataList.get(position).getFollows()==1){
} else if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_FOLLOW) {
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
holder.getView(R.id.btn).setEnabled(false);
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_follow));
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_follow);
}else{
holder.getView(R.id.btn).setVisibility(View.GONE);
}
holder.getView(R.id.btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MessageChatUserBean bean = (MessageChatUserBean) view.getTag();
Button btn = (Button) view;
follow(btn, bean);
}
});
}
private void bindChat(ViewHolder holder, int position) {
}
public void setDataCollection(List<UserBean> data) {
private void follow(Button btn, MessageChatUserBean bean) {
LiveNetManager.get(btn.getContext())
.setAttents(bean.getId(), new HttpCallback<SetAttentsModel>() {
@Override
public void onSuccess(SetAttentsModel data) {
bean.setType(MyAddressBookFragment.TYPE_MUTUAL);
btn.setEnabled(true);
btn.setTextColor(Color.parseColor("#333333"));
btn.setText(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual));
btn.setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_mutual);
btn.setTag(bean);
notifyDataSetChanged();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
public void setDataCollection(List<MessageChatUserBean> data) {
if (data == null) {
data = new ArrayList();
}

View File

@ -238,6 +238,7 @@ public class MainHomeCommunityFragment extends BaseFragment {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWebView.loadUrl(url);
Log.i(TAG, url);
findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View File

@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.main.R;
@ -23,6 +24,9 @@ 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.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.RongCoreClient;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.SearchConversationResult;
@ -40,25 +44,35 @@ public class MainMessageChatFragment extends ConversationListFragment {
public void search(String search) {
mAdapter.getData().clear();
getContactsList(search);
}
private void getContactsList(String search) {
List<BaseUiConversation> list = new ArrayList<>();
List<BaseUiConversation> data = 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);
for (int i = 0; i < 3; i++) {
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 (cn.mCore.getConversationTitle().contains(search)) {
conversation = new SingleConversation(getContext(), new Conversation());
conversation.mCore.setObjectName("SEARCH_USER" + search);
conversation.mCore.setConversationTitle(search + "|" + i);
conversation.mCore.setConversationTitle(cn.mCore.getConversationTitle());
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
conversation.mCore.setPortraitUrl("https://downs.yaoulive.com/girltwo.png");
conversation.mCore.setPortraitUrl(cn.mCore.getPortraitUrl());
conversation.mCore.setTargetId(cn.mCore.getTargetId());
conversation.mCore.setSenderUserId(cn.mCore.getSenderUserId());
data.add(conversation);
}
}
mAdapter.getData().clear();
if (data.size() == 1) {
data.get(0).mCore.setMentionedCount(3);
} else if (data.size() != 0) {
@ -119,7 +133,7 @@ public class MainMessageChatFragment extends ConversationListFragment {
@Override
protected ConversationListAdapter onResolveAdapter() {
this.mAdapter = new MainConversationListAdapter();
this.mAdapter = new MainConversationListAdapter(getContext());
return this.mAdapter;
}
}

View File

@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.interfaces.OnGetItemListener;
import com.yunbao.common.interfaces.OnItemClickListener;
@ -37,11 +38,11 @@ public class MyAddressBookFragment extends Fragment {
protected RecyclerView mList;
private MainMsgAddressBookListAdapter mAdapter;
private int type;
List<UserBean> list;
private OnGetItemListener<List<UserBean>> listener;
List<MessageChatUserBean> list;
private OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>> listener;
int p = 1;
public MyAddressBookFragment(int typeMutual,OnGetItemListener<List<UserBean>> listener) {
public MyAddressBookFragment(int typeMutual, OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>> listener) {
this.type = typeMutual;
this.listener = listener;
}
@ -82,6 +83,19 @@ public class MyAddressBookFragment extends Fragment {
}
private void onConversationListLoadMore() {
listener.onItemClick(new OnItemClickListener<List<MessageChatUserBean>>() {
@Override
public void onItemClick(List<MessageChatUserBean> bean, int position) {
if(bean.isEmpty()){
mRefreshLayout.finishLoadMoreWithNoMoreData();
return;
}
list.addAll(bean);
mAdapter.setDataCollection(list);
mRefreshLayout.finishLoadMore();
p = position + 1;
}
}, p);
}
private void onConversationListRefresh(RefreshLayout refreshLayout) {
@ -90,11 +104,16 @@ public class MyAddressBookFragment extends Fragment {
}
private void initData() {
list = listener.getItems();
p = 1;
listener.onItemClick(new OnItemClickListener<List<MessageChatUserBean>>() {
@Override
public void onItemClick(List<MessageChatUserBean> bean, int position) {
list = bean;
mAdapter.setDataCollection(list);
mRefreshLayout.finishLoadMore();
mRefreshLayout.finishRefresh(true);
mRefreshLayout.finishRefresh();
p = position + 1;
}
}, p);
}
@ -104,11 +123,11 @@ public class MyAddressBookFragment extends Fragment {
mRefreshLayout.setEnableLoadMore(true);
}
public List<UserBean> getDate() {
public List<MessageChatUserBean> getDate() {
return mAdapter.getData();
}
public void setSearchData(List<UserBean> list) {
public void setSearchData(List<MessageChatUserBean> list) {
mAdapter.setDataCollection(list);
mRefreshLayout.setEnableRefresh(false);
mRefreshLayout.setEnableLoadMore(false);

View File

@ -93,11 +93,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="60dp"
android:text="你好,朋友!"
android:textColor="#777777"
android:textSize="11sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl"
app:layout_constraintTop_toBottomOf="@+id/rc_conversation_title" />