diff --git a/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java index c746da32d..91f9417cf 100644 --- a/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java @@ -39,6 +39,7 @@ import io.rong.imkit.widget.adapter.ViewHolder; import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Message; +import io.rong.message.SightMessage; import io.rong.message.TextMessage; public class MainConversationListAdapter extends ConversationListAdapter { @@ -55,6 +56,11 @@ public class MainConversationListAdapter extends ConversationListAdapter { this.mContext = mContext; } + public void setSrcList(List srcList) { + this.srcList = srcList; + notifyDataSetChanged(); + } + public void setOnRefreshListener(OnRecyclerListRefreshListener> onRefreshListener) { this.onRefreshListener = onRefreshListener; } @@ -134,6 +140,13 @@ public class MainConversationListAdapter extends ConversationListAdapter { } else if (holder.getView(R.id.rc_conversation_date) != null) { holder.getView(R.id.rc_conversation_date).setVisibility(View.GONE); } + if("0".equals(conversation.mCore.getDraft())){ + holder.setImageDrawable(R.id.rc_conversation_live_online_icon,mContext.getResources().getDrawable(R.mipmap.msg_online)); + holder.setText(R.id.rc_conversation_live_online,WordUtil.isNewZh()?"在線":"Online"); + }else{ + holder.setImageDrawable(R.id.rc_conversation_live_online_icon,mContext.getResources().getDrawable(R.mipmap.msg_off)); + holder.setText(R.id.rc_conversation_live_online,WordUtil.isNewZh()?"離線":"Offline"); + } if (holder.getView(R.id.rc_conversation_live_status) == null || IMLoginManager.get(holder.getContext()).getAnchorB() != 1) { return; } @@ -322,7 +335,12 @@ public class MainConversationListAdapter extends ConversationListAdapter { BaseUiConversation conversation = mDataList.get(id); conversation.mCore.setSentTime(bean.getSentTime()); conversation.mCore.setUnreadMessageCount(integer); - conversation.mConversationContent = new SpannableString(((TextMessage) bean.getContent()).getContent()); + if(bean.getContent() instanceof SightMessage){ + conversation.mConversationContent = new SpannableString(WordUtil.isNewZh()?"[小視頻]":"[Video]"); + }else{ + conversation.mConversationContent = new SpannableString(((TextMessage) bean.getContent()).getContent()); + } + mDataList.set(id, conversation); notifyItemChanged(id); } diff --git a/common/src/main/java/com/yunbao/common/adapter/MsgRecommendAdapter.java b/common/src/main/java/com/yunbao/common/adapter/MsgRecommendAdapter.java new file mode 100644 index 000000000..a216f47e1 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/MsgRecommendAdapter.java @@ -0,0 +1,101 @@ +package com.yunbao.common.adapter; + +import static com.yunbao.common.utils.StringUtil.isEmpty; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.MessageChatUserBean; +import com.yunbao.common.bean.MsgRecommendBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ClipPathCircleImage; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by cxf on 2019/4/22. + */ + +public class MsgRecommendAdapter extends RecyclerView.Adapter { + + private Context mContext; + private List mList; + private LayoutInflater mInflater; + + public MsgRecommendAdapter.onItemSayHi onItemSayHi; + + public void setOnItemSayHi(onItemSayHi onItemSayHi) { + this.onItemSayHi = onItemSayHi; + } + + public MsgRecommendAdapter(Context context, List list) { + mContext = context; + mInflater = LayoutInflater.from(context); + mList = list; + } + + public void setDataCollection(List data) { + if (data == null) { + data = new ArrayList(); + } + this.mList = data; + this.notifyDataSetChanged(); + } + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(R.layout.msg_main_recommend_item, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh holder, @SuppressLint("RecyclerView") int position) { + if (isEmpty() || mList.isEmpty()) { + return; + } + ImgLoader.display(holder.itemView.getContext(), mList.get(position).getAvatar(), holder.mAvatar); + holder.rc_conversation_title.setText(mList.get(position).getUser_nicename()); + holder.sayHi.setText(mList.get(position).isSayHi()? (WordUtil.isNewZh()?"已打招呼":"Said Hallo"):(WordUtil.isNewZh()?"打招呼":"Greet")); + holder.sayHi.setBackground(mList.get(position).isSayHi()? mContext.getDrawable(R.drawable.bg_msg_recommended):mContext.getDrawable(R.drawable.bg_msg_recommend)); + holder.sayHi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(onItemSayHi!=null){ + onItemSayHi.onSayHi(mList.get(position),position); + } + } + }); + } + + @Override + public int getItemCount() { + return mList.size(); + } + + class Vh extends RecyclerView.ViewHolder { + private ClipPathCircleImage mAvatar; + private TextView rc_conversation_title; + private TextView sayHi; + + public Vh(@NonNull View itemView) { + super(itemView); + mAvatar = itemView.findViewById(R.id.avatar); + rc_conversation_title = itemView.findViewById(R.id.rc_conversation_title); + sayHi = itemView.findViewById(R.id.sayHi); + } + } + + public interface onItemSayHi{ + void onSayHi(MsgRecommendBean model,int position); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java b/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java index e27e9b7da..12dde677b 100644 --- a/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java +++ b/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java @@ -54,6 +54,16 @@ public class HomeUserInfoBean extends BaseModel { private String rong_online; + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + public String getRong_online() { return rong_online; } diff --git a/common/src/main/java/com/yunbao/common/bean/MsgOnlineStatusBean.java b/common/src/main/java/com/yunbao/common/bean/MsgOnlineStatusBean.java new file mode 100644 index 000000000..df8af0547 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/MsgOnlineStatusBean.java @@ -0,0 +1,24 @@ +package com.yunbao.common.bean; +/** + * 消息列表用户在线状态 + */ +public class MsgOnlineStatusBean { + private String id; + private String online; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getOnline() { + return online; + } + + public void setOnline(String online) { + this.online = online; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/MsgRecommendBean.java b/common/src/main/java/com/yunbao/common/bean/MsgRecommendBean.java new file mode 100644 index 000000000..57dfec7c8 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/MsgRecommendBean.java @@ -0,0 +1,70 @@ +package com.yunbao.common.bean; + +/** + * 消息-推荐消息 + */ +public class MsgRecommendBean { + private String id; + private String avatar; + private String user_login; + private String user_nicename; + private String langue; + private String online; + private boolean sayHi = false; + + public boolean isSayHi() { + return sayHi; + } + + public void setSayHi(boolean sayHi) { + this.sayHi = sayHi; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getUser_login() { + return user_login; + } + + public void setUser_login(String user_login) { + this.user_login = user_login; + } + + public String getUser_nicename() { + return user_nicename; + } + + public void setUser_nicename(String user_nicename) { + this.user_nicename = user_nicename; + } + + public String getLangue() { + return langue; + } + + public void setLangue(String langue) { + this.langue = langue; + } + + public String getOnline() { + return online; + } + + public void setOnline(String online) { + this.online = online; + } +} diff --git a/common/src/main/java/com/yunbao/common/event/LiveMsgWindowsCloseEvent.java b/common/src/main/java/com/yunbao/common/event/LiveMsgWindowsCloseEvent.java new file mode 100644 index 000000000..56761a285 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LiveMsgWindowsCloseEvent.java @@ -0,0 +1,6 @@ +package com.yunbao.common.event; + +public class LiveMsgWindowsCloseEvent { + public LiveMsgWindowsCloseEvent() { + } +} diff --git a/common/src/main/java/com/yunbao/common/event/MessageIMLiveEvent.java b/common/src/main/java/com/yunbao/common/event/MessageIMLiveEvent.java new file mode 100644 index 000000000..4ab2fa6ca --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/MessageIMLiveEvent.java @@ -0,0 +1,33 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +/** + * 未读消息整合 + */ +public class MessageIMLiveEvent extends BaseModel { + private int number = 0; + private int message = 0; + + public int getMessage() { + return message; + } + + public MessageIMLiveEvent setMessage(int message) { + this.message = message; + return this; + } + + public MessageIMLiveEvent(int number) { + this.number = number; + } + + public int getNumber() { + return number; + } + + public MessageIMLiveEvent setNumber(int number) { + this.number = number; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/fragment/AbsMainMessageChatListFragment.java b/common/src/main/java/com/yunbao/common/fragment/AbsMainMessageChatListFragment.java index 6cc8c97ae..e17e9d1af 100644 --- a/common/src/main/java/com/yunbao/common/fragment/AbsMainMessageChatListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/AbsMainMessageChatListFragment.java @@ -1,33 +1,51 @@ package com.yunbao.common.fragment; +import android.net.Uri; import android.os.Bundle; +import android.util.Log; import android.view.View; 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.alibaba.fastjson.JSON; +import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.MainMessageChatListTimer; +import com.yunbao.common.bean.MessageChatUserBean; +import com.yunbao.common.bean.MsgOnlineStatusBean; +import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnRecyclerListRefreshListener; import com.yunbao.common.adapter.MainConversationListAdapter; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.manager.InstructorRemarkManager; +import com.yunbao.common.utils.StringUtil; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.lang.reflect.Array; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import io.rong.imkit.conversationlist.model.BaseUiConversation; +import io.rong.imkit.conversationlist.model.SingleConversation; +import io.rong.imkit.userinfo.RongUserInfoManager; import io.rong.imkit.widget.refresh.SmartRefreshLayout; import io.rong.imlib.model.Conversation; +import io.rong.imlib.model.Message; +import io.rong.imlib.model.UserInfo; public abstract class AbsMainMessageChatListFragment extends Fragment { + private static final String TAG = "全部聊天"; public RecyclerView recyclerView; public MainConversationListAdapter mAdapter; public SmartRefreshLayout refreshLayout; @@ -118,6 +136,45 @@ public abstract class AbsMainMessageChatListFragment extends Fragment { }); } + public void loadLiveOnlineStatus(List srcList, OnRecyclerListRefreshListener> onRefreshListener){ + List uids = new ArrayList<>(); + isNet = true; + for (BaseUiConversation conversation : srcList) { + map.put(conversation.mCore.getTargetId(), conversation); + if (conversation.mCore.getConversationType() == Conversation.ConversationType.PRIVATE) { + uids.add(conversation.mCore.getTargetId()); + } + } + CommonHttpUtil.getUserOnline(String.join(",", uids), new com.yunbao.common.http.HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if(code==0&&info!=null){ + List listUserBean = JSON.parseArray(Arrays.toString(info), MsgOnlineStatusBean.class); + for (int i = 0; i list, String search) { diff --git a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java index 3d8da397d..064807c63 100644 --- a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java @@ -1,27 +1,44 @@ package com.yunbao.common.fragment; import android.content.Context; +import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; +import androidx.recyclerview.widget.LinearLayoutManager; import com.yunbao.common.R; +import com.yunbao.common.bean.MessageChatUserBean; +import com.yunbao.common.event.MessageIMLiveEvent; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnRecyclerListRefreshListener; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.InstructorRemarkManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.L; +import com.yunbao.common.utils.StringUtil; +import java.util.ArrayList; import java.util.List; import java.util.Map; import io.rong.imkit.conversationlist.model.BaseUiConversation; +import io.rong.imkit.conversationlist.model.SingleConversation; +import io.rong.imkit.userinfo.RongUserInfoManager; +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.imlib.model.Conversation; +import io.rong.imlib.model.Message; +import io.rong.imlib.model.UserInfo; public class MainMessageChatListFragment extends AbsMainMessageChatListFragment { private static final String TAG = "MainMessageChatListFragment"; @@ -33,20 +50,20 @@ public class MainMessageChatListFragment extends AbsMainMessageChatListFragment @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + L.eSw("111111"); return inflater.inflate(R.layout.fragment_main_message_chat_list, container, false); } MainMessageChatFragment conversationListFragment; @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - Log.i(TAG, "onViewCreated: 准备创建融云"); + public void onResume() { + super.onResume(); conversationListFragment = new MainMessageChatFragment(); setAdapter(conversationListFragment.getAdapter()); - FragmentManager manager = ((FragmentActivity) mContext).getSupportFragmentManager(); + FragmentManager manager = getChildFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); - transaction.replace(view.findViewById(R.id.container).getId(), conversationListFragment); + transaction.replace(R.id.container, conversationListFragment); transaction.commitAllowingStateLoss(); //自定义空数据背景View //conversationListFragment.setEmptyView(emptyView); @@ -60,10 +77,95 @@ public class MainMessageChatListFragment extends AbsMainMessageChatListFragment public void onFinish(Map stringIntegerMap) { conversationListFragment.getAdapter().setTimerMap(stringIntegerMap); updateList(); + loadLiveOnlineStatus(baseUiConversations, new OnRecyclerListRefreshListener>() { + @Override + public void onFinish(List baseUiConversations) { + conversationListFragment.getAdapter().setSrcList(baseUiConversations); + } + }); + int count=0; + for (int i = 0; i uids = new ArrayList<>(); + for (BaseUiConversation conversation : baseUiConversations) { + map.put(conversation.mCore.getTargetId(), conversation); + if (conversation.mCore.getConversationType() == Conversation.ConversationType.PRIVATE) { + uids.add(conversation.mCore.getTargetId()); + } + } + getUserInfo(uids); } }); + } + + private void getUserInfo(List uidList) { + String uids = String.join(",", uidList); + LiveNetManager.get(getContext()) + .getOtherList(uids, new HttpCallback>() { + @Override + public void onSuccess(List data) { + List list = new ArrayList<>(); + for (MessageChatUserBean datum : data) { + Conversation conversation = new Conversation(); + BaseUiConversation baseUiConversation = new SingleConversation(getContext(), conversation); + baseUiConversation.mCore.setTargetId(datum.getId()); + baseUiConversation.mCore.setSenderUserId(IMLoginManager.get(getContext()).getUserInfo().getId() + ""); + baseUiConversation.mCore.setSentStatus(Message.SentStatus.CANCELED); + baseUiConversation.mCore.setSentTime(-1); + baseUiConversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE); + baseUiConversation.mCore.setPortraitUrl(datum.getAvatar()); + String remark = InstructorRemarkManager.get(getContext()).getInstructorRemark().get(datum.getId()); + baseUiConversation.mCore.setConversationTitle(StringUtil.isEmpty(remark) ? datum.getUserNiceName() : remark); + + list.add(baseUiConversation); + + UserInfo userInfo = new UserInfo(baseUiConversation.mCore.getTargetId(), + baseUiConversation.mCore.getConversationTitle(), + Uri.parse(baseUiConversation.mCore.getPortraitUrl())); + RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo); + } + if (!list.isEmpty()) { + List srcList = new ArrayList<>(mAdapter.getSrcList()); + srcList.addAll(list); + Log.i(TAG, "onSuccess: 增加用户数:" + list.size() + "||总用户数:" + srcList.size()); + for (BaseUiConversation conversation : srcList) { + Log.i(TAG, "onSuccess: 用户id:" + conversation.mCore.getTargetId() + "||用户名:" + conversation.mCore.getConversationTitle() + "||用户头像:" + conversation.mCore.getPortraitUrl()); + } + int position = 0; + try { + position = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition(); + } catch (Exception e) { + + } + mAdapter.setDataCollection(srcList); + //mAdapter.onFinish(); + recyclerView.scrollToPosition(position); + } + onRefreshFinished(); + onLoadMoreFinished(); + } + + @Override + public void onError(String error) { + onLoadMoreFinished(); + onRefreshFinished(); + } + }); + + } + + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + L.eSw("222222"); + Log.i(TAG, "onViewCreated: 准备创建融云"); + } diff --git a/common/src/main/java/com/yunbao/common/fragment/MainMessageRecommendFragment.java b/common/src/main/java/com/yunbao/common/fragment/MainMessageRecommendFragment.java index 0c72d07a3..2fa8ea33a 100644 --- a/common/src/main/java/com/yunbao/common/fragment/MainMessageRecommendFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/MainMessageRecommendFragment.java @@ -1,51 +1,131 @@ package com.yunbao.common.fragment; +import android.content.Context; import android.os.Bundle; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.lifecycle.Observer; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; -import com.google.gson.Gson; +import com.alibaba.fastjson.JSON; import com.yunbao.common.R; -import com.yunbao.common.adapter.MainConversationListAdapter; -import com.yunbao.common.utils.L; -import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.adapter.MsgRecommendAdapter; +import com.yunbao.common.bean.MsgRecommendBean; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import io.rong.imkit.conversationlist.ConversationListAdapter; -import io.rong.imkit.conversationlist.ConversationListFragment; -import io.rong.imkit.conversationlist.model.BaseUiConversation; -import io.rong.imkit.conversationlist.model.SingleConversation; -import io.rong.imkit.event.Event; -import io.rong.imlib.RongIMClient; -import io.rong.imlib.model.Conversation; -import io.rong.imlib.model.SearchConversationResult; +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 MainMessageRecommendFragment extends ConversationListFragment { +public class MainMessageRecommendFragment extends AbsMainMessageChatListFragment { + SmartRefreshLayout mRefreshLayout; + RecyclerView mList; + Context mContext; + MsgRecommendAdapter adapter; + List list = new ArrayList<>(); @Nullable public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.msg_main_recommend_list_fragment, container, false); } + public MainMessageRecommendFragment(Context context) { + this.mContext = context; + } + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + initView(view); + initRefreshView(); + initData(); + } + + private void initView(View view) { + mRefreshLayout = view.findViewById(R.id.rc_refresh); + mList = view.findViewById(R.id.rc_conversation_list); + LinearLayoutManager layoutManager = new LinearLayoutManager(this.getActivity()); + mList.setLayoutManager(layoutManager); + mList.setItemViewCacheSize(0); + } + + protected void initRefreshView() { + mRefreshLayout.setNestedScrollingEnabled(false); + mRefreshLayout.setRefreshHeader(new RongRefreshHeader(getContext())); + mRefreshLayout.setRefreshFooter(new RongRefreshHeader(getContext())); + mRefreshLayout.setEnableLoadMore(false); + mRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + initData(); + } + }); + mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() { + public void onLoadMore(@NonNull RefreshLayout refreshLayout) { + + } + }); + adapter = new MsgRecommendAdapter(mContext,list); + mList.setAdapter(adapter); + adapter.setOnItemSayHi(new MsgRecommendAdapter.onItemSayHi() { + @Override + public void onSayHi(MsgRecommendBean model,int position) { + if (model.isSayHi()) { + return; + } + CommonHttpUtil.sayHi(model.getId(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + list.get(position).setSayHi(true); + adapter.notifyItemChanged(position); + } + ToastUtil.show(msg); + } + }); + } + }); + } + + private void initData() { + CommonHttpUtil.getMainMsgRecommend(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info != null) { + list = JSON.parseArray(Arrays.toString(info), MsgRecommendBean.class); + adapter.setDataCollection(list); + mRefreshLayout.finishRefresh(true); + } else { + ToastUtil.show(msg); + } + } + }); + } + + @Override + public void onChatList() { } + @Override + public void search(String string) { + } + @Override + public void updateList() { - + } } diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index 8c30a1cb4..9b6b8d3f0 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -685,6 +685,39 @@ public class CommonHttpUtil { .params("dynamic_id", dynamic_id) .execute(callback); } + + /** + * 获取打招呼推荐列表 + */ + public static void getMainMsgRecommend(HttpCallback callback) { + HttpClient.getInstance().get("Pdluser.getRecommendUser", "Pdluser.getRecommendUser") + .execute(callback); + } + + /** + * 打招呼 + * @param toUid + * @param callback + */ + public static void sayHi(String toUid,HttpCallback callback) { + HttpClient.getInstance().get("Pdluser.liveCall", "Pdluser.liveCall") + .params("target_uid",toUid) + .params("behavior_type","5") + .execute(callback); + } + + /** + *获取聊天列表用户在线状态 + * @param toUid + * @param callback + */ + public static void getUserOnline(String toUid,HttpCallback callback) { + HttpClient.getInstance().get("Pdluser.getUserOnline", "Pdluser.getUserOnline") + .params("uids",toUid) + .execute(callback); + } + + } diff --git a/common/src/main/java/com/yunbao/common/views/MsgCommemdViewHolder.java b/common/src/main/java/com/yunbao/common/views/MsgCommemdViewHolder.java new file mode 100644 index 000000000..6e8297e3b --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MsgCommemdViewHolder.java @@ -0,0 +1,49 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.exoplayer2.C; +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.bean.MsgRecommendBean; +import com.yunbao.common.bean.playerObject; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ClipPathCircleImage; + +public class MsgCommemdViewHolder extends RecyclerView.ViewHolder { + private ClipPathCircleImage mAvatar; + private TextView rc_conversation_title; + private TextView sayHi; + + public MsgCommemdViewHolder(@NonNull View itemView) { + super(itemView); + mAvatar = itemView.findViewById(R.id.avatar); + rc_conversation_title = itemView.findViewById(R.id.rc_conversation_title); + sayHi = itemView.findViewById(R.id.sayHi); + } + + public void setData(MsgRecommendBean model, Context mContext,onItemSayHi onItemSayHi) { + ImgLoader.display(itemView.getContext(), model.getAvatar(), mAvatar); + rc_conversation_title.setText(model.getUser_nicename()); + sayHi.setText(model.isSayHi()? (WordUtil.isNewZh()?"已打招呼":"Said Hallo"):(WordUtil.isNewZh()?"打招呼":"Greet")); + sayHi.setBackground(model.isSayHi()? mContext.getDrawable(R.drawable.bg_msg_recommended):mContext.getDrawable(R.drawable.bg_msg_recommend)); + sayHi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(onItemSayHi!=null){ + onItemSayHi.onSayHi(model); + } + } + }); + } + + public interface onItemSayHi{ + void onSayHi(MsgRecommendBean model); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/MsgRecommendPopupView.java b/common/src/main/java/com/yunbao/common/views/MsgRecommendPopupView.java new file mode 100644 index 000000000..cff035874 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MsgRecommendPopupView.java @@ -0,0 +1,40 @@ +package com.yunbao.common.views; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.AttachPopupView; +import com.yunbao.common.R; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +public class MsgRecommendPopupView extends AttachPopupView { + + ItemDelListener itemDelListener; + + public MsgRecommendPopupView(@NonNull Context context, ItemDelListener itemDelListener) { + super(context); + this.itemDelListener = itemDelListener; + } + + @Override + protected int getImplLayoutId() { + return R.layout.view_msg_recommend; + } + + @Override + protected void onCreate() { + //特效设置 + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.close), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + dismiss(); + itemDelListener.onItemDel(); + } + }); + } + + public interface ItemDelListener { + void onItemDel(); + } +} diff --git a/common/src/main/res/drawable/backgroud_user_home_msg.xml b/common/src/main/res/drawable/backgroud_user_home_msg.xml new file mode 100644 index 000000000..1d5b3309d --- /dev/null +++ b/common/src/main/res/drawable/backgroud_user_home_msg.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_msg_recommend.xml b/common/src/main/res/drawable/bg_msg_recommend.xml new file mode 100644 index 000000000..718443abb --- /dev/null +++ b/common/src/main/res/drawable/bg_msg_recommend.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_msg_recommended.xml b/common/src/main/res/drawable/bg_msg_recommended.xml new file mode 100644 index 000000000..f093ebea8 --- /dev/null +++ b/common/src/main/res/drawable/bg_msg_recommended.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/activity_user_home.xml b/common/src/main/res/layout/activity_user_home.xml index af0023e3c..1024df10f 100644 --- a/common/src/main/res/layout/activity_user_home.xml +++ b/common/src/main/res/layout/activity_user_home.xml @@ -213,30 +213,62 @@ + android:orientation="vertical" + android:gravity="center_horizontal" + android:layout_height="wrap_content"> - - - + android:layout_height="35dp" + android:minWidth="90dp" + android:background="@drawable/bg_main_com_type" + android:gravity="center" + android:paddingStart="10dp" + android:paddingEnd="10dp"> + + + + + + + + + + + + diff --git a/common/src/main/res/layout/dialog_live_new_function.xml b/common/src/main/res/layout/dialog_live_new_function.xml index c3f4f3f5b..5f56e7029 100644 --- a/common/src/main/res/layout/dialog_live_new_function.xml +++ b/common/src/main/res/layout/dialog_live_new_function.xml @@ -529,11 +529,32 @@ android:textColor="#FF9A9A9A" android:textSize="12sp" /> + + + + + @@ -566,26 +587,7 @@ android:layout_marginStart="16dp" android:layout_marginBottom="20dp"> - - - - - diff --git a/common/src/main/res/layout/msg_main_recommend_item.xml b/common/src/main/res/layout/msg_main_recommend_item.xml index 2594d56a9..9cbc6b4be 100644 --- a/common/src/main/res/layout/msg_main_recommend_item.xml +++ b/common/src/main/res/layout/msg_main_recommend_item.xml @@ -16,36 +16,12 @@ > - - - - - - + tools:text="" /> - - + android:id="@+id/sayHi" + android:layout_width="51dp" + android:layout_height="26dp" + android:ellipsize="end" + android:background="@drawable/bg_msg_recommend" + android:maxWidth="120dp" + android:gravity="center" + android:layout_gravity="center_vertical" + android:maxLines="1" + android:textColor="@color/white" + android:textSize="11dp" + tools:text="打招呼" /> diff --git a/common/src/main/res/layout/msg_main_recommend_list_fragment.xml b/common/src/main/res/layout/msg_main_recommend_list_fragment.xml index 2844c7f9a..5927df3a3 100644 --- a/common/src/main/res/layout/msg_main_recommend_list_fragment.xml +++ b/common/src/main/res/layout/msg_main_recommend_list_fragment.xml @@ -2,7 +2,6 @@ @@ -11,7 +10,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="match_parent"> + + + + + + + - @@ -131,7 +142,7 @@ android:maxLines="1" android:text="你好,朋友!11111111111111111111111111111111111111111" android:textColor="@color/rc_secondary_color" - android:textSize="@dimen/rc_font_text_third_size" + android:textSize="13dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait_rl" diff --git a/common/src/main/res/layout/view_msg_recommend.xml b/common/src/main/res/layout/view_msg_recommend.xml new file mode 100644 index 000000000..f3fc22927 --- /dev/null +++ b/common/src/main/res/layout/view_msg_recommend.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-b+en+us/recommed_msg_bg.png b/common/src/main/res/mipmap-b+en+us/recommed_msg_bg.png new file mode 100644 index 000000000..92929e199 Binary files /dev/null and b/common/src/main/res/mipmap-b+en+us/recommed_msg_bg.png differ diff --git a/common/src/main/res/mipmap-mdpi/msg_off.png b/common/src/main/res/mipmap-mdpi/msg_off.png new file mode 100644 index 000000000..2d6b00a9d Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/msg_off.png differ diff --git a/common/src/main/res/mipmap-mdpi/msg_online.png b/common/src/main/res/mipmap-mdpi/msg_online.png new file mode 100644 index 000000000..6d27acad7 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/msg_online.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/recommed_msg_bg.png b/common/src/main/res/mipmap-xxhdpi/recommed_msg_bg.png new file mode 100644 index 000000000..f07598cdd Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/recommed_msg_bg.png differ diff --git a/config.gradle b/config.gradle index 1272389ce..66f4bf4f3 100644 --- a/config.gradle +++ b/config.gradle @@ -4,8 +4,8 @@ ext { buildToolsVersion: "29.0.2", minSdkVersion : 23, targetSdkVersion : 34, - versionCode : 536, - versionName : "6.7.1", + versionCode : 538, + versionName : "6.7.2", namespace : "com.pandoralive.shayu" ] manifestPlaceholders = [ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index e130bbd06..1ba93ce68 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -21,6 +21,10 @@ import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; +import com.yunbao.common.event.LiveMsgWindowsCloseEvent; +import com.yunbao.common.event.MessageIMEvent; +import com.yunbao.common.event.MessageIMLiveEvent; +import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; @@ -232,6 +236,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } } } + if(fragment!=null){ + fragment.dismiss(); + } } @@ -990,14 +997,29 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL new LiveUserAnchorMailBoxPopDialog(mContext).showDialog(); } + LiveUserAnchorMsgPopDialog fragment; /** * 用户端打开聊天列表页面 */ public void openLiveMsgWindow() { - LiveUserAnchorMsgPopDialog fragment = new LiveUserAnchorMsgPopDialog(); + fragment = new LiveUserAnchorMsgPopDialog(); fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "LiveUserAnchorMsgPopDialog"); } + @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) + public void onMessageIMEvent(LiveMsgWindowsCloseEvent event) { + if(fragment!=null){ + fragment.dismiss(); + } + } + + @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) + public void onMessageIMEvent(MessageIMLiveEvent event) { + if(fragment!=null){ + fragment.refreshMsgCount(event.getNumber()); + } + } + /** * 发 弹幕 消息 */ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 59018127d..fe0eaa2d0 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -39,6 +39,7 @@ import com.lxj.xpopup.interfaces.XPopupCallback; import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.enums.ShowPattern; import com.yunbao.common.dialog.DebugDialog; +import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; @@ -1860,7 +1861,7 @@ public class LiveAudienceActivity extends LiveActivity { @SuppressLint("SetTextI18n") public void showMsgRed(int num) { - if (manager == null || manager.mLiveAudienceViewHolder == null || manager.mLiveAudienceViewHolder.mRedPoint == null) { + /*if (manager == null || manager.mLiveAudienceViewHolder == null || manager.mLiveAudienceViewHolder.mRedPoint == null) { return; } if (num == -1) { @@ -1869,7 +1870,21 @@ public class LiveAudienceActivity extends LiveActivity { } else if (num > 0) { manager.mLiveAudienceViewHolder.mRedPoint.setText(num + ""); } - manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.VISIBLE); + manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.VISIBLE);*/ + } + + //消息中心 + @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) + public void onMessageIMEvent(MessageIMEvent event) { + if (manager == null || manager.mLiveAudienceViewHolder == null || manager.mLiveAudienceViewHolder.mRedPoint == null) { + return; + } + if(event.getNumber()>0){ + manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.VISIBLE); + }else{ + manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.GONE); + } + } public void setShowCrownRed(boolean isShow) { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMsgPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMsgPopDialog.java index 2172f9d31..171591a07 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMsgPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMsgPopDialog.java @@ -1,12 +1,14 @@ package com.yunbao.live.dialog; import android.content.Context; +import android.content.DialogInterface; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.Window; import android.view.WindowManager; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -45,6 +47,8 @@ import java.util.List; public class LiveUserAnchorMsgPopDialog extends AbsDialogFragment { private ViewPager2 viewPager; private MagicIndicator mIndicator; + private TextView titleCount; + private List fragmentList; @Override @@ -68,7 +72,7 @@ public class LiveUserAnchorMsgPopDialog extends AbsDialogFragment { WindowManager.LayoutParams params = window.getAttributes(); window.setWindowAnimations(R.style.bottomToTopAnim); params.width = WindowManager.LayoutParams.MATCH_PARENT; - params.height = (int) (ScreenDimenUtil.getInstance().getScreenHeight()*0.6); + params.height = (int) (ScreenDimenUtil.getInstance().getScreenHeight() * 0.6); params.gravity = Gravity.BOTTOM; window.setAttributes(params); } @@ -78,10 +82,10 @@ public class LiveUserAnchorMsgPopDialog extends AbsDialogFragment { super.onActivityCreated(savedInstanceState); mIndicator = (MagicIndicator) findViewById(R.id.indicator); viewPager = (ViewPager2) findViewById(R.id.viewPager); + titleCount= (TextView) findViewById(R.id.titleCount); fragmentList = new ArrayList<>(); fragmentList.add(new MainMessageChatListFragment(AppManager.getInstance().getLiveActivity())); viewPager.setAdapter(new FragmentStateAdapter((FragmentActivity) AppManager.getInstance().getLiveActivity()) { - @Override public int getItemCount() { return fragmentList.size(); @@ -98,6 +102,18 @@ public class LiveUserAnchorMsgPopDialog extends AbsDialogFragment { initIndicator(); initData(); } + + public void refreshMsgCount(int num){ + if(titleCount!=null){ + titleCount.setText(getResources().getString(R.string.message_chat_msg_all_an_a)+"("+num+")"); + } + } + + @Override + public void onDismiss(DialogInterface dialog) { + super.onDismiss(dialog); + } + /** * 初始化数据 */ @@ -105,6 +121,7 @@ public class LiveUserAnchorMsgPopDialog extends AbsDialogFragment { IMLoginManager.get(mContext).checkInstructor(); MessageIMManager.get(mContext).getSystemMessages(); } + private void initIndicator() { final String[] titles = new String[]{ WordUtil.getNewString(R.string.message_chat_msg_all), @@ -148,6 +165,8 @@ public class LiveUserAnchorMsgPopDialog extends AbsDialogFragment { return linePagerIndicator; } }); + LinePagerIndicator linePagerIndicator = new LinePagerIndicator(mContext); + linePagerIndicator.setLineHeight(0); mIndicator.setNavigator(commonNavigator); ViewPageIndicatorUtils.bind(mIndicator, viewPager, new ViewPager2.OnPageChangeCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index da6d5452b..1deb21138 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -1,5 +1,6 @@ package com.yunbao.live.dialog; +import android.app.Activity; import android.app.Dialog; import android.graphics.Color; import android.graphics.drawable.Drawable; @@ -22,6 +23,7 @@ import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; +import com.yunbao.common.event.MainHomeCommunityToChatEvent; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; @@ -48,6 +50,7 @@ import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -129,6 +132,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On GifImageView btn_live; SVGAImageView gift_svga; + String userType; @Override protected int getLayoutId() { @@ -347,6 +351,8 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On isAnchor = obj.getInteger("is_anchor") == 1; mUserBean = JSON.toJavaObject(obj, UserBean.class); + userType = obj.getString("type"); + mToName = obj.getString("user_nicename"); mAvatarUrl = obj.getString("avatar"); mAction = obj.getIntValue("action"); @@ -663,7 +669,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) { + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) { if (liveBean == null) { return; } @@ -738,9 +744,32 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } else if (i == R.id.btn_setting) { if (TextUtils.equals(mLiveUid, "uid")) return; setting(); + } else if (i == R.id.btn_pri_msg) { + //私聊 + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("C") && userType.equals("C")) { + showMsgError(); + return; + } + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("A") && userType.equals("A")) { + showMsgError(); + return; + } + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("A") && userType.equals("B")) { + showMsgError(); + return; + } + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("B") && userType.equals("A")) { + showMsgError(); + return; + } + EventBus.getDefault().post(new MainHomeCommunityToChatEvent().setTargetId(mToUid)); } } + public void showMsgError() { + ToastUtil.show(WordUtil.isNewZh()?"無法聊天,待開發":"Unable to chat, awaiting development"); + } + /** * 设置 diff --git a/live/src/main/java/com/yunbao/live/presenter/AbsLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/AbsLinkMicPkPresenter.java index c99610974..110acedd9 100644 --- a/live/src/main/java/com/yunbao/live/presenter/AbsLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/AbsLinkMicPkPresenter.java @@ -11,6 +11,8 @@ import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.AppManager; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.R; import com.yunbao.live.views.LiveRoomViewHolder; public abstract class AbsLinkMicPkPresenter { @@ -115,7 +117,22 @@ public abstract class AbsLinkMicPkPresenter { } protected void isPKTmp(UserBean u) { - isPK(u); + LiveHttpUtil.livePkCheckLive(IMLoginManager.get(AppManager.getInstance().getMainActivity()).getUserInfo().getId()+"", "", "", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + if (obj != null) { + if (obj.getString("ispk").equals("0")) { + isPK(u); + } else { + ToastUtil.show(AppManager.getInstance().getMainActivity().getString(R.string.pking_over)); + } + } + } + } + }); + } protected void onDRPkApplyTmp(UserBean u) { diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index fdf3883ba..9a1723c46 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -25,6 +25,7 @@ import android.widget.ViewFlipper; import androidx.fragment.app.FragmentActivity; import com.lxj.xpopup.XPopup; +import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; @@ -374,6 +375,11 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { } else { findViewById(R.id.total_image_red_point).setVisibility(View.GONE); } + getMsgCount(); + } + + private void getMsgCount() { + MessageIMManager.get(mContext).resetImUnReadMessageCount(mContext); } public void onGuardRed() { @@ -768,7 +774,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) public void onMessageIMEvent(MessageIMEvent event) { //判断消息中心红点是否已经展示,如果已经展示并且未读消息大于0则不再执行之后的逻辑 - int number = event.getMessage(); + int number = event.getNumber(); if (v_msg_redpoint.getVisibility() == View.VISIBLE && number > 0 || SpUtil.getInstance().getBooleanValue("private_chat_message_switch")) return; if (number > 0) { diff --git a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java index d72767c8e..d29fb747e 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java @@ -184,6 +184,7 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { } public void initSwEngine(String liveUid) { + dr_pk_view.setVisibility(View.GONE); this.liveUid = liveUid; //初始化声网SDK swAuManager = SWAuManager.get(); diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index bf75a8e8d..64aeda683 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -31,6 +31,7 @@ import com.lzf.easyfloat.EasyFloat; import com.lzf.easyfloat.enums.ShowPattern; import com.lzf.easyfloat.permission.PermissionUtils; import com.lzf.easyfloat.utils.LifecycleUtils; +import com.yunbao.common.event.LiveMsgWindowsCloseEvent; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; @@ -1556,6 +1557,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onLiveEnd() { + Bus.get().post(new LiveMsgWindowsCloseEvent()); MicStatusManager.getInstance().clear(); endPlay(); if (!CommonAppConfig.LIVE_ROOM_SCROLL) { diff --git a/live/src/main/res/layout/dialog_live_user_bottom_1.xml b/live/src/main/res/layout/dialog_live_user_bottom_1.xml index f3a185349..a70f32bfb 100644 --- a/live/src/main/res/layout/dialog_live_user_bottom_1.xml +++ b/live/src/main/res/layout/dialog_live_user_bottom_1.xml @@ -14,38 +14,6 @@ android:layout_height="50dp" android:orientation="horizontal"> - - - - - - - - - - - - - + + + + + + + + + android:visibility="gone" /> + + diff --git a/live/src/main/res/values-en/strings.xml b/live/src/main/res/values-en/strings.xml index 75ff980bd..843734054 100644 --- a/live/src/main/res/values-en/strings.xml +++ b/live/src/main/res/values-en/strings.xml @@ -117,13 +117,15 @@ Fan group level Of Lv%s Can send this gift Join the fan group can be opened [Join] Join the fan group to open - 全部聊天 - 系統匹配 - 對方主動 + Chat All + Chat All + Suggest chat + System matching + User initiated 看直播%dmin [Read] [Unread] - 發起聊天 + Initiate a chat Progress To do diff --git a/live/src/main/res/values/strings.xml b/live/src/main/res/values/strings.xml index 6e72a609d..fbd77e73b 100644 --- a/live/src/main/res/values/strings.xml +++ b/live/src/main/res/values/strings.xml @@ -116,6 +116,8 @@ 加入粉絲團可開啟【加入】 加入粉絲團可開啟 全部聊天 + 全部聊天 + 推荐聊天 系統匹配 對方主動 看直播%dmin diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java index aa9ed9314..3469deb3e 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java @@ -535,7 +535,8 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl if (!TextUtils.isEmpty(content)) { IMCenter.getInstance().saveTextMessageDraft(Conversation.ConversationType.PRIVATE, targetId, content, null); } - + //关闭对话框后,刷新未读数量 + MessageIMManager.get(mContext).resetImUnReadMessageCount(mContext); EventBus.getDefault().unregister(this); } @@ -560,4 +561,5 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl hideUserCard(); } } + } diff --git a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java index 70768fd69..8e6a13fbc 100644 --- a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java @@ -471,8 +471,9 @@ public class RegisterActivity extends AbsActivity { mDialog.dismiss(); } if (bean != null) { - netHandler.post(getRandJoinAnchor); -// EventBus.getDefault().post(new RegSuccessEvent()); + //netHandler.post(getRandJoinAnchor); + jumpMain(false, null); + EventBus.getDefault().post(new RegSuccessEvent()); } } }); @@ -488,22 +489,27 @@ public class RegisterActivity extends AbsActivity { HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor").params("uid", userInfo.getId()).params("token", userInfo.getToken()).execute(new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - if (info[0] != null) { - JSONObject obj = JSON.parseObject(info[0]); - IMLoginManager.get(activity).setisNewUserOne(true); - IMLoginManager.get(activity).setNewUserGif(true); - if (obj.containsKey("home_zdy_img_us")) { - home_zdy_img_us = obj.getString("home_zdy_img_us"); - home_zdy_img_cn = obj.getString("home_zdy_img_cn"); + if(info!=null){ + if (info[0] != null) { + JSONObject obj = JSON.parseObject(info[0]); + IMLoginManager.get(activity).setisNewUserOne(true); + IMLoginManager.get(activity).setNewUserGif(true); + if (obj.containsKey("home_zdy_img_us")) { + home_zdy_img_us = obj.getString("home_zdy_img_us"); + home_zdy_img_cn = obj.getString("home_zdy_img_cn"); + } + // gotoLive(obj.getString("anchor_id")); + if (obj.containsKey("home_zdy_pop")) { + NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop")); + } + jumpMain(false, obj.getString("anchor_id")); + } else { + jumpMain(false, null); } - // gotoLive(obj.getString("anchor_id")); - if (obj.containsKey("home_zdy_pop")) { - NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop")); - } - jumpMain(false, obj.getString("anchor_id")); - } else { + }else{ jumpMain(false, null); } + EventBus.getDefault().post(new RegSuccessEvent()); } }); diff --git a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java index 6415edf00..527544e9d 100644 --- a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java @@ -52,6 +52,7 @@ import com.yunbao.common.bean.NewLevelModel; import com.yunbao.common.bean.UserHomeImgBean; import com.yunbao.common.dialog.ImagePreviewDialog; import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.event.MainHomeCommunityToChatEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.LiveHttpUtil; @@ -167,6 +168,7 @@ public class UserHomeActivity extends AbsActivity { private TextView authorNum; private TextView levelNum; private View top_bg; + private LinearLayout msgLayout; @Override protected int getLayoutId() { @@ -586,6 +588,31 @@ public class UserHomeActivity extends AbsActivity { communityRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); communityRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); + msgLayout = findViewById(R.id.msgLayout); + msgLayout.setVisibility(uid.equals(CommonAppConfig.getInstance().getUid())?View.GONE:View.VISIBLE); + msgLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //私聊 + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("C") && userInfo.getUserHomeTopInfo().getType().equals("C")) { + showMsgError(); + return; + } + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("A") && userInfo.getUserHomeTopInfo().getType().equals("A")) { + showMsgError(); + return; + } + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("A") && userInfo.getUserHomeTopInfo().getType().equals("B")) { + showMsgError(); + return; + } + if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("B") && userInfo.getUserHomeTopInfo().getType().equals("A")) { + showMsgError(); + return; + } + EventBus.getDefault().post(new MainHomeCommunityToChatEvent().setTargetId(String.valueOf(userInfo.getUserHomeTopInfo().getUser_id()))); + } + }); findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -815,6 +842,11 @@ public class UserHomeActivity extends AbsActivity { }); } + public void showMsgError() { + ToastUtil.show(WordUtil.isNewZh()?"無法聊天,待開發":"Unable to chat, awaiting development"); + } + + private void selectImg() { String permission1 = Manifest.permission.READ_EXTERNAL_STORAGE; String permission2 = Manifest.permission.WRITE_EXTERNAL_STORAGE; diff --git a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java index 755fcf47b..37192a33e 100644 --- a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java +++ b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java @@ -289,7 +289,7 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O @Override public void run() { Intent intent = new Intent(mContext, CommunitySendActivity.class); - startActivity(intent); + mContext.startActivity(intent); /*String mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType(); if ("2".equals(mBeautySdkType)) { Constants.myIntoIndex = 2; diff --git a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java index 5502b9cd2..080ee9794 100644 --- a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java +++ b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java @@ -21,17 +21,20 @@ import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.VipModel; +import com.yunbao.common.event.LiveMsgWindowsCloseEvent; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.InstructorRemarkManager; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.PDLIiveChatActivity; import com.yunbao.live.bean.SearchUserBean; import com.yunbao.live.dialog.PDLIiveChatConversationFragment; +import com.yunbao.live.event.LiveOpenSuccessEvent; import com.yunbao.main.R; import com.yunbao.main.activity.PDLiveConversationActivity; import com.yunbao.main.activity.PDLiveConversationListActivity; @@ -231,6 +234,7 @@ public class ConversationIMListManager { context.runOnUiThread(() -> { Conversation.ConversationType type = Conversation.ConversationType.PRIVATE; RouteUtils.routeToConversationActivity(context, type, userId, null); + Bus.get().post(new LiveMsgWindowsCloseEvent()); }); } conversationIMListHandler.post(getUserBaseinfoRunnable); diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java index 8398e4e7b..41459f6a9 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java @@ -1,13 +1,23 @@ package com.yunbao.main.views; import android.app.Activity; +import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.graphics.Color; +import android.graphics.drawable.Drawable; import android.os.Handler; import android.text.Editable; +import android.text.Layout; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.TextPaint; import android.text.TextUtils; import android.text.TextWatcher; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; +import android.text.style.ImageSpan; import android.util.Log; import android.util.TypedValue; import android.view.KeyEvent; @@ -16,9 +26,13 @@ import android.view.ViewGroup; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.viewpager2.adapter.FragmentStateAdapter; @@ -29,10 +43,14 @@ import com.binioter.guideview.Guide; import com.binioter.guideview.GuideBuilder; import com.facebook.appevents.AppEventsLogger; import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.enums.PopupPosition; import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.fragment.MainMessageRecommendFragment; +import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.bean.ImUserInfoModel; @@ -48,11 +66,14 @@ import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; +import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ViewPageIndicatorUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsMainViewHolder; +import com.yunbao.common.views.MsgRecommendPopupView; +import com.yunbao.common.views.MsgSysDelPopupView; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.activity.SystemMessageActivity; import com.yunbao.live.bean.ImUserBean; @@ -110,6 +131,18 @@ public class MainMessageViewHolder extends AbsMainViewHolder { private MagicIndicator mIndicator; private List fragmentList; + private ConstraintLayout tabLayout1, tabLayout2, tabLayout3; + private TextView tab1, tab2, tab3; + private View tab_line1, tab_line2, tab_line3; + private ImageView tab_icon; + + private List relativeLayouts = new ArrayList<>(); + private List tabTexts = new ArrayList<>(); + private List tabLine = new ArrayList<>(); + private LinearLayout tabLayouts; + + private int userType = 0; // (0)普通用户 (1)主播A (2)主播B + public MainMessageViewHolder setHomeZdyPop(String homeZdyPop) { this.homeZdyPop = homeZdyPop; if (TextUtils.equals(homeZdyPop, "1")) { @@ -156,6 +189,21 @@ public class MainMessageViewHolder extends AbsMainViewHolder { contacts = findViewById(R.id.news_icon_contacts); more = findViewById(R.id.news_icon_more); search = findViewById(R.id.search); + tabLayouts = findViewById(R.id.tabLayouts); + + tab_icon = findViewById(R.id.tab_icon); + tabLayout1 = findViewById(R.id.tabLayout1); + tabLayout2 = findViewById(R.id.tabLayout2); + tabLayout3 = findViewById(R.id.tabLayout3); + + tab1 = findViewById(R.id.tab1); + tab2 = findViewById(R.id.tab2); + tab3 = findViewById(R.id.tab3); + + tab_line1 = findViewById(R.id.tab_line1); + tab_line2 = findViewById(R.id.tab_line2); + tab_line3 = findViewById(R.id.tab_line3); + contacts.setOnClickListener(view -> { //通讯录 RouteUtil.forwardActivity(RouteUtil.PATH_ADDRESSBOOK); @@ -168,6 +216,133 @@ public class MainMessageViewHolder extends AbsMainViewHolder { return i == KeyEvent.KEYCODE_ENTER || i == KeyEvent.KEYCODE_NUMPAD_ENTER; } }); + netHandler = new Handler(); + moreXPopup = new XPopup.Builder(mContext).atView(more); + more.setOnClickListener(view -> { + moreXPopup.asCustom(new MsgMoreDialog(mContext)).show(); + }); + } + + private void initFragment() { + final String[] titles; + fragmentList = new ArrayList<>(); + ViewGroup.LayoutParams params = mIndicator.getLayoutParams(); + if (userType == 0) { //普通用户 + params.width = ViewGroup.LayoutParams.WRAP_CONTENT; + mIndicator.setLayoutParams(params); + titles = new String[]{WordUtil.getNewString(R.string.message_chat_msg_all_an_a)}; + fragmentList.add(new MainMessageChatListFragment(AppManager.getInstance().getMainActivity())); + } else if (userType == 1) {//主播A + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + mIndicator.setLayoutParams(params); + titles = new String[]{WordUtil.getNewString(R.string.message_chat_msg_recommend), WordUtil.getNewString(R.string.message_chat_msg_all_an_a)}; + fragmentList.add(new MainMessageRecommendFragment(AppManager.getInstance().getMainActivity())); + fragmentList.add(new MainMessageChatListFragment(AppManager.getInstance().getMainActivity())); + } else { //主播B + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + mIndicator.setLayoutParams(params); + fragmentList.add(new MainMessageChatListFragment(AppManager.getInstance().getMainActivity())); + fragmentList.add(new MainMessageChatListSystemFragment()); + fragmentList.add(new MainMessageChatListUserFragment()); + titles = new String[]{WordUtil.getNewString(R.string.message_chat_msg_all), WordUtil.getNewString(R.string.message_chat_msg_system), WordUtil.getNewString(R.string.message_chat_msg_user)}; + } + initTabView(); + ToastUtil.showDebug("列表数量x" + fragmentList.size()); + viewPager.setAdapter(new FragmentStateAdapter((FragmentActivity) AppManager.getInstance().getMainActivity()) { + + @Override + public int getItemCount() { + Log.i(TAG, "viewpage 列表 getItemCount: " + fragmentList.size()); + return fragmentList.size(); + } + + @NonNull + @Override + public Fragment createFragment(int i) { + Log.i(TAG, "createFragment: 创建fragment :" + i + " | " + fragmentList.get(i)); + return fragmentList.get(i); + } + }); + if(userType==1){ + viewPager.setCurrentItem(1); + }else{ + viewPager.setCurrentItem(0); + } + viewPager.setUserInputEnabled(false); + ConversationIMListManager.get(mContext).addUserInfoProvider(); + + CommonNavigator commonNavigator = new CommonNavigator(AppManager.getInstance().getMainActivity()); + 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")); + if (titles.length == 2 && index == 0) { + Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.icon_msg_recommend); + drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); // 设置Drawable的边界 + SpannableString spannableString = new SpannableString(" " + titles[index] + " "); + ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE); + spannableString.setSpan(imageSpan, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + spannableString.setSpan(new ClickableSpan() { + @Override + public void onClick(View widget) { + // 点击事件的处理逻辑 + /*XPopup.Builder builder = new XPopup.Builder(mContext).atView(simplePagerTitleView); + builder.hasShadowBg(false).isLightStatusBar(false).popupPosition(PopupPosition.Top).asCustom(new MsgRecommendPopupView(mContext).show());*/ + } + + @Override + public void updateDrawState(TextPaint ds) { + //super.updateDrawState(ds); + //ds.setUnderlineText(false); + } + }, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + simplePagerTitleView.setText(spannableString); + simplePagerTitleView.setMovementMethod(LinkMovementMethod.getInstance()); // 必须调用此方法 + } else { + simplePagerTitleView.setText(titles[index]); + } + + simplePagerTitleView.setTextSize(15); + simplePagerTitleView.getPaint().setFakeBoldText(true); + simplePagerTitleView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (viewPager != null) { + viewPager.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"), Color.parseColor("#FF83C6")); + return linePagerIndicator; + } + }); + mIndicator.setNavigator(commonNavigator); + ViewPageIndicatorUtils.bind(mIndicator, viewPager, new ViewPager2.OnPageChangeCallback() { + @Override + public void onPageSelected(int position) { + super.onPageSelected(position); + search.setText(""); + selectTab(position); + } + }); search.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { @@ -189,96 +364,84 @@ public class MainMessageViewHolder extends AbsMainViewHolder { } } }); - netHandler = new Handler(); - moreXPopup = new XPopup.Builder(mContext).atView(more); - more.setOnClickListener(view -> { - moreXPopup.asCustom(new MsgMoreDialog(mContext)).show(); - }); - initFragment(); - initIndicator(); } - private void initFragment() { - fragmentList = new ArrayList<>(); - fragmentList.add(new MainMessageChatListFragment(AppManager.getInstance().getMainActivity())); - fragmentList.add(new MainMessageChatListSystemFragment()); - fragmentList.add(new MainMessageChatListUserFragment()); + private void initTabView() { + relativeLayouts = new ArrayList<>(); + tabTexts = new ArrayList<>(); + tabLine = new ArrayList<>(); - ToastUtil.showDebug("列表数量x" + fragmentList.size()); - viewPager.setAdapter(new FragmentStateAdapter((FragmentActivity) AppManager.getInstance().getMainActivity()) { + relativeLayouts.add(tabLayout1); + relativeLayouts.add(tabLayout2); + relativeLayouts.add(tabLayout3); - @Override - public int getItemCount() { - Log.i(TAG, "viewpage 列表 getItemCount: " + fragmentList.size()); - return fragmentList.size(); - } - - @NonNull - @Override - public Fragment createFragment(int i) { - Log.i(TAG, "createFragment: 创建fragment :" + i + " | " + fragmentList.get(i)); - return fragmentList.get(i); - } - }); - viewPager.setCurrentItem(0); - viewPager.setUserInputEnabled(false); - ConversationIMListManager.get(mContext).addUserInfoProvider(); - } - - private void initIndicator() { - final String[] titles = new String[]{ - WordUtil.getNewString(R.string.message_chat_msg_all), - WordUtil.getNewString(R.string.message_chat_msg_system), - WordUtil.getNewString(R.string.message_chat_msg_user) - }; - CommonNavigator commonNavigator = new CommonNavigator(AppManager.getInstance().getMainActivity()); - 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 (viewPager != null) { - viewPager.setCurrentItem(index); + tabTexts.add(tab1); + tabTexts.add(tab2); + tabTexts.add(tab3); + tabLine.add(tab_line1); + tabLine.add(tab_line2); + tabLine.add(tab_line3); + if (userType == 0) { //普通用户 + relativeLayouts.get(0).setVisibility(View.VISIBLE); + tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_all_an_a)); + ViewGroup.LayoutParams params = tabLayouts.getLayoutParams(); + params.width = LinearLayout.LayoutParams.WRAP_CONTENT; + tabLayouts.setLayoutParams(params); + } else if (userType == 1) {//主播A + tab_icon.setVisibility(View.VISIBLE); + tab_icon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + /*XPopup.Builder builder = new XPopup.Builder(mContext).atView(v); + builder.hasShadowBg(false).isLightStatusBar(false).popupPosition(PopupPosition.Top).asCustom(new MsgRecommendPopupView(mContext).show());*/ + XPopup.Builder builder = new XPopup.Builder(mContext).atView(v); + builder.hasShadowBg(false).isDestroyOnDismiss(true).isLightStatusBar(false).popupPosition(PopupPosition.Bottom).asCustom(new MsgRecommendPopupView(mContext, new MsgRecommendPopupView.ItemDelListener() { + @Override + public void onItemDel() { } - } - }); - return simplePagerTitleView; - } + })).show(); + } + }); + relativeLayouts.get(0).setVisibility(View.VISIBLE); + tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_recommend)); + relativeLayouts.get(1).setVisibility(View.VISIBLE); + tabTexts.get(1).setText(WordUtil.getNewString(R.string.message_chat_msg_all_an_a)); + } else { //主播B + relativeLayouts.get(0).setVisibility(View.VISIBLE); + tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_all)); + relativeLayouts.get(1).setVisibility(View.VISIBLE); + tabTexts.get(1).setText(WordUtil.getNewString(R.string.message_chat_msg_system)); + relativeLayouts.get(2).setVisibility(View.VISIBLE); + tabTexts.get(2).setText(WordUtil.getNewString(R.string.message_chat_msg_user)); + } + for (int i = 0; i < relativeLayouts.size(); i++) { + int finalI = i; + relativeLayouts.get(i).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectTab(finalI); + viewPager.setCurrentItem(finalI); + } + }); + } + if(userType==1){ + selectTab(1); + }else{ + selectTab(0); + } + } - @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"), Color.parseColor("#FF83C6")); - return linePagerIndicator; + public void selectTab(int position) { + for (int i = 0; i < relativeLayouts.size(); i++) { + if (position == i) { + tabTexts.get(i).setTextColor(Color.parseColor("#333333")); + tabLine.get(i).setVisibility(View.VISIBLE); + } else { + tabTexts.get(i).setTextColor(Color.parseColor("#777777")); + tabLine.get(i).setVisibility(View.INVISIBLE); } - }); - mIndicator.setNavigator(commonNavigator); - ViewPageIndicatorUtils.bind(mIndicator, viewPager, new ViewPager2.OnPageChangeCallback() { - @Override - public void onPageSelected(int position) { - super.onPageSelected(position); - search.setText(""); - } - }); + } } @Override @@ -292,10 +455,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { MessageGuideView guideView = new MessageGuideView((Activity) mContext); //top_noback GuideBuilder builder = new GuideBuilder(); - builder.setTargetView(topLayout) - .setAlpha(180) - .setHighTargetCorner(20) - .setHighTargetPadding(10); + builder.setTargetView(topLayout).setAlpha(180).setHighTargetCorner(20).setHighTargetPadding(10); builder.setOverlayTarget(true); builder.setAutoDismiss(false); @@ -345,27 +505,31 @@ public class MainMessageViewHolder extends AbsMainViewHolder { Log.i(TAG, "initData: 初始化数据"); //获取一下系统通知 MessageIMManager.get(mContext).getSystemMessages(); - LiveNetManager.get(mContext) - .getIsAnchor(new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(MessageChatIsAnchor data) { - AppManager.runDebugCode(() -> { - more.setVisibility(View.VISIBLE); - }); - if (data.getIsAnchor() == 1) { - more.setVisibility(View.VISIBLE); - viewPager.setUserInputEnabled(true); - mIndicator.setVisibility(View.VISIBLE); - } - IMLoginManager.get(mContext) - .setAnchorB(data.getIsAnchor()); - } - - @Override - public void onError(String error) { - - } + LiveNetManager.get(mContext).getIsAnchor(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(MessageChatIsAnchor data) { + AppManager.runDebugCode(() -> { + more.setVisibility(View.VISIBLE); }); + if (data.getIsAnchor() == 1 && CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("C")) { + userType = 2;//主播B + more.setVisibility(View.VISIBLE); + viewPager.setUserInputEnabled(true); + //mIndicator.setVisibility(View.VISIBLE); + } else if (CommonAppConfig.getInstance().getUserBean().getUsers_type().equals("C")) { + userType = 1;//主播A + } else { + userType = 0; + } + IMLoginManager.get(mContext).setAnchorB(data.getIsAnchor()); + initFragment(); + } + + @Override + public void onError(String error) { + + } + }); } @@ -405,11 +569,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { MobclickAgent.onEvent(mContext, "information_official_notice", "官方通知"); type = userBean.getType(); netHandler.post(systemNumberRunnable); - mContext.startActivity(new Intent(mContext, SystemMessageActivity.class) - .putExtra("type", userBean.getType()) - .putExtra("uid", "") - .putExtra("title", userBean.getTitle()) - .putExtra("headImg", "")); + mContext.startActivity(new Intent(mContext, SystemMessageActivity.class).putExtra("type", userBean.getType()).putExtra("uid", "").putExtra("title", userBean.getTitle()).putExtra("headImg", "")); }); break; //互動消息 @@ -432,11 +592,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { MobclickAgent.onEvent(mContext, "information_system_interactive", "互動消息"); type = userBean.getType(); netHandler.post(systemNumberRunnable); - mContext.startActivity(new Intent(mContext, SystemMessageActivity.class) - .putExtra("type", userBean.getType()) - .putExtra("uid", "") - .putExtra("title", userBean.getTitle()) - .putExtra("headImg", "")); + mContext.startActivity(new Intent(mContext, SystemMessageActivity.class).putExtra("type", userBean.getType()).putExtra("uid", "").putExtra("title", userBean.getTitle()).putExtra("headImg", "")); }); break; //在線客服 @@ -464,11 +620,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { // WebViewActivity.forward(mContext, userBean.getLink()); RouteUtil.forwardCustomerService(userBean.getLink()); } else { - mContext.startActivity(new Intent(mContext, SystemMessageActivity.class) - .putExtra("type", userBean.getType()) - .putExtra("uid", "") - .putExtra("title", userBean.getTitle()) - .putExtra("headImg", "")); + mContext.startActivity(new Intent(mContext, SystemMessageActivity.class).putExtra("type", userBean.getType()).putExtra("uid", "").putExtra("title", userBean.getTitle()).putExtra("headImg", "")); } }); break; @@ -492,11 +644,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { MobclickAgent.onEvent(mContext, "information_system_notice", "系统消息"); type = userBean.getType(); netHandler.post(systemNumberRunnable); - mContext.startActivity(new Intent(mContext, SystemMessageActivity.class) - .putExtra("type", userBean.getType()) - .putExtra("uid", "") - .putExtra("title", userBean.getTitle()) - .putExtra("headImg", "")); + mContext.startActivity(new Intent(mContext, SystemMessageActivity.class).putExtra("type", userBean.getType()).putExtra("uid", "").putExtra("title", userBean.getTitle()).putExtra("headImg", "")); }); break; } @@ -675,8 +823,8 @@ public class MainMessageViewHolder extends AbsMainViewHolder { LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) { - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw); + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw); } @Override diff --git a/main/src/main/res/layout/view_main_message.xml b/main/src/main/res/layout/view_main_message.xml index 4e2b23189..47097b605 100644 --- a/main/src/main/res/layout/view_main_message.xml +++ b/main/src/main/res/layout/view_main_message.xml @@ -301,22 +301,196 @@ android:id="@+id/indicator" android:layout_width="match_parent" android:layout_height="37dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/line" /> + android:visibility="gone" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> diff --git a/main/src/main/res/mipmap-xxhdpi/icon_msg_recommend.png b/main/src/main/res/mipmap-xxhdpi/icon_msg_recommend.png new file mode 100644 index 000000000..c8d907291 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/icon_msg_recommend.png differ