新增消息-通讯录界面

This commit is contained in:
z583819556 2024-03-07 16:01:12 +08:00
parent 2c554dadef
commit a22e600b52
16 changed files with 807 additions and 5 deletions

View File

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

View File

@ -0,0 +1,34 @@
package com.yunbao.common.utils;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
public class ListUtils {
public static <T extends Parcelable> List<T> cloneList(List<T> src) {
List<T> copiedList = new ArrayList<>();
for (T item : src) {
T copiedItem = deepCopyItem(item);
copiedList.add(copiedItem);
}
return copiedList;
}
private static <T extends Parcelable> T deepCopyItem(T item) {
Parcel parcel = Parcel.obtain();
item.writeToParcel(parcel, 0); // 将对象写入Parcel
parcel.setDataPosition(0); // 重置Parcel的位置到开头
Parcelable.Creator<T> creator= null;
try {
creator = (Parcelable.Creator<T>) item.getClass().getField("CREATOR").get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
T copiedItem = creator.createFromParcel(parcel); // 从Parcel中创建新的对象实例
parcel.recycle(); // 回收Parcel对象
return copiedItem;
}
}

View File

@ -50,6 +50,7 @@ public class RouteUtil {
public static final String PATH_BattlePassActivity="/main/BattlePassActivity";
public static final String PATH_SudGameActivity="/live/SudGameActivity";
public static final String PATH_COMMUNITY_Activity="/main/MainHomeCommunityActivity";
public static final String PATH_ADDRESSBOOK="/main/MsgAddressBookActivity";
public static void forwardCommunityActivity() {
@ -355,4 +356,8 @@ public class RouteUtil {
ARouter.getInstance().build(PATH_BattlePassActivity)
.navigation();
}
public static void forwardActivity(String path) {
ARouter.getInstance().build(path).navigation();
}
}

View File

@ -162,6 +162,8 @@
<activity android:name=".activity.MainHomeCommunityActivity"
android:screenOrientation="portrait" />
<activity android:name=".activity.MsgAddressBookActivity"
android:screenOrientation="portrait" />
</application>
</manifest>

View File

@ -0,0 +1,311 @@
package com.yunbao.main.activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.adapter.FragmentStateAdapter;
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.interfaces.OnGetItemListener;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ListUtils;
import com.yunbao.common.utils.RandomUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.main.R;
import com.yunbao.main.adapter.MainMsgAddressBookListAdapter;
import com.yunbao.main.fragment.MyAddressBookFragment;
import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.ViewPagerHelper;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
import java.util.ArrayList;
import java.util.List;
@Route(path = RouteUtil.PATH_ADDRESSBOOK)
public class MsgAddressBookActivity extends AbsActivity {
protected ViewPager2 mViewPager;
private MagicIndicator mIndicator;
private List<MyAddressBookFragment> fragmentList = new ArrayList<>();
List<UserBean> userLists = new ArrayList<>();
@Override
protected int getLayoutId() {
return R.layout.activity_msg_addressbook;
}
@Override
protected void main(Bundle savedInstanceState) {
super.main(savedInstanceState);
mIndicator = (MagicIndicator) findViewById(R.id.indicator);
mViewPager = (ViewPager2) findViewById(R.id.viewPager);
initViewPager();
initIndicator();
((EditText) findViewById(R.id.search)).addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
String key = editable.toString();
MyAddressBookFragment fragment = fragmentList.get(mViewPager.getCurrentItem());
if (StringUtil.isEmpty(key)) {
mIndicator.setVisibility(View.VISIBLE);
fragment.reload();
mViewPager.setUserInputEnabled(true);
} else {
mIndicator.setVisibility(View.GONE);
search(key);
}
}
});
}
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);
for (int i = 0; i < tmp.size(); i++) {
UserBean userBean = tmp.get(i);
if (i == 0) {
if (userBean.getUserNiceName().contains(key)) {
userBean.setMobile("SEARCH_USER" + key);
userBean.setPraise(1);
data.add(userBean);
}
} else if (i == tmp.size() - 1) {
if (userBean.getUserNiceName().contains(key)) {
userBean.setPraise(2);
userBean.setMobile("SEARCH_USER" + key);
data.add(userBean);
}
} else {
if (userBean.getUserNiceName().contains(key)) {
userBean.setMobile("SEARCH_USER" + key);
data.add(userBean);
}
}
}
if (data.size() == 1) {
data.get(0).setPraise(3);
}
return data;
}
private UserBean createTitleBean(String title) {
UserBean mutualTitle = new UserBean();
mutualTitle.setUserNiceName(title);
mutualTitle.setMobile("SEARCH_TITLE");
return mutualTitle;
}
private void initIndicator() {
final String[] titles = getTitles();
CommonNavigator commonNavigator = new CommonNavigator(mContext);
commonNavigator.setAdjustMode(true);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return titles.length;
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
simplePagerTitleView.setNormalColor(Color.parseColor("#777777"));
simplePagerTitleView.setSelectedColor(Color.parseColor("#333333"));
simplePagerTitleView.setText(titles[index]);
simplePagerTitleView.setTextSize(18);
simplePagerTitleView.getPaint().setFakeBoldText(true);
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mViewPager != null) {
mViewPager.setCurrentItem(index);
}
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT);
linePagerIndicator.setXOffset(DpUtil.dp2px(5));
linePagerIndicator.setRoundRadius(DpUtil.dp2px(2));
linePagerIndicator.setColors(Color.parseColor("#EB6FFF"));
return linePagerIndicator;
}
});
mIndicator.setNavigator(commonNavigator);
bind(mIndicator, mViewPager);
}
private void initViewPager() {
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_FOLLOW));
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_FAN));
userLists.addAll(createTempData(MyAddressBookFragment.TYPE_MUTUAL));
fragmentList = new ArrayList<>();
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_FOLLOW, new OnGetItemListener<List<UserBean>>() {
@Override
public List<UserBean> getItems() {
return getDate(MyAddressBookFragment.TYPE_FOLLOW);
}
}));
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_FAN, new OnGetItemListener<List<UserBean>>() {
@Override
public List<UserBean> getItems() {
return getDate(MyAddressBookFragment.TYPE_FAN);
}
}));
fragmentList.add(new MyAddressBookFragment(MyAddressBookFragment.TYPE_MUTUAL, new OnGetItemListener<List<UserBean>>() {
@Override
public List<UserBean> getItems() {
return getDate(MyAddressBookFragment.TYPE_MUTUAL);
}
}));
mViewPager.setAdapter(new FragmentStateAdapter(this) {
@Override
public int getItemCount() {
return fragmentList.size();
}
@NonNull
@Override
public Fragment createFragment(int i) {
return fragmentList.get(i);
}
});
}
public static void bind(final MagicIndicator magicIndicator, ViewPager2 viewPager) {
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
magicIndicator.onPageSelected(position);
}
@Override
public void onPageScrollStateChanged(int state) {
super.onPageScrollStateChanged(state);
magicIndicator.onPageScrollStateChanged(state);
}
});
}
private List<UserBean> createTempData(int type) {
List<UserBean> list = new ArrayList<>();
for (int i = 0; i < 3; i++) {
UserBean u = new UserBean();
u.setUserNiceName(RandomUtil.nextInt(100) + "title" + type);
u.setAvatar("https://downs.yaoulive.com/girltwo.png");
if (type == 0) {
u.setFollows(1);
} else if (type == 1) {
u.setFans(1);
} else {
u.setFans(1);
u.setFollows(1);
}
list.add(u);
}
if (list.size() == 1) {
list.get(0).setPraise(3);
} else if (list.size() != 0) {
list.get(0).setPraise(1);
list.get(list.size() - 1).setPraise(2);
}
return list;
}
private List<UserBean> getDate(int type) {
List<UserBean> list = new ArrayList<>();
for (UserBean bean : userLists) {
if (type == MyAddressBookFragment.TYPE_MUTUAL) {
if (bean.getFollows() == 1 && bean.getFans() == 1) {
list.add(bean);
}
} else if (type == MyAddressBookFragment.TYPE_FOLLOW) {
if (bean.getFollows() == 1 && bean.getFans() != 1) {
list.add(bean);
}
} else if (type == MyAddressBookFragment.TYPE_FAN) {
if (bean.getFollows() != 1 && bean.getFans() == 1) {
list.add(bean);
}
}
}
if (list.size() == 1) {
list.get(0).setPraise(3);
} else if (list.size() > 1) {
list.get(0).setPraise(1);
list.get(list.size() - 1).setPraise(2);
}
return list;
}
private String[] getTitles() {
return new String[]{
WordUtil.getNewString(R.string.activity_msg_addressbook_tab_follow),
WordUtil.getNewString(R.string.activity_msg_addressbook_tab_fan),
WordUtil.getNewString(R.string.activity_msg_addressbook_tab_mutual)
};
}
}

View File

@ -0,0 +1,177 @@
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;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.StringUtil;
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.widget.adapter.BaseAdapter;
import io.rong.imkit.widget.adapter.ViewHolder;
public class MainMsgAddressBookListAdapter extends BaseAdapter<UserBean> {
public static final int TYPE_SEARCH_TITLE = 500;
public static final int TYPE_SEARCH_USER = 510;
public static final int TYPE_SEARCH_CHAT = 520;
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ViewHolder holder = null;
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);
} else if (viewType == TYPE_SEARCH_USER) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_chat, parent, false);
holder = ViewHolder.createViewHolder(parent.getContext(), view);
} else if (viewType == TYPE_SEARCH_CHAT) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_chat, parent, false);
holder = ViewHolder.createViewHolder(parent.getContext(), view);
} else {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_chat, parent, false);
holder = ViewHolder.createViewHolder(parent.getContext(), view);
}
return holder;
}
@Override
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;
}
}
return type;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
if (getItemViewType(position) == TYPE_SEARCH_USER) {
bindUser(holder, position);
} else if (getItemViewType(position) == TYPE_SEARCH_CHAT) {
bindChat(holder, position);
} else if (getItemViewType(position) == TYPE_SEARCH_TITLE) {
bindTitle(holder, position);
} else {
bindList(holder, position);
}
}
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.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){
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){
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);
}
}
private void bindTitle(ViewHolder holder, int position) {
holder.setText(R.id.title, mDataList.get(position).getUserNiceName());
}
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", "");
title = title.replace(key, "<font color='#FF4874'>" + key + "</font>");
Spanned spanned = Html.fromHtml(title);
((TextView) holder.getView(R.id.rc_conversation_title)).setText(spanned);
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);
}
if (mDataList.get(position).getFans()==1 && mDataList.get(position).getFollows()==0) {
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){
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){
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);
}
}
private void bindChat(ViewHolder holder, int position) {
}
public void setDataCollection(List<UserBean> data) {
if (data == null) {
data = new ArrayList();
}
super.setDataCollection(data);
this.notifyDataSetChanged();
}
}

View File

@ -0,0 +1,116 @@
package com.yunbao.main.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.interfaces.OnGetItemListener;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.RandomUtil;
import com.yunbao.main.R;
import com.yunbao.main.adapter.MainMsgAddressBookListAdapter;
import java.util.ArrayList;
import java.util.List;
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
import io.rong.imkit.widget.refresh.api.RefreshLayout;
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
public class MyAddressBookFragment extends Fragment {
public static final int TYPE_FOLLOW = 0;
public static final int TYPE_FAN = 1;
public static final int TYPE_MUTUAL = 2;
protected SmartRefreshLayout mRefreshLayout;
protected RecyclerView mList;
private MainMsgAddressBookListAdapter mAdapter;
private int type;
List<UserBean> list;
private OnGetItemListener<List<UserBean>> listener;
public MyAddressBookFragment(int typeMutual,OnGetItemListener<List<UserBean>> listener) {
this.type=typeMutual;
this.listener=listener;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_msg_addressbook_list, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mAdapter = new MainMsgAddressBookListAdapter();
this.mList = (RecyclerView) view.findViewById(R.id.rc_conversation_list);
this.mRefreshLayout = (SmartRefreshLayout) view.findViewById(R.id.rc_refresh);
LinearLayoutManager layoutManager = new LinearLayoutManager(this.getActivity());
this.mList.setLayoutManager(layoutManager);
mList.setAdapter(mAdapter);
initRefreshView();
initData();
}
protected void initRefreshView() {
this.mRefreshLayout.setNestedScrollingEnabled(false);
this.mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
this.mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
this.mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
onConversationListRefresh(refreshLayout);
}
});
this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
onConversationListLoadMore();
}
});
}
private void onConversationListLoadMore() {
}
private void onConversationListRefresh(RefreshLayout refreshLayout) {
mAdapter.getData().clear();
initData();
}
private void initData() {
list = listener.getItems();
mAdapter.setDataCollection(list);
mRefreshLayout.finishLoadMore();
mRefreshLayout.finishRefresh(true);
}
public void reload() {
mAdapter.setDataCollection(list);
mRefreshLayout.setEnableRefresh(true);
mRefreshLayout.setEnableLoadMore(true);
}
public List<UserBean> getDate() {
return mAdapter.getData();
}
public void setSearchData(List<UserBean> list) {
mAdapter.setDataCollection(list);
mRefreshLayout.setEnableRefresh(false);
mRefreshLayout.setEnableLoadMore(false);
}
}

View File

@ -129,6 +129,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
search = findViewById(R.id.search);
contacts.setOnClickListener(view -> {
//通讯录
RouteUtil.forwardActivity(RouteUtil.PATH_ADDRESSBOOK);
});
search.addTextChangedListener(new TextWatcher() {
@Override
@ -138,11 +139,6 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
/* if(StringUtil.isEmpty(charSequence.toString())){
conversationListFragment.onChatList();
}else {
conversationListFragment.search(charSequence.toString());
}*/
}
@Override

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="68dp" android:height="37dp">
<shape android:shape="rectangle">
<gradient android:type="linear" android:useLevel="true" android:startColor="#ffff83c6" android:endColor="#ffeb6fff" android:angle="180" />
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="68dp" android:height="37dp">
<shape android:shape="rectangle">
<solid android:color="#ffdfdfdf" />
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="68dp" android:height="37dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ff777777" />
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="34dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/btn_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:onClick="backClick"
android:padding="2dp"
android:src="@mipmap/icon_sud_history_back" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="11dp"
android:text="@string/activity_msg_addressbook_layout_title"
android:textColor="#333333"
android:textSize="18sp"
android:textStyle="bold" />
</FrameLayout>
<EditText
android:id="@+id/search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="15dp"
android:layout_weight="0.7"
android:background="@drawable/bg_msg_list_search"
android:drawableStart="@mipmap/ic_home_game_search"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:hint="@string/activity_msg_addressbook_search_hint"
android:lines="1"
android:padding="10dp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top" />
<net.lucode.hackware.magicindicator.MagicIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/search" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/indicator" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.rong.imkit.widget.refresh.SmartRefreshLayout
android:id="@+id/rc_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rc_conversation_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
tools:listitem="@layout/rc_conversationlist_item" />
</io.rong.imkit.widget.refresh.SmartRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -102,6 +102,19 @@
app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl"
app:layout_constraintTop_toBottomOf="@+id/rc_conversation_title" />
<Button
android:id="@+id/btn"
android:layout_width="68dp"
android:layout_height="37dp"
android:layout_marginEnd="16dp"
tools:text="关注"
android:visibility="gone"
tools:visibility="visible"
android:background="@drawable/bg_msg_address_book_user_btn_mutual"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -29,4 +29,10 @@
<string name="activity_msg_list_include">包含:</string>
<string name="activity_msg_list_title_contacts">聯繫人</string>
<string name="activity_msg_list_title_chat_records">聊天記錄</string>
<string name="activity_msg_addressbook_layout_title">通讯录</string>
<string name="activity_msg_addressbook_search_hint">搜索昵稱</string>
<string name="activity_msg_addressbook_tab_follow">已關注</string>
<string name="activity_msg_addressbook_tab_fan">粉絲</string>
<string name="activity_msg_addressbook_tab_fan2">回關</string>
<string name="activity_msg_addressbook_tab_mutual">互相關注</string>
</resources>

View File

@ -29,4 +29,10 @@
<string name="activity_msg_list_include">Include:</string>
<string name="activity_msg_list_title_contacts">Contacts</string>
<string name="activity_msg_list_title_chat_records">Chat Records</string>
<string name="activity_msg_addressbook_layout_title">Address Book</string>
<string name="activity_msg_addressbook_search_hint">Search</string>
<string name="activity_msg_addressbook_tab_follow">Following</string>
<string name="activity_msg_addressbook_tab_fan">Fan</string>
<string name="activity_msg_addressbook_tab_fan2">Return</string>
<string name="activity_msg_addressbook_tab_mutual">Mutual</string>
</resources>