主播消息中心功能构建

This commit is contained in:
18401019693 2023-02-18 13:21:59 +08:00
parent d86e16c9f5
commit 8d823f7a07
17 changed files with 874 additions and 334 deletions

View File

@ -0,0 +1,52 @@
package com.yunbao.common.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.views.LiveSystemMessageViewHolder;
import java.util.ArrayList;
import java.util.List;
/**
* 主播消息中心适配器
*/
public class LiveSystemMessageAdapter extends RecyclerView.Adapter {
private Context mContext;
private LayoutInflater mInflater;
private List<ListInfoMessageModel> listInfoMessageModels = new ArrayList<>();
public LiveSystemMessageAdapter(Context mContext) {
this.mContext = mContext;
mInflater = LayoutInflater.from(mContext);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new LiveSystemMessageViewHolder(mInflater.inflate(R.layout.view_live_system_message, parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
LiveSystemMessageViewHolder messageViewHolder = (LiveSystemMessageViewHolder) holder;
messageViewHolder.setViewData(listInfoMessageModels.get(position));
}
@Override
public int getItemCount() {
return listInfoMessageModels.size();
}
public void addData(List<ListInfoMessageModel> list) {
listInfoMessageModels.addAll(list);
notifyDataSetChanged();
}
}

View File

@ -0,0 +1,96 @@
package com.yunbao.common.bean;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ListInfoMessageModel extends BaseModel {
@SerializedName("id")
private int id;
@SerializedName("title")
private String title;
@SerializedName("banner")
private String banner;
@SerializedName("content")
private String content;
@SerializedName("link")
private String link;
@SerializedName("addtime")
private String addtime;
public int getId() {
return id;
}
public ListInfoMessageModel setId(int id) {
this.id = id;
return this;
}
public String getTitle() {
return title;
}
public ListInfoMessageModel setTitle(String title) {
this.title = title;
return this;
}
public String getBanner() {
return banner;
}
public ListInfoMessageModel setBanner(String banner) {
this.banner = banner;
return this;
}
public String getContent() {
return content;
}
public ListInfoMessageModel setContent(String content) {
this.content = content;
return this;
}
public String getLink() {
return link;
}
public ListInfoMessageModel setLink(String link) {
this.link = link;
return this;
}
public String getAddtime() {
return addtime;
}
public ListInfoMessageModel setAddtime(String addtime) {
this.addtime = addtime;
return this;
}
/**
* 会话列表展示时间
*/
public String getLastDate(String type) {
if (!TextUtils.isEmpty(addtime) && !TextUtils.equals(addtime, "0")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date currenTimeZone;
if (TextUtils.equals(type, "-1")) {
currenTimeZone = new Date(Long.parseLong(addtime));
} else {
currenTimeZone = new Date(Long.parseLong(addtime + "000"));
}
return sdf.format(currenTimeZone);
} else {
return "";
}
}
}

View File

@ -12,6 +12,7 @@ import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner;
@ -542,4 +543,9 @@ public interface PDLiveApi {
Observable<ResponseModel<BaseModel>> jieshuDRPK(
@Query("roomid") String roomId,
@Query("uid") String uid);
@GET("/api/public/?service=Message.getListInfo")
Observable<ResponseModel<List<ListInfoMessageModel>>> getListInfo(
@Query("type") String type,
@Query("p") int p);
}

View File

@ -14,6 +14,7 @@ import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner;
@ -1075,6 +1076,18 @@ public class LiveNetManager {
}).isDisposed();
}
public void getListInfo(String type, int p, HttpCallback<List<ListInfoMessageModel>> callback) {
API.get().pdLiveApi(mContext)
.getListInfo(type, p)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
callback.onSuccess(listResponseModel.getData().getInfo());
}, throwable -> {
callback.onError(throwable.getMessage());
}).isDisposed();
}
/**
* 直播间取消网络请求
*/

View File

@ -0,0 +1,72 @@
package com.yunbao.common.views;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.core.BottomPopupView;
import com.yunbao.common.R;
import com.yunbao.common.adapter.LiveSystemMessageAdapter;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.ToastUtil;
import java.util.List;
/**
* 主播消息中心
*/
public class LiveAnchorMessageCustomPopup extends BottomPopupView {
private LiveSystemMessageAdapter adapter;
private RecyclerView liveMessage;
public LiveAnchorMessageCustomPopup(@NonNull Context context) {
super(context);
}
// 返回自定义弹窗的布局
@Override
protected int getImplLayoutId() {
return R.layout.dialog_live_anchor_message;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
initView();
initDate();
}
private void initDate() {
LiveNetManager.get(getContext())
.getListInfo("1", 1, new HttpCallback<List<ListInfoMessageModel>>() {
@Override
public void onSuccess(List<ListInfoMessageModel> data) {
adapter.addData(data);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
private void initView() {
liveMessage = findViewById(R.id.live_message);
liveMessage.setHasFixedSize(false);
liveMessage.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
adapter = new LiveSystemMessageAdapter(getContext());
liveMessage.setAdapter(adapter);
}
@Override
public void onDestroy() {
super.onDestroy();
}
}

View File

@ -0,0 +1,47 @@
package com.yunbao.common.views;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.glide.ImgLoader;
public class LiveSystemMessageViewHolder extends RecyclerView.ViewHolder {
private TextView titleText, timeText, contextLayout, toView;
private CardView bannerCard;
private ImageView bannerImage;
public LiveSystemMessageViewHolder(@NonNull View itemView) {
super(itemView);
titleText = itemView.findViewById(R.id.title_text);
timeText = itemView.findViewById(R.id.time_text);
contextLayout = itemView.findViewById(R.id.context_layout);
toView = itemView.findViewById(R.id.to_view);
bannerCard = itemView.findViewById(R.id.banner_card);
bannerImage = itemView.findViewById(R.id.banner_image);
}
public void setViewData(ListInfoMessageModel model) {
titleText.setText(model.getTitle());
timeText.setText(model.getLastDate("1"));
if (TextUtils.isEmpty(model.getBanner())) {
bannerCard.setVisibility(View.GONE);
} else {
bannerCard.setVisibility(View.VISIBLE);
ImgLoader.display(itemView.getContext(), model.getBanner(), bannerImage);
}
contextLayout.setText(model.getContent());
if (TextUtils.isEmpty(model.getLink())) {
toView.setVisibility(View.GONE);
} else {
toView.setVisibility(View.VISIBLE);
}
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="13dp"/>
<solid android:color="#b3000000"/>
</shape>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
<solid android:color="#F4F7FC" />
</shape>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@drawable/bg_live_anchor_message"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:text="@string/message"
android:textColor="@color/black3"
android:textSize="24sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/live_message"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -1,11 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:background="@drawable/bg_live_anchor"
android:gravity="center"
android:paddingStart="6dp"
android:paddingTop="4dp"
android:paddingEnd="6dp"
android:paddingBottom="4dp">
<androidx.cardview.widget.CardView
android:layout_width="6dp"
android:layout_height="6dp"
app:cardBackgroundColor="#FF4E4E"
app:cardCornerRadius="8dp"
app:cardElevation="0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:text="00:00"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:background="@drawable/bg_live_anchor"
android:gravity="center_vertical"
android:paddingStart="6dp"
android:paddingTop="4dp"
android:paddingEnd="6dp"
android:paddingBottom="4dp">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:src="@mipmap/live_icon_data" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:text="@string/broadcast_data"
android:textColor="@color/white"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/message_linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_live_anchor"
android:gravity="center_vertical"
android:paddingStart="6dp"
android:paddingTop="4dp"
android:paddingEnd="6dp"
android:paddingBottom="4dp">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:src="@mipmap/live_icon_news" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:text="@string/message"
android:textColor="@color/white"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_live_tota"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -95,6 +194,7 @@
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/live_tool_robot"
android:layout_width="wrap_content"
@ -213,6 +313,7 @@
</LinearLayout>
</HorizontalScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -278,6 +379,7 @@
android:textColor="#FF9A9A9A"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/live_tool_random_pk"
android:layout_width="wrap_content"
@ -325,5 +427,7 @@
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="15dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="16dp"
android:text="通知標題標題通知標題標題"
android:textColor="#ff161616"
android:textSize="17sp" />
<TextView
android:id="@+id/time_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="19dp"
android:layout_marginEnd="12dp"
android:text="2-24 17:00"
android:textColor="#ff8c8c8c"
android:textSize="13sp" />
</FrameLayout>
<androidx.cardview.widget.CardView
android:id="@+id/banner_card"
android:layout_width="match_parent"
android:layout_height="102dp"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="12dp"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<ImageView
android:id="@+id/banner_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/context_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="12dp"
android:text="內容內容內容內容內容內容內容內容內容內容內容
內容內容內容內容內容內容內容內容內容內容內容內容內容內容內容
內容內容內容內容內容內容內容內容內容內容內容內容
內容內容內容內容內容內容內容。"
android:textColor="#B1B1B1"
android:textSize="13sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="20dp">
<TextView
android:id="@+id/to_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="12dp"
android:drawablePadding="4dp"
android:drawableEnd="@mipmap/icon_more"
android:gravity="center_vertical"
android:text="@string/click_to_view"
android:textColor="#ff8c8c8c"
android:textSize="13sp" />
</FrameLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

Before

Width:  |  Height:  |  Size: 603 B

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1003,4 +1003,6 @@ Limited ride And limited avatar frame</string>
<string name="live_user_ban_hd">There is no choice, the anchor is not turned on HD live.</string>
<string name="function_is_suspended">Sorry, this feature is on hold.</string>
<string name="phone_number">phone</string>
<string name="broadcast_data">Broadcast</string>
<string name="click_to_view">Click To View</string>
</resources>

View File

@ -785,6 +785,7 @@
<string name="encourage_list_nodata">暫時還沒有人給予作者鼓勵T_T</string>
<string name="click_moer">點擊查看更多</string>
<string name="customer_service">客服</string>
<string name="set_up">設定</string>
<string name="kefu_time">每日13:00PM-1:00AM</string>
@ -1023,4 +1024,6 @@
<string name="live_user_ban_hd" >無法選擇,該主播未開啟高清直播。</string>
<string name="function_is_suspended" >抱歉,該功能暫停使用中。</string>
<string name="phone_number" >手機號</string>
<string name="broadcast_data" >開播數據</string>
<string name="click_to_view">點擊查看</string>
</resources>

View File

@ -1,6 +1,16 @@
package com.yunbao.live.dialog;
import static com.yunbao.common.Constants.*;
import static com.yunbao.common.Constants.LIVE_FUNC_BEAUTY;
import static com.yunbao.common.Constants.LIVE_FUNC_CAMERA;
import static com.yunbao.common.Constants.LIVE_FUNC_DR;
import static com.yunbao.common.Constants.LIVE_FUNC_LINK_MIC;
import static com.yunbao.common.Constants.LIVE_FUNC_MIC;
import static com.yunbao.common.Constants.LIVE_FUNC_RANDOM_PK;
import static com.yunbao.common.Constants.LIVE_FUNC_WISHLIST;
import static com.yunbao.common.Constants.LIVE_FUNC_WKS;
import static com.yunbao.common.Constants.LIVE_FUNC_ZG;
import static com.yunbao.common.Constants.LIVE_FUNC_ZSLK;
import static com.yunbao.common.Constants.LIVE_ROBOT;
import android.os.Bundle;
import android.view.Gravity;
@ -10,10 +20,11 @@ import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.Constants;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.LiveAnchorMessageCustomPopup;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.interfaces.LiveFunctionClickListener;
@ -92,6 +103,8 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
mMultiPkView.setOnClickListener(this);
mMicView.setOnClickListener(this);
mRandomPk.setOnClickListener(this);
findViewById(R.id.message_linear).setOnClickListener(this);
findViewById(R.id.live_tool_robot).setOnClickListener(this);
if (leave == 0) {
@ -149,6 +162,11 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
} else if (id == R.id.live_tool_robot) {
mFunctionClickListener.onClick(LIVE_ROBOT);
dismiss();
} else if (id == R.id.message_linear) {
new XPopup.Builder(getContext())
.asCustom(new LiveAnchorMessageCustomPopup(getContext()))
.show();
dismiss();
}
}
}