update通讯录搜索
This commit is contained in:
parent
5a866e5fc5
commit
0982b9554c
@ -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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -76,6 +76,66 @@ public class UserBean implements Parcelable {
|
|||||||
|
|
||||||
private boolean isRequest = false;
|
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() {
|
public boolean isRequest() {
|
||||||
return isRequest;
|
return isRequest;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package com.yunbao.common.interfaces;
|
package com.yunbao.common.interfaces;
|
||||||
|
|
||||||
public interface OnGetItemListener<T> {
|
public interface OnGetItemListener<T> {
|
||||||
T getItems();
|
T getItems(int p);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,13 @@ import androidx.viewpager2.widget.ViewPager2;
|
|||||||
|
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
import com.yunbao.common.activity.AbsActivity;
|
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.OnGetItemListener;
|
||||||
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
import com.yunbao.common.utils.ListUtils;
|
import com.yunbao.common.utils.ListUtils;
|
||||||
import com.yunbao.common.utils.RandomUtil;
|
import com.yunbao.common.utils.RandomUtil;
|
||||||
@ -46,7 +51,7 @@ public class MsgAddressBookActivity extends AbsActivity {
|
|||||||
protected ViewPager2 mViewPager;
|
protected ViewPager2 mViewPager;
|
||||||
private MagicIndicator mIndicator;
|
private MagicIndicator mIndicator;
|
||||||
private List<MyAddressBookFragment> fragmentList = new ArrayList<>();
|
private List<MyAddressBookFragment> fragmentList = new ArrayList<>();
|
||||||
List<UserBean> userLists = new ArrayList<>();
|
List<MessageChatUserBean> userLists = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,46 +94,71 @@ public class MsgAddressBookActivity extends AbsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void search(String key) {
|
private void search(String key) {
|
||||||
List<UserBean> list = new ArrayList<>();
|
|
||||||
list.add(createTitleBean(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual)));
|
LiveNetManager.get(mContext)
|
||||||
list.addAll(getSearchData(key, getDate(MyAddressBookFragment.TYPE_MUTUAL)));
|
.addressBookSearch(key, new HttpCallback<List<MessageChatUserBean>>() {
|
||||||
list.add(createTitleBean(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan)));
|
@Override
|
||||||
list.addAll(getSearchData(key, getDate(MyAddressBookFragment.TYPE_FAN)));
|
public void onSuccess(List<MessageChatUserBean> tmp) {
|
||||||
list.add(createTitleBean(WordUtil.getNewString(R.string.activity_msg_addressbook_tab_follow)));
|
List<MessageChatUserBean> data = new ArrayList<>();
|
||||||
list.addAll(getSearchData(key, getDate(MyAddressBookFragment.TYPE_FOLLOW)));
|
for (int i = 0; i < tmp.size(); i++) {
|
||||||
System.out.println("筛选 ");
|
MessageChatUserBean MessageChatUserBean = tmp.get(i);
|
||||||
System.out.println("筛选 ");
|
MessageChatUserBean.setModelType(MainMsgAddressBookListAdapter.TYPE_SEARCH_USER);
|
||||||
System.out.println("筛选--------------------------------------------");
|
if (MessageChatUserBean.getAttention() == 1) {
|
||||||
for (UserBean datum : list) {
|
MessageChatUserBean.setType(MyAddressBookFragment.TYPE_FAN);
|
||||||
System.out.println("筛选 " + datum.getUserNiceName() + " ");
|
} else if (MessageChatUserBean.getAttention() == 2) {
|
||||||
}
|
MessageChatUserBean.setType(MyAddressBookFragment.TYPE_FOLLOW);
|
||||||
System.out.println("筛选--------------------------------------------");
|
} else if (MessageChatUserBean.getAttention() == 3) {
|
||||||
fragmentList.get(mViewPager.getCurrentItem()).setSearchData(list);
|
MessageChatUserBean.setType(MyAddressBookFragment.TYPE_MUTUAL);
|
||||||
mViewPager.setUserInputEnabled(false);
|
} else {
|
||||||
|
MessageChatUserBean.setType(-1);
|
||||||
|
}
|
||||||
|
if (i == 0) {
|
||||||
|
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<UserBean> getSearchData(String key, List<UserBean> list) {
|
private List<MessageChatUserBean> getSearchData(String key, List<MessageChatUserBean> list) {
|
||||||
List<UserBean> data = new ArrayList<>();
|
List<MessageChatUserBean> data = new ArrayList<>();
|
||||||
List<UserBean> tmp = ListUtils.cloneList(list);
|
List<MessageChatUserBean> tmp = ListUtils.cloneList(list);
|
||||||
for (int i = 0; i < tmp.size(); i++) {
|
for (int i = 0; i < tmp.size(); i++) {
|
||||||
UserBean userBean = tmp.get(i);
|
MessageChatUserBean MessageChatUserBean = tmp.get(i);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (userBean.getUserNiceName().contains(key)) {
|
if (MessageChatUserBean.getUserNiceName().contains(key)) {
|
||||||
userBean.setMobile("SEARCH_USER" + key);
|
MessageChatUserBean.setMobile("SEARCH_USER" + key);
|
||||||
userBean.setPraise(1);
|
MessageChatUserBean.setPraise(1);
|
||||||
data.add(userBean);
|
data.add(MessageChatUserBean);
|
||||||
}
|
}
|
||||||
} else if (i == tmp.size() - 1) {
|
} else if (i == tmp.size() - 1) {
|
||||||
if (userBean.getUserNiceName().contains(key)) {
|
if (MessageChatUserBean.getUserNiceName().contains(key)) {
|
||||||
userBean.setPraise(2);
|
MessageChatUserBean.setPraise(2);
|
||||||
userBean.setMobile("SEARCH_USER" + key);
|
MessageChatUserBean.setMobile("SEARCH_USER" + key);
|
||||||
data.add(userBean);
|
data.add(MessageChatUserBean);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (userBean.getUserNiceName().contains(key)) {
|
if (MessageChatUserBean.getUserNiceName().contains(key)) {
|
||||||
userBean.setMobile("SEARCH_USER" + key);
|
MessageChatUserBean.setMobile("SEARCH_USER" + key);
|
||||||
data.add(userBean);
|
data.add(MessageChatUserBean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,8 +169,8 @@ public class MsgAddressBookActivity extends AbsActivity {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserBean createTitleBean(String title) {
|
private MessageChatUserBean createTitleBean(String title) {
|
||||||
UserBean mutualTitle = new UserBean();
|
MessageChatUserBean mutualTitle = new MessageChatUserBean();
|
||||||
mutualTitle.setUserNiceName(title);
|
mutualTitle.setUserNiceName(title);
|
||||||
mutualTitle.setMobile("SEARCH_TITLE");
|
mutualTitle.setMobile("SEARCH_TITLE");
|
||||||
return mutualTitle;
|
return mutualTitle;
|
||||||
@ -191,26 +221,69 @@ public class MsgAddressBookActivity extends AbsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initViewPager() {
|
private void initViewPager() {
|
||||||
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_FOLLOW));
|
userLists = new ArrayList<>();
|
||||||
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_FAN));
|
|
||||||
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_MUTUAL));
|
|
||||||
fragmentList = 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
|
@Override
|
||||||
public List<UserBean> getItems() {
|
public void onItemClick(OnItemClickListener<List<MessageChatUserBean>> bean, int position) {
|
||||||
return getDate(MyAddressBookFragment.TYPE_FOLLOW);
|
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
|
@Override
|
||||||
public List<UserBean> getItems() {
|
public void onItemClick(OnItemClickListener<List<MessageChatUserBean>> bean, int position) {
|
||||||
return getDate(MyAddressBookFragment.TYPE_FAN);
|
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
|
@Override
|
||||||
public List<UserBean> getItems() {
|
public void onItemClick(OnItemClickListener<List<MessageChatUserBean>> bean, int position) {
|
||||||
return getDate(MyAddressBookFragment.TYPE_MUTUAL);
|
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) {
|
mViewPager.setAdapter(new FragmentStateAdapter(this) {
|
||||||
@ -250,10 +323,10 @@ public class MsgAddressBookActivity extends AbsActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserBean> createTempData(int type) {
|
private List<MessageChatUserBean> createTempData(int type) {
|
||||||
List<UserBean> list = new ArrayList<>();
|
List<MessageChatUserBean> list = new ArrayList<>();
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
UserBean u = new UserBean();
|
MessageChatUserBean u = new MessageChatUserBean();
|
||||||
u.setUserNiceName(RandomUtil.nextInt(100) + "title" + type);
|
u.setUserNiceName(RandomUtil.nextInt(100) + "title" + type);
|
||||||
u.setAvatar("https://downs.yaoulive.com/girltwo.png");
|
u.setAvatar("https://downs.yaoulive.com/girltwo.png");
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
@ -275,9 +348,9 @@ public class MsgAddressBookActivity extends AbsActivity {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserBean> getDate(int type) {
|
private List<MessageChatUserBean> getDate(int type) {
|
||||||
List<UserBean> list = new ArrayList<>();
|
List<MessageChatUserBean> list = new ArrayList<>();
|
||||||
for (UserBean bean : userLists) {
|
for (MessageChatUserBean bean : userLists) {
|
||||||
if (type == MyAddressBookFragment.TYPE_MUTUAL) {
|
if (type == MyAddressBookFragment.TYPE_MUTUAL) {
|
||||||
if (bean.getFollows() == 1 && bean.getFans() == 1) {
|
if (bean.getFollows() == 1 && bean.getFans() == 1) {
|
||||||
list.add(bean);
|
list.add(bean);
|
||||||
|
@ -30,8 +30,11 @@ import com.yunbao.common.activity.AbsActivity;
|
|||||||
import com.yunbao.common.activity.SelectImageActivity;
|
import com.yunbao.common.activity.SelectImageActivity;
|
||||||
import com.yunbao.common.bean.IMLoginModel;
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
import com.yunbao.common.bean.ImageEntity;
|
import com.yunbao.common.bean.ImageEntity;
|
||||||
|
import com.yunbao.common.bean.MessageChatUserBean;
|
||||||
import com.yunbao.common.bean.NoviceInstructorModel;
|
import com.yunbao.common.bean.NoviceInstructorModel;
|
||||||
import com.yunbao.common.event.PDChatInputModeEvent;
|
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.interfaces.OnSendMessageListener;
|
||||||
import com.yunbao.common.manager.IMLoginManager;
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||||
@ -169,6 +172,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
|
|
||||||
//绑定聊天用户id
|
//绑定聊天用户id
|
||||||
inputPanel.setTargetId(targetId);
|
inputPanel.setTargetId(targetId);
|
||||||
|
ToastUtil.show("id:"+targetId);
|
||||||
//获取用户信息
|
//获取用户信息
|
||||||
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
|
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
|
||||||
if (null != userInfo) {
|
if (null != userInfo) {
|
||||||
@ -190,8 +194,9 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
Log.e("PDLiveConversation", userInfo.getExtra());
|
Log.e("PDLiveConversation", userInfo.getExtra());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
titleView.setText("系統消息");
|
/* titleView.setText("系統消息");
|
||||||
inputPanel.setVisibility(View.GONE);
|
inputPanel.setVisibility(View.GONE);*/
|
||||||
|
setUserCard();
|
||||||
}
|
}
|
||||||
getDraft();
|
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
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yunbao.main.adapter;
|
package com.yunbao.main.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -12,23 +13,37 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.utils.ListUtils;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import io.rong.imkit.conversationlist.ConversationListAdapter;
|
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.adapter.ViewHolder;
|
||||||
|
|
||||||
public class MainConversationListAdapter extends ConversationListAdapter {
|
public class MainConversationListAdapter extends ConversationListAdapter {
|
||||||
public static final int TYPE_SEARCH_TITLE = 500;
|
public static final int TYPE_SEARCH_TITLE = 500;
|
||||||
public static final int TYPE_SEARCH_USER = 510;
|
public static final int TYPE_SEARCH_USER = 510;
|
||||||
public static final int TYPE_SEARCH_CHAT = 520;
|
public static final int TYPE_SEARCH_CHAT = 520;
|
||||||
|
private List<BaseUiConversation> srcList;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public MainConversationListAdapter(Context mContext) {
|
||||||
|
this.mContext = mContext;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
ViewHolder holder = null;
|
ViewHolder holder = null;
|
||||||
|
mContext=parent.getContext();
|
||||||
if (viewType == TYPE_SEARCH_TITLE) {
|
if (viewType == TYPE_SEARCH_TITLE) {
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_title, parent, false);
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_title, parent, false);
|
||||||
holder = ViewHolder.createViewHolder(parent.getContext(), view);
|
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) {
|
private void bindTitle(ViewHolder holder, int position) {
|
||||||
holder.setText(R.id.title, mDataList.get(position).mCore.getObjectName().replace("SEARCH_TITLE", ""));
|
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.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
||||||
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
|
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) {
|
private void bindChat(ViewHolder holder, int position) {
|
||||||
@ -106,7 +144,7 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
|||||||
String title = mDataList.get(position).mConversationContent.toString();
|
String title = mDataList.get(position).mConversationContent.toString();
|
||||||
String key = mDataList.get(position).mCore.getObjectName().replace("SEARCH_CHAT", "");
|
String key = mDataList.get(position).mCore.getObjectName().replace("SEARCH_CHAT", "");
|
||||||
title = title.replace(key, "<font color='#FF4874'>" + key + "</font>");
|
title = title.replace(key, "<font color='#FF4874'>" + key + "</font>");
|
||||||
Spanned spanned = Html.fromHtml(WordUtil.getNewString(R.string.activity_msg_list_include) +title);
|
Spanned spanned = Html.fromHtml(WordUtil.getNewString(R.string.activity_msg_list_include) + title);
|
||||||
((TextView) holder.getView(R.id.rc_conversation_content)).setText(spanned);
|
((TextView) holder.getView(R.id.rc_conversation_content)).setText(spanned);
|
||||||
int type = mDataList.get(position).mCore.getMentionedCount();
|
int type = mDataList.get(position).mCore.getMentionedCount();
|
||||||
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
|
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
|
||||||
@ -122,5 +160,8 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
|||||||
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
||||||
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
|
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());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,25 +6,34 @@ import android.text.Spanned;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
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.bean.UserBean;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
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.StringUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
|
import com.yunbao.main.fragment.MyAddressBookFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.rong.imkit.conversationlist.ConversationListAdapter;
|
import io.rong.imkit.conversationlist.ConversationListAdapter;
|
||||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
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.BaseAdapter;
|
||||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
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_TITLE = 500;
|
||||||
public static final int TYPE_SEARCH_USER = 510;
|
public static final int TYPE_SEARCH_USER = 510;
|
||||||
public static final int TYPE_SEARCH_CHAT = 520;
|
public static final int TYPE_SEARCH_CHAT = 520;
|
||||||
@ -53,14 +62,7 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
int type = super.getItemViewType(position);
|
int type = super.getItemViewType(position);
|
||||||
if (mDataList.size() > position) {
|
if (mDataList.size() > position) {
|
||||||
String objectName = mDataList.get(position).getMobile();
|
type = mDataList.get(position).getModelType();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@ -76,45 +78,50 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
|
|||||||
} else {
|
} else {
|
||||||
bindList(holder, position);
|
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){
|
|
||||||
|
private void bindList(ViewHolder holder, int position) {
|
||||||
ImgLoader.display(holder.getContext(), mDataList.get(position).getAvatar(), holder.getView(R.id.rc_conversation_portrait));
|
ImgLoader.display(holder.getContext(), mDataList.get(position).getAvatar(), holder.getView(R.id.rc_conversation_portrait));
|
||||||
String title = mDataList.get(position).getUserNiceName();
|
String title = mDataList.get(position).getUserNiceName();
|
||||||
((TextView) holder.getView(R.id.rc_conversation_title)).setText(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.itemDecorationTop).setVisibility(View.GONE);
|
||||||
holder.getView(R.id.itemDecorationBottom).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.itemView.setBackground(null);
|
||||||
//holder.setText(R.id.rc_conversation_content,mDataList.get(position).getSignature());
|
holder.setText(R.id.rc_conversation_content, mDataList.get(position).getSignature());
|
||||||
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).setVisibility(View.VISIBLE);
|
||||||
holder.getView(R.id.btn).setEnabled(true);
|
|
||||||
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
|
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
|
||||||
holder.setText(R.id.btn,WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan2));
|
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);
|
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).setVisibility(View.VISIBLE);
|
||||||
holder.getView(R.id.btn).setEnabled(true);
|
|
||||||
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
|
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
|
||||||
holder.setText(R.id.btn,WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual));
|
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);
|
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).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.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);
|
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) {
|
private void bindTitle(ViewHolder holder, int position) {
|
||||||
@ -124,13 +131,14 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
|
|||||||
private void bindUser(ViewHolder holder, int position) {
|
private void bindUser(ViewHolder holder, int position) {
|
||||||
ImgLoader.display(holder.getContext(), mDataList.get(position).getAvatar(), holder.getView(R.id.rc_conversation_portrait));
|
ImgLoader.display(holder.getContext(), mDataList.get(position).getAvatar(), holder.getView(R.id.rc_conversation_portrait));
|
||||||
String title = mDataList.get(position).getUserNiceName();
|
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>");
|
title = title.replace(key, "<font color='#FF4874'>" + key + "</font>");
|
||||||
Spanned spanned = Html.fromHtml(title);
|
Spanned spanned = Html.fromHtml(title);*/
|
||||||
((TextView) holder.getView(R.id.rc_conversation_title)).setText(spanned);
|
((TextView) holder.getView(R.id.rc_conversation_title)).setText(title);
|
||||||
int type = mDataList.get(position).getPraise();
|
int type = mDataList.get(position).getPraise();
|
||||||
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
|
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
|
||||||
holder.getView(R.id.itemDecorationBottom).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) {
|
if (type == 1) {
|
||||||
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_top);
|
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_top);
|
||||||
holder.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
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.getView(R.id.itemDecorationBottom).setVisibility(View.VISIBLE);
|
||||||
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
|
holder.itemView.setBackgroundResource(R.drawable.bg_msg_list_item_centre);
|
||||||
}
|
}
|
||||||
|
holder.getView(R.id.btn).setTag(mDataList.get(position));
|
||||||
if (mDataList.get(position).getFans()==1 && mDataList.get(position).getFollows()==0) {
|
if (mDataList.get(position).getTypeInt() == MyAddressBookFragment.TYPE_FAN) {
|
||||||
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
||||||
holder.getView(R.id.btn).setEnabled(true);
|
|
||||||
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
|
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
|
||||||
holder.setText(R.id.btn,WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan2));
|
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);
|
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).setVisibility(View.VISIBLE);
|
||||||
holder.getView(R.id.btn).setEnabled(true);
|
|
||||||
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
|
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
|
||||||
holder.setText(R.id.btn,WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual));
|
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);
|
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).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.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);
|
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) {
|
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) {
|
if (data == null) {
|
||||||
data = new ArrayList();
|
data = new ArrayList();
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,7 @@ public class MainHomeCommunityFragment extends BaseFragment {
|
|||||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||||
}
|
}
|
||||||
mWebView.loadUrl(url);
|
mWebView.loadUrl(url);
|
||||||
|
Log.i(TAG, url);
|
||||||
findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.yunbao.common.custom.ItemDecoration;
|
import com.yunbao.common.custom.ItemDecoration;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.main.R;
|
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.ConversationListFragment;
|
||||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
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.RongIMClient;
|
||||||
import io.rong.imlib.model.Conversation;
|
import io.rong.imlib.model.Conversation;
|
||||||
import io.rong.imlib.model.SearchConversationResult;
|
import io.rong.imlib.model.SearchConversationResult;
|
||||||
@ -40,25 +44,35 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
|||||||
|
|
||||||
|
|
||||||
public void search(String search) {
|
public void search(String search) {
|
||||||
mAdapter.getData().clear();
|
|
||||||
getContactsList(search);
|
getContactsList(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getContactsList(String search) {
|
private void getContactsList(String search) {
|
||||||
List<BaseUiConversation> list = new ArrayList<>();
|
List<BaseUiConversation> list = new ArrayList<>();
|
||||||
List<BaseUiConversation> data = new ArrayList<>();
|
|
||||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_contacts));
|
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_contacts));
|
||||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||||
list.add(conversation);
|
list.add(conversation);
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
conversation = new SingleConversation(getContext(), new Conversation());
|
List<BaseUiConversation> data = new ArrayList<>();
|
||||||
conversation.mCore.setObjectName("SEARCH_USER" + search);
|
System.err.println(" ----------------------->" + mAdapter.getData().size());
|
||||||
conversation.mCore.setConversationTitle(search + "|" + i);
|
for (BaseUiConversation cn : ((MainConversationListAdapter) mAdapter).getSrcList()) {
|
||||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
System.err.println(" ----------------------->" + cn.mCore.getConversationTitle() + "|" + cn.mCore.getSenderUserName());
|
||||||
conversation.mCore.setPortraitUrl("https://downs.yaoulive.com/girltwo.png");
|
if(StringUtil.isEmpty(cn.mCore.getConversationTitle()))continue;
|
||||||
data.add(conversation);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
mAdapter.getData().clear();
|
||||||
if (data.size() == 1) {
|
if (data.size() == 1) {
|
||||||
data.get(0).mCore.setMentionedCount(3);
|
data.get(0).mCore.setMentionedCount(3);
|
||||||
} else if (data.size() != 0) {
|
} else if (data.size() != 0) {
|
||||||
@ -85,7 +99,7 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
|||||||
List<BaseUiConversation> data = new ArrayList<>();
|
List<BaseUiConversation> data = new ArrayList<>();
|
||||||
for (SearchConversationResult result : searchConversationResults) {
|
for (SearchConversationResult result : searchConversationResults) {
|
||||||
BaseUiConversation cn = new SingleConversation(getContext(), result.getConversation());
|
BaseUiConversation cn = new SingleConversation(getContext(), result.getConversation());
|
||||||
cn.mCore.setObjectName("SEARCH_CHAT"+search);
|
cn.mCore.setObjectName("SEARCH_CHAT" + search);
|
||||||
data.add(cn);
|
data.add(cn);
|
||||||
}
|
}
|
||||||
if (data.size() == 1) {
|
if (data.size() == 1) {
|
||||||
@ -103,7 +117,7 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(RongIMClient.ErrorCode e) {
|
public void onError(RongIMClient.ErrorCode e) {
|
||||||
ToastUtil.show("搜索出错了:"+e.getMessage());
|
ToastUtil.show("搜索出错了:" + e.getMessage());
|
||||||
mAdapter.setDataCollection(list);
|
mAdapter.setDataCollection(list);
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
@ -119,7 +133,7 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ConversationListAdapter onResolveAdapter() {
|
protected ConversationListAdapter onResolveAdapter() {
|
||||||
this.mAdapter = new MainConversationListAdapter();
|
this.mAdapter = new MainConversationListAdapter(getContext());
|
||||||
return this.mAdapter;
|
return this.mAdapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.MessageChatUserBean;
|
||||||
import com.yunbao.common.bean.UserBean;
|
import com.yunbao.common.bean.UserBean;
|
||||||
import com.yunbao.common.interfaces.OnGetItemListener;
|
import com.yunbao.common.interfaces.OnGetItemListener;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
@ -37,13 +38,13 @@ public class MyAddressBookFragment extends Fragment {
|
|||||||
protected RecyclerView mList;
|
protected RecyclerView mList;
|
||||||
private MainMsgAddressBookListAdapter mAdapter;
|
private MainMsgAddressBookListAdapter mAdapter;
|
||||||
private int type;
|
private int type;
|
||||||
List<UserBean> list;
|
List<MessageChatUserBean> list;
|
||||||
private OnGetItemListener<List<UserBean>> listener;
|
private OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>> listener;
|
||||||
|
int p = 1;
|
||||||
|
|
||||||
|
public MyAddressBookFragment(int typeMutual, OnItemClickListener<OnItemClickListener<List<MessageChatUserBean>>> listener) {
|
||||||
public MyAddressBookFragment(int typeMutual,OnGetItemListener<List<UserBean>> listener) {
|
this.type = typeMutual;
|
||||||
this.type=typeMutual;
|
this.listener = listener;
|
||||||
this.listener=listener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -82,6 +83,19 @@ public class MyAddressBookFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onConversationListLoadMore() {
|
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) {
|
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||||
@ -90,11 +104,16 @@ public class MyAddressBookFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
list = listener.getItems();
|
p = 1;
|
||||||
|
listener.onItemClick(new OnItemClickListener<List<MessageChatUserBean>>() {
|
||||||
mAdapter.setDataCollection(list);
|
@Override
|
||||||
mRefreshLayout.finishLoadMore();
|
public void onItemClick(List<MessageChatUserBean> bean, int position) {
|
||||||
mRefreshLayout.finishRefresh(true);
|
list = bean;
|
||||||
|
mAdapter.setDataCollection(list);
|
||||||
|
mRefreshLayout.finishRefresh();
|
||||||
|
p = position + 1;
|
||||||
|
}
|
||||||
|
}, p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,11 +123,11 @@ public class MyAddressBookFragment extends Fragment {
|
|||||||
mRefreshLayout.setEnableLoadMore(true);
|
mRefreshLayout.setEnableLoadMore(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserBean> getDate() {
|
public List<MessageChatUserBean> getDate() {
|
||||||
return mAdapter.getData();
|
return mAdapter.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchData(List<UserBean> list) {
|
public void setSearchData(List<MessageChatUserBean> list) {
|
||||||
mAdapter.setDataCollection(list);
|
mAdapter.setDataCollection(list);
|
||||||
mRefreshLayout.setEnableRefresh(false);
|
mRefreshLayout.setEnableRefresh(false);
|
||||||
mRefreshLayout.setEnableLoadMore(false);
|
mRefreshLayout.setEnableLoadMore(false);
|
||||||
|
@ -93,11 +93,10 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginEnd="60dp"
|
|
||||||
android:text="你好,朋友!"
|
android:text="你好,朋友!"
|
||||||
android:textColor="#777777"
|
android:textColor="#777777"
|
||||||
android:textSize="11sp"
|
android:textSize="11sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toStartOf="@+id/btn"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl"
|
app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/rc_conversation_title" />
|
app:layout_constraintTop_toBottomOf="@+id/rc_conversation_title" />
|
||||||
|
Loading…
Reference in New Issue
Block a user