fix [关注状态有误]
This commit is contained in:
parent
33b1f6101f
commit
f391d1bee7
@ -1,8 +1,6 @@
|
||||
package com.yunbao.main.adapter;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -13,12 +11,10 @@ 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.RouteUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
@ -27,17 +23,18 @@ 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<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;
|
||||
private com.yunbao.common.interfaces.OnItemClickListener<MessageChatUserBean> onItemClickListener;
|
||||
|
||||
public void setOnItemClickListener(com.yunbao.common.interfaces.OnItemClickListener<MessageChatUserBean> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@ -74,7 +71,7 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<MessageChatUserBe
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
if(isEmpty()|| mDataList.isEmpty()){
|
||||
if (isEmpty() || mDataList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (getItemViewType(position) == TYPE_SEARCH_USER) {
|
||||
@ -105,22 +102,33 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<MessageChatUserBe
|
||||
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.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).getTypeInt() == MyAddressBookFragment.TYPE_MUTUAL) {
|
||||
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
||||
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).getTypeInt() == MyAddressBookFragment.TYPE_FOLLOW) {
|
||||
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
||||
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);
|
||||
}
|
||||
switch (mDataList.get(position).getAttention()) {
|
||||
case 1:
|
||||
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
||||
holder.setTextColor(R.id.btn, Color.parseColor("#FFFFFF"));
|
||||
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_fan);
|
||||
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan2));
|
||||
break;
|
||||
case 2:
|
||||
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_follow));
|
||||
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
||||
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_follow);
|
||||
break;
|
||||
case 3:
|
||||
holder.setText(R.id.btn, WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual));
|
||||
holder.getView(R.id.btn).setVisibility(View.VISIBLE);
|
||||
holder.setTextColor(R.id.btn, Color.parseColor("#333333"));
|
||||
holder.getView(R.id.btn).setBackgroundResource(R.drawable.bg_msg_address_book_user_btn_mutual);
|
||||
break;
|
||||
}
|
||||
holder.getView(R.id.rc_conversation_portrait).setOnClickListener(view -> {
|
||||
RouteUtil.forwardUserHome(mDataList.get(position).getId());
|
||||
});
|
||||
@ -129,7 +137,7 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<MessageChatUserBe
|
||||
public void onClick(View view) {
|
||||
MessageChatUserBean bean = (MessageChatUserBean) view.getTag();
|
||||
Button btn = (Button) view;
|
||||
follow(btn, bean);
|
||||
follow(btn, bean, position);
|
||||
|
||||
}
|
||||
});
|
||||
@ -184,7 +192,7 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<MessageChatUserBe
|
||||
public void onClick(View view) {
|
||||
MessageChatUserBean bean = (MessageChatUserBean) view.getTag();
|
||||
Button btn = (Button) view;
|
||||
follow(btn, bean);
|
||||
follow(btn, bean, position);
|
||||
|
||||
}
|
||||
});
|
||||
@ -194,18 +202,17 @@ public class MainMsgAddressBookListAdapter extends BaseAdapter<MessageChatUserBe
|
||||
|
||||
}
|
||||
|
||||
private void follow(Button btn, MessageChatUserBean bean) {
|
||||
private void follow(Button btn, MessageChatUserBean bean, int position) {
|
||||
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();
|
||||
/* bean.setAttention(Integer.parseInt(data.getIsattent()));
|
||||
mDataList.set(position, bean);
|
||||
notifyDataSetChanged();*/
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(bean, -2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user