update 聊天页面顶部信息

This commit is contained in:
z583819556 2024-03-09 16:23:57 +08:00
parent f4210bf136
commit ee8f6baf02
15 changed files with 387 additions and 13 deletions

View File

@ -255,6 +255,16 @@ public class IMLoginModel extends BaseModel {
@SerializedName("guard_type")
private String guardType = "";
@SerializedName("isAttention")
private int attention;
public int getAttention() {
return attention;
}
public void setAttention(int attention) {
this.attention = attention;
}
public String getCreateTime() {
return createTime;

View File

@ -0,0 +1,16 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class MessageChatIsAnchor extends BaseModel{
@SerializedName("is_anchor")
private int isAnchor;//是否是主播 0否 1是
public int getIsAnchor() {
return isAnchor;
}
public void setIsAnchor(int isAnchor) {
this.isAnchor = isAnchor;
}
}

View File

@ -83,10 +83,43 @@ public class MessageUserInfoBean extends BaseModel{
private String area;
private int is_hello;
private String star_name;
private String career;
private String height;
private String age;
public String getAge() {
if(StringUtil.isEmpty(age)){
age="0";
}
return age;
}
public void setAge(String age) {
this.age = age;
}
public UserInfo() {
}
public String getCareer() {
return career;
}
public void setCareer(String career) {
this.career = career;
}
public String getHeight() {
if(StringUtil.isEmpty(height)){
height="0";
}
return height;
}
public void setHeight(String height) {
this.height = height;
}
public int getId() {
return id;
}
@ -445,5 +478,6 @@ public class MessageUserInfoBean extends BaseModel{
public void setWealth_icon(String wealth_icon) {
this.wealth_icon = wealth_icon;
}
}
}

View File

@ -43,6 +43,7 @@ import com.yunbao.common.bean.LiveStetUpStatusModel;
import com.yunbao.common.bean.LiveTaskModel;
import com.yunbao.common.bean.LiveUserMailBoxModel;
import com.yunbao.common.bean.MedalAchievementModel;
import com.yunbao.common.bean.MessageChatIsAnchor;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.MessageUserInfoBean;
import com.yunbao.common.bean.MsgSwitchDetailModel;
@ -1176,4 +1177,9 @@ public interface PDLiveApi {
Observable<ResponseModel<List<MessageChatUserBean>>> addressBookSearch(@Query("user_nicename") String key);
@GET("/api/public/?service=Pdlinfos.getOtherInfo")
Observable<ResponseModel<MessageUserInfoBean>> getOtherInfo(@Query("tuid") String tuid);
@GET("/api/public/?service=Userhome.getUserHomeBanner")
Observable<ResponseModel<List<String>>> getUserHomeBanner(@Query("select_uid") String tuid);
@GET("/api/public/?service=Pdlinfos.getIsAnchor")
Observable<ResponseModel<MessageChatIsAnchor>> getIsAnchor();
}

View File

@ -43,6 +43,7 @@ import com.yunbao.common.bean.LiveStetUpStatusModel;
import com.yunbao.common.bean.LiveTaskModel;
import com.yunbao.common.bean.LiveUserMailBoxModel;
import com.yunbao.common.bean.MedalAchievementModel;
import com.yunbao.common.bean.MessageChatIsAnchor;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.MessageUserInfoBean;
import com.yunbao.common.bean.NobleRankHideUserListModel;
@ -3028,6 +3029,45 @@ public class LiveNetManager {
}
}).isDisposed();
}
public void getUserHomeBanner(String search,HttpCallback<List<String>> callback) {
API.get().pdLiveApi(mContext)
.getUserHomeBanner(search)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(roomMicStatusModelResponseModel -> {
if (callback != null) {
callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void getIsAnchor(HttpCallback<MessageChatIsAnchor> callback) {
API.get().pdLiveApi(mContext)
.getIsAnchor()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(roomMicStatusModelResponseModel -> {
if (callback != null) {
callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
/**
* 直播间取消网络请求
*/

View File

@ -0,0 +1,9 @@
package com.yunbao.common.utils;
import android.view.View;
public class ViewUtils {
public static <T extends View> T findViewById(View view,int id,Class<T> clazz){
return view.findViewById(id);
}
}

View File

@ -16,6 +16,7 @@ import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
@ -24,6 +25,7 @@ import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.GsonUtils;
import com.yunbao.common.activity.AbsActivity;
@ -31,8 +33,11 @@ import com.yunbao.common.activity.SelectImageActivity;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.bean.MessageChatUserBean;
import com.yunbao.common.bean.MessageUserInfoBean;
import com.yunbao.common.bean.NoviceInstructorModel;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.event.PDChatInputModeEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.OnSendMessageListener;
@ -41,7 +46,10 @@ import com.yunbao.common.manager.NoviceInstructorManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.message.content.MessageChatTipsContent;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.ViewUtils;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.live.dialog.MenuPopuwWindow;
import com.yunbao.live.event.InputPanelViewHolderEvent;
@ -49,12 +57,16 @@ import com.yunbao.live.utils.WindowSoftModeAdjustResizeExecutor;
import com.yunbao.live.views.InputPanelViewHolder;
import com.yunbao.live.views.PDLiveConversationFragment;
import com.yunbao.main.R;
import com.yunbao.main.adapter.MessageChatTopImageListAdapter;
import com.yunbao.main.adapter.MessageChatTopTopListAdapter;
import com.yunbao.main.fragment.MyAddressBookFragment;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import io.rong.imkit.IMCenter;
import io.rong.imkit.conversation.extension.InputMode;
@ -80,6 +92,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
private String targetId = "";
private View card;
private View mContainer;
private MessageUserInfoBean userInfoBean;
@Override
@ -172,9 +185,10 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
//绑定聊天用户id
inputPanel.setTargetId(targetId);
ToastUtil.show("id:"+targetId);
ToastUtil.show("id:" + targetId);
//获取用户信息
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
setUserCard();
if (null != userInfo) {
titleView.setText(userInfo.getName());
if (!TextUtils.isEmpty(userInfo.getExtra())) {
@ -193,10 +207,6 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
inputPanel.setAdmin(isAdmin);
Log.e("PDLiveConversation", userInfo.getExtra());
}
} else {
/* titleView.setText("系統消息");
inputPanel.setVisibility(View.GONE);*/
setUserCard();
}
getDraft();
@ -248,10 +258,45 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
private void setUserCard() {
LiveNetManager.get(mContext)
.getOtherInfo(targetId, new HttpCallback<MessageChatUserBean>() {
.getOtherInfo(targetId, new HttpCallback<MessageUserInfoBean>() {
@Override
public void onSuccess(MessageChatUserBean data) {
public void onSuccess(MessageUserInfoBean data) {
userInfoBean = data;
titleView.setText(data.getUser().getUserNicename() + "_");
ImgLoader.display(mContext, data.getUser().getAvatar(), ViewUtils.findViewById(card, R.id.rc_conversation_portrait, ImageView.class));
ViewUtils.findViewById(card, R.id.userName, TextView.class).setText(data.getUser().getUserNicename());
ViewUtils.findViewById(card, R.id.sign, TextView.class).setText(data.getUser().getSignature());
showBanner();
showTag();
if(data.getUser().getAttention()==0){
ViewUtils.findViewById(card,R.id.follow, Button.class).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
follow((Button) view,userInfoBean.getUser().getId()+"");
}
});
}else{
ViewUtils.findViewById(card,R.id.follow, Button.class).setVisibility(View.INVISIBLE);
}
}
@Override
public void onError(String error) {
}
private void showBanner() {
LiveNetManager.get(mContext)
.getUserHomeBanner(targetId, new HttpCallback<List<String>>() {
@Override
public void onSuccess(List<String> data) {
List<String> urls = new ArrayList<>();
urls.add(userInfoBean.getUser().getAvatar());
urls.addAll(data);
RecyclerView avatarList = ViewUtils.findViewById(card, R.id.avatar_list, RecyclerView.class);
MessageChatTopImageListAdapter adapter = new MessageChatTopImageListAdapter();
avatarList.setAdapter(adapter);
adapter.setUrls(urls);
}
@Override
@ -260,6 +305,37 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
}
});
}
private void showTag(){
List<String> tags=new ArrayList<>();
tags.add(userInfoBean.getInfo().getAge());
if(!StringUtil.isEmpty(userInfoBean.getInfo().getCareer())){
tags.add(userInfoBean.getInfo().getCareer());
}
if(!StringUtil.isEmpty(userInfoBean.getInfo().getHeight())&&!userInfoBean.getInfo().getHeight().equals("0")) {
tags.add(userInfoBean.getInfo().getHeight());
}
List<String> t;
if(WordUtil.isNewZh()) {
t=userInfoBean.getInfo().getCn_label();
}else{
t=userInfoBean.getInfo().getEn_label();
}
if(t!=null){
for (String tag : t) {
if(!StringUtil.isEmpty(tag)){
tags.add(tag);
}
}
}
MessageChatTopTopListAdapter adapter=new MessageChatTopTopListAdapter();
RecyclerView avatarList = ViewUtils.findViewById(card, R.id.tag_list, RecyclerView.class);
avatarList.setAdapter(adapter);
adapter.setUrls(tags);
}
});
}
@Override
public void onClick(View v) {
@ -342,7 +418,20 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
}
}
}
private void follow(Button btn, String id) {
LiveNetManager.get(btn.getContext())
.setAttents(id, new HttpCallback<SetAttentsModel>() {
@Override
public void onSuccess(SetAttentsModel data) {
btn.setVisibility(View.INVISIBLE);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
@ -376,5 +465,4 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
hideUserCard();
}
}
}

View File

@ -0,0 +1,55 @@
package com.yunbao.main.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.main.R;
import java.util.ArrayList;
import java.util.List;
public class MessageChatTopImageListAdapter extends RecyclerView.Adapter<com.yunbao.main.adapter.MessageChatTopImageListAdapter.ViewHolder> {
List<String> urls = new ArrayList<>();
public void setUrls(List<String> urls) {
ToastUtil.show("照片数量:"+urls.size());
this.urls = urls;
notifyDataSetChanged();
}
@NonNull
@Override
public com.yunbao.main.adapter.MessageChatTopImageListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_msg_chat_top_image, parent, false));
}
@Override
public void onBindViewHolder(@NonNull com.yunbao.main.adapter.MessageChatTopImageListAdapter.ViewHolder holder, int position) {
holder.show(urls.get(position));
}
@Override
public int getItemCount() {
return urls.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
public ViewHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.cover);
}
public void show(String url) {
ImgLoader.display(itemView.getContext(), url, imageView);
}
}
}

View File

@ -0,0 +1,55 @@
package com.yunbao.main.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.main.R;
import java.util.ArrayList;
import java.util.List;
public class MessageChatTopTopListAdapter extends RecyclerView.Adapter<MessageChatTopTopListAdapter.ViewHolder> {
List<String> urls = new ArrayList<>();
public void setUrls(List<String> urls) {
this.urls = urls;
notifyDataSetChanged();
}
@NonNull
@Override
public MessageChatTopTopListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_msg_chat_top_tag, parent, false));
}
@Override
public void onBindViewHolder(@NonNull MessageChatTopTopListAdapter.ViewHolder holder, int position) {
holder.show(urls.get(position));
}
@Override
public int getItemCount() {
return urls.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView tagView;
public ViewHolder(@NonNull View itemView) {
super(itemView);
tagView = itemView.findViewById(R.id.tag);
}
public void show(String tag) {
tagView.setText(String.format("#%s", tag));
}
}
}

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="63dp" android:height="23dp">
<shape android:shape="rectangle">
<solid android:color="#fffff6e8" />
<corners android:topLeftRadius="20dp" android:topRightRadius="20dp" android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp" />
</shape>
</item>
</selector>

View File

@ -102,7 +102,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginTop="70dp"
android:layout_marginTop="60dp"
android:text="TextView"
android:textColor="#333333"
android:textSize="16sp"
@ -126,7 +126,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="TextView"
android:text="@string/activity_msg_chat_top_tip1"
android:textColor="#777777"
android:textSize="11sp"
app:layout_constraintStart_toStartOf="@+id/userName"
@ -157,6 +157,7 @@
android:id="@+id/follow"
android:layout_width="69dp"
android:layout_height="38dp"
android:layout_marginTop="-10dp"
android:background="@drawable/bg_msg_address_book_user_btn_fan"
android:drawableLeft="@mipmap/bg_msg_chat_title_follow"
android:gravity="center"
@ -168,8 +169,8 @@
android:textColor="#FFFFFF"
android:textSize="13sp"
app:autoSizeMaxTextSize="13sp"
app:autoSizeMinTextSize="3sp"
app:autoSizeMinTextSize="3sp"
app:autoSizeStepGranularity="1sp"
app:autoSizeTextType="uniform"
app:layout_constraintEnd_toEndOf="@+id/constraintLayout6"
@ -183,6 +184,10 @@
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="60dp"
tools:listitem="@layout/view_msg_chat_top_image"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="9"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/imageView"
app:layout_constraintStart_toStartOf="parent" />
@ -191,9 +196,14 @@
android:id="@+id/tag_list"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@+id/avatar_list"
app:layout_constraintEnd_toEndOf="@+id/avatar_list"
app:layout_constraintStart_toStartOf="@+id/avatar_list" />
app:layout_constraintStart_toStartOf="@+id/avatar_list"
tools:itemCount="9"
tools:listitem="@layout/view_msg_chat_top_tag" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginEnd="5dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/icon_beauty_filter_natural_8"
app:riv_corner_radius="10dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="63dp"
android:layout_height="23dp"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginEnd="5dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:gravity="start|center"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:textColor="#C38764"
android:textSize="11sp"
android:id="@+id/tag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/view_chat_top_tag"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="#标签" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -36,4 +36,5 @@
<string name="activity_msg_addressbook_tab_fan">粉絲</string>
<string name="activity_msg_addressbook_tab_fan2">回關</string>
<string name="activity_msg_addressbook_tab_mutual">互相關注</string>
<string name="activity_msg_chat_top_tip1">赠送礼物陪伴TA</string>
</resources>

View File

@ -36,4 +36,5 @@
<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>
<string name="activity_msg_chat_top_tip1">Present a gift to accompany him/her~</string>
</resources>