推送管理

This commit is contained in:
hch 2024-01-09 14:52:27 +08:00
parent dcf3f5c308
commit 661c2fd334
29 changed files with 608 additions and 118 deletions

View File

@ -67,6 +67,13 @@ public abstract class RefreshAdapter<T> extends RecyclerView.Adapter {
}
}
public void refreshDel(){
if (mRecyclerView != null) {
notifyDataSetChanged();
}
}
public void refreshData(List<T> list) {
if (mRecyclerView != null && list != null) {
mList.clear();

View File

@ -1,5 +1,7 @@
package com.yunbao.common.utils;
import com.yunbao.common.http.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -13,10 +15,13 @@ public class DateFormatUtil {
private static SimpleDateFormat sFormat2;
private static SimpleDateFormat sFormat3;
private static SimpleDateFormat sFormat4;
static {
sFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
sFormat2 = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS");
sFormat3 = new SimpleDateFormat("MM.dd-HH:mm:ss");
sFormat4 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
}
@ -24,6 +29,14 @@ public class DateFormatUtil {
return sFormat.format(new Date());
}
public static String getTimeString(long time) {
Date date = new Date(time); // 创建Date对象并传入时间戳参数
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 设置日期格式
String formattedDate = sdf.format(date); // 格式化日期字符串
return formattedDate;
}
public static String getVideoCurTimeString() {
return sFormat2.format(new Date());
}

View File

@ -1,5 +1,6 @@
package com.yunbao.common.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@ -46,7 +47,7 @@ public class RouteUtil {
public static final String PATH_RED_PACKET_LIST = "/main/RedPacketListActivity";
public static final String PATH_RED_PACKET_INFO = "/main/RedPacketInfoActivity";
public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity";
public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity";
public static final String PATH_SELECT_AVATAR = "/main/UserAvatarSelectActivity";
public static void forwardFansActivity(String uid) {
ARouter.getInstance().build(PATH_FANSACTIVITY)
@ -152,10 +153,15 @@ public class RouteUtil {
/**
* 跳转到
*/
public static void forwardLiveCompensateActivity(String url, boolean isFull) {
public static void forwardLiveCompensateActivity(Context context, String msgid, String banner, String title, String content, String time, String link, boolean receive) {
ARouter.getInstance().build(PATH_COMPENSATE_ACTIVITY)
.withString("url", url)
.withBoolean("isFull", isFull)
.withString("msgid", msgid)
.withString("banner", banner)
.withString("title", title)
.withString("content", content)
.withString("time", time)
.withString("link", link)
.withBoolean("receive", receive)
.navigation();
}
@ -195,7 +201,7 @@ public class RouteUtil {
* 跳转到充值页面
*/
public static void forwardMyCoin(Context context) {
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=zhifu&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=zhifu&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
ARouter.getInstance().build(PATH_COIN).withString("url", url).navigation();
}
@ -246,14 +252,14 @@ public class RouteUtil {
postcard.navigation();
}
public static void forwardGiftWallActivity(String mStream, String mAnchorName, String mLiveUid, String mAvatarUrl, int isAttention,boolean isLive) {
public static void forwardGiftWallActivity(String mStream, String mAnchorName, String mLiveUid, String mAvatarUrl, int isAttention, boolean isLive) {
ARouter.getInstance().build(PATH_GIFT_WALL)
.withString(Constants.LIVE_UID, mLiveUid)
.withString(Constants.STREAM, mStream)
.withString("mAnchorName", mAnchorName)
.withString("mAvatarUrl", mAvatarUrl)
.withInt("isAttention", isAttention)
.withBoolean("isLive",isLive)
.withBoolean("isLive", isLive)
.navigation();
}
@ -323,7 +329,7 @@ public class RouteUtil {
/**
* 系统头像选择
*/
public static void forwardUserAvatarSelect(){
public static void forwardUserAvatarSelect() {
ARouter.getInstance().build(PATH_SELECT_AVATAR)
.navigation();
}

View File

@ -33,10 +33,12 @@ public class SpUtil {
public static final String BEAUTY_SDK_TYPE = "beautySdkType";
public static final String TURNTABLE_ENABLE = "turntableEnable";
public static final String BEAUTY_360_TIEZHI_URL = "beauty360TiezhiUrl";
public static final String BEAUTY_360_TIEZHI_EXIST = "beauty360TiezhiExist";
public static final String ANCHOR_PK_TIME = "anchorPkTime";
public static final String BEAUTY_360_TIEZHI_EXIST = "beauty360TiezhiExist";
public static final String ANCHOR_PK_TIME = "anchorPkTime";
//播放短视频上下滑动引导页
public static final String READ_VIDEO_GUIDE = "readVideoGuide";
public static final String READ_VIDEO_GUIDE = "readVideoGuide";
public static final String MESSAGE_SYS_DEL = "FIRST_DEL";
public SpUtil() {
@ -73,8 +75,8 @@ public class SpUtil {
/**
* 判断一个值是否存在
*/
public boolean isExists(String key){
return mSharedPreferences.contains(key);
public boolean isExists(String key) {
return mSharedPreferences.contains(key);
}
/**

View File

@ -0,0 +1,42 @@
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.event.CustomDrawerPopupEvent;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class MsgSysDelPopupView extends AttachPopupView {
ItemDelListener itemDelListener;
public MsgSysDelPopupView(@NonNull Context context, ItemDelListener itemDelListener) {
super(context);
this.itemDelListener = itemDelListener;
}
@Override
protected int getImplLayoutId() {
return R.layout.view_msg_sys_del;
}
@Override
protected void onCreate() {
//特效设置
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.del), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dismiss();
itemDelListener.onItemDel();
}
});
}
public interface ItemDelListener {
void onItemDel();
}
}

View File

@ -0,0 +1,18 @@
<?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="50dp"
android:layout_height="25dp"
app:cardBackgroundColor="#0F0B14"
app:cardCornerRadius="4dp"
app:cardElevation="16dp">
<TextView
android:id="@+id/del"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/delete"
android:textColor="#FF9A9A9A"
android:textSize="12sp" />
</androidx.cardview.widget.CardView>

View File

@ -1400,4 +1400,14 @@ Limited ride And limited avatar frame</string>
<string name="msg_del_sys01">The items inside have not been claimed yet.Are you sure to delete the message</string>
<string name="msg_del_sys02">Are you sure to delete the message</string>
<string name="receive_success">Successfully claimed</string>
<string name="receive1">Receive</string>
<string name="receive2">Received</string>
<string name="del_suc">Delete successful</string>
<string name="sys_msg_year">-</string>
<string name="sys_msg_month">-</string>
<string name="sys_msg_day"></string>
</resources>

View File

@ -1398,4 +1398,15 @@
<string name="pay_cancel">支付取消</string>
<string name="pay_suc">支付成功</string>
<string name="pay_fail">支付失敗</string>
<string name="receive_success">領取成功</string>
<string name="receive1">領取</string>
<string name="receive2">已領取</string>
<string name="del_suc">刪除成功</string>
<string name="sys_msg_year"></string>
<string name="sys_msg_month"></string>
<string name="sys_msg_day"></string>
</resources>

View File

@ -1397,4 +1397,15 @@
<string name="pay_cancel">支付取消</string>
<string name="pay_suc">支付成功</string>
<string name="pay_fail">支付失敗</string>
<string name="receive_success">領取成功</string>
<string name="receive1">領取</string>
<string name="receive2">已領取</string>
<string name="del_suc">刪除成功</string>
<string name="sys_msg_year"></string>
<string name="sys_msg_month"></string>
<string name="sys_msg_day"></string>
</resources>

View File

@ -1396,4 +1396,14 @@
<string name="msg_del_sys01">內含物品還未領取,是否確定刪除消息?</string>
<string name="msg_del_sys02">是否確定刪除消息?</string>
<string name="receive_success">領取成功</string>
<string name="receive1">领取</string>
<string name="receive2">已領取</string>
<string name="del_suc">刪除成功</string>
<string name="sys_msg_year"></string>
<string name="sys_msg_month"></string>
<string name="sys_msg_day"></string>
</resources>

View File

@ -82,4 +82,6 @@
<color name="gray_f6f7fb">#F6F7FB</color>
<color name="gray_f6f6f6f6">#FFF6F6F6</color>
<color name="gray_F4F4F4">#F4F4F4</color>
</resources>

View File

@ -1404,4 +1404,15 @@ Limited ride And limited avatar frame</string>
<string name="pay_cancel">Payment cancellation</string>
<string name="pay_suc">Payment successful</string>
<string name="pay_fail">Payment failed</string>
<string name="receive_success">Successfully claimed</string>
<string name="receive1">Receive</string>
<string name="receive2">Received</string>
<string name="del_suc">Delete successful</string>
<string name="sys_msg_year">-</string>
<string name="sys_msg_month">-</string>
<string name="sys_msg_day"></string>
</resources>

View File

@ -1,8 +1,11 @@
package com.yunbao.live.activity;
import android.content.Intent;
import android.graphics.Outline;
import android.text.format.DateUtils;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.Button;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -10,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.blankj.utilcode.util.StringUtils;
import com.ms.banner.Banner;
import com.ms.banner.BannerConfig;
import com.ms.banner.listener.OnBannerClickListener;
@ -18,21 +21,29 @@ import com.umeng.analytics.MobclickAgent;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.LiveGiftBean;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.adapter.MsgSysGiftAdapter;
import com.yunbao.live.bean.MsgSysGiftInfoBean;
import com.yunbao.live.bean.SlideBean;
import com.yunbao.live.bean.SystemMessageBean;
import com.yunbao.live.custom.TopGradual;
import com.yunbao.live.http.ImHttpUtil;
import com.yunbao.live.views.CustomMyViewHolder;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -42,19 +53,28 @@ public class CompensateActivity extends AbsActivity {
Banner banner_me;
TextView content;
TextView time;
RecyclerView recyclerView;
MsgSysGiftAdapter msgSysGiftAdapter;
int msgId;
String msgId, mBanner, mContent, link;
Button submit;
@Override
protected int getLayoutId() {
return R.layout.activity_compensate;
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void refreshStatus(SystemMessageBean systemMessageBean) {
}
@Override
protected void main() {
setTitle(getIntent().getStringExtra("title"));
EventBus.getDefault().register(this);
content = findViewById(R.id.content);
submit = findViewById(R.id.submit);
time = findViewById(R.id.time);
recyclerView = findViewById(R.id.hor_recycler);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
@ -64,34 +84,68 @@ public class CompensateActivity extends AbsActivity {
recyclerView.setAdapter(msgSysGiftAdapter);
msgId = getIntent().getIntExtra("msgid", -1);
msgId = getIntent().getStringExtra("msgid");
mBanner = getIntent().getStringExtra("banner");
mContent = getIntent().getStringExtra("content");
link = getIntent().getStringExtra("link");
banner_me = (Banner) findViewById(R.id.banner_me);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy" + getString(R.string.sys_msg_year) + "MM" + getString(R.string.sys_msg_month) + "dd" + getString(R.string.sys_msg_day) + " HH:mm");
Date currenTimeZone = new Date(Long.parseLong(getIntent().getStringExtra("time") + "000"));
time.setText(sdf.format(currenTimeZone));
content.setText(mContent);
banner_me = findViewById(R.id.banner_me);
banner_me.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10);
}
});
if (!getIntent().getBooleanExtra("receive", false)) {
submit.setBackground(mContext.getDrawable(R.mipmap.icon_sys_received));
submit.setText(getString(R.string.receive2));
submit.setTextColor(mContext.getResources().getColor(R.color.gray_F4F4F4));
}
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ImHttpUtil.receiveGift(msgId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
SystemMessageBean systemMessageBean = new SystemMessageBean();
systemMessageBean.setId(msgId);
EventBus.getDefault().post(systemMessageBean);
submit.setBackground(mContext.getDrawable(R.mipmap.icon_sys_received));
submit.setText(getString(R.string.receive2));
submit.setTextColor(mContext.getResources().getColor(R.color.gray_F4F4F4));
ToastUtil.show(msg);
} else {
ToastUtil.show(msg);
}
}
});
}
});
getMessageGiftInfo();
if (!StringUtils.isEmpty(mBanner)) {
List<SlideBean> mBannerList = new ArrayList<>();
SlideBean slideBean = new SlideBean();
slideBean.setSlide_pic(mBanner);
slideBean.setSlide_url(link);
mBannerList.add(slideBean);
showBanner(mBannerList);
findViewById(R.id.lt_advertisement).setVisibility(View.VISIBLE);
}
}
private void getMessageGiftInfo() {
ImHttpUtil.getMessageGiftInfo(msgId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
List<MsgSysGiftInfoBean> list = new ArrayList<>();
if (info != null) {
list = JSON.parseArray(info[0], MsgSysGiftInfoBean.class);
}
List<MsgSysGiftInfoBean> list = JSON.parseArray(Arrays.toString(info), MsgSysGiftInfoBean.class);
msgSysGiftAdapter.setList(list);
List<SlideBean> mBannerList = new ArrayList<>();
SlideBean slideBean = new SlideBean();
slideBean.setSlide_pic("https://downs.yaoulive.com/20231111/55ddbc06ffdd02e480f3513fdb31caf6.png");
mBannerList.add(slideBean);
mBannerList.add(slideBean);
showBanner(mBannerList);
}
});
}
@ -104,13 +158,12 @@ public class CompensateActivity extends AbsActivity {
if (p >= 0 && p < mBannerList.size()) {
SlideBean bean = mBannerList.get(p);
if (!bean.getSlide_url().equals("")) {
Constants.isTitle = true;
String url = bean.getSlide_url() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0");
RouteUtil.forwardCustomerService(url);
Map<String, String> map_ekv = new HashMap<String, String>();
map_ekv.put("link", url);
MobclickAgent.onEvent(mContext, "my_banner", map_ekv);
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
StringBuffer urlBuffer = new StringBuffer();
urlBuffer.append(bean.getSlide_url()).append("&uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&isZh=").append(WordUtil.isNewZh() ? "1" : 0);
mContext.startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", urlBuffer.toString()));
}
}
}

View File

@ -10,9 +10,15 @@ import com.yunbao.common.Constants;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.activity.SelectImageActivity;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.live.R;
import com.yunbao.live.bean.SystemMessageBean;
import com.yunbao.live.views.SystemMessageViewHolder;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.Date;
@ -32,11 +38,7 @@ public class SystemMessageActivity extends AbsActivity {
public static String nowUid, nowTitle, mowHeadImg;
public static void forward(Context context, String type, String uid, String title, String headImg) {
context.startActivity(new Intent(context, SystemMessageActivity.class)
.putExtra("type", type)
.putExtra("uid", uid)
.putExtra("title", title)
.putExtra("headImg", headImg));
context.startActivity(new Intent(context, SystemMessageActivity.class).putExtra("type", type).putExtra("uid", uid).putExtra("title", title).putExtra("headImg", headImg));
}
@Override

View File

@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.live.R;
import com.yunbao.live.bean.MsgSysGiftInfoBean;
@ -28,7 +29,6 @@ public class MsgSysGiftAdapter extends RecyclerView.Adapter {
mList = new ArrayList<>();
mList.add(new MsgSysGiftInfoBean());
mInflater = LayoutInflater.from(context);
}
public void setList(List<MsgSysGiftInfoBean> list) {
@ -84,7 +84,7 @@ public class MsgSysGiftAdapter extends RecyclerView.Adapter {
itemView.setTag(position);
ImgLoader.display(mContext, bean.getItem_image(), mAvatar);
mName.setText(bean.getItem_name());
name_remarks.setText(bean.getRestrict_time());
name_remarks.setText(String.valueOf(bean.getStr_value()));
}
}

View File

@ -2,9 +2,12 @@ package com.yunbao.live.adapter;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -14,10 +17,12 @@ import android.widget.TextView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.bean.SystemMessageBean;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.http.ImHttpUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -52,7 +57,9 @@ public class SystemMessageAdapter extends RefreshAdapter<SystemMessageBean> {
TextView mTime, text;
LinearLayout toView, bg;
ImageView img_content;
CardView cv_img_content;
CardView cv_img_content, radius;
public Vh(View itemView) {
super(itemView);
mContent = itemView.findViewById(R.id.content);
@ -62,6 +69,7 @@ public class SystemMessageAdapter extends RefreshAdapter<SystemMessageBean> {
text = itemView.findViewById(R.id.text);
img_content = itemView.findViewById(R.id.img_content);
cv_img_content = itemView.findViewById(R.id.cv_img_content);
radius = itemView.findViewById(R.id.radius);
}
void setData(SystemMessageBean bean) {
@ -69,10 +77,22 @@ public class SystemMessageAdapter extends RefreshAdapter<SystemMessageBean> {
@Override
public void onClick(View v) {
if (bean.getLink() != null && !bean.getLink().equals("")) {
startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", bean.getLink()+ "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0")));
startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", bean.getLink() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0")));
if (bean.getRead_status() == 2) {
ImHttpUtil.readMsg(bean.getId(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
}
});
radius.setVisibility(View.GONE);
}
}
}
});
radius.setVisibility((bean.getRead_status() == 2 && !TextUtils.isEmpty(bean.getLink())) ? View.VISIBLE : View.GONE);
mContent.setText(bean.getContent());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
@ -91,5 +111,4 @@ public class SystemMessageAdapter extends RefreshAdapter<SystemMessageBean> {
}
}
}
}

View File

@ -1,24 +1,32 @@
package com.yunbao.live.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.blankj.utilcode.util.StringUtils;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.bean.SystemMessageBean;
import com.yunbao.live.http.ImHttpUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -44,12 +52,15 @@ public class SystemMessageNewAdapter extends RefreshAdapter<SystemMessageBean> {
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
((Vh) vh).setData(mList.get(position));
((Vh) vh).setData(mList.get(position), position);
}
class Vh extends RecyclerView.ViewHolder {
TextView messageContext, messageTime;
TextView messageContext, messageTime, title, del;
CardView radius, bannerImgLayout;
LinearLayout layoutMore, itemLayout;
ImageView img_content;
ImageView icon;
public Vh(View itemView) {
super(itemView);
@ -57,45 +68,89 @@ public class SystemMessageNewAdapter extends RefreshAdapter<SystemMessageBean> {
layoutMore = itemView.findViewById(R.id.layout_more);
itemLayout = itemView.findViewById(R.id.itemLayout);
messageTime = itemView.findViewById(R.id.message_time);
radius = itemView.findViewById(R.id.radius);
icon = itemView.findViewById(R.id.icon);
img_content = itemView.findViewById(R.id.img_content);
bannerImgLayout = itemView.findViewById(R.id.cv_img_content);
title = itemLayout.findViewById(R.id.title);
del = itemLayout.findViewById(R.id.del);
}
void setData(SystemMessageBean bean) {
void setData(SystemMessageBean bean, int position) {
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
messageTime.setText(sdf.format(currenTimeZone));
messageContext.setText(bean.getContent());
if (bean.getSystem_message_type() == 1) {
title.setText(String.valueOf(bean.getTitle()));
if (bean.getSystem_message_type() == 2) {
//带礼物的消息
if (bean.getGet_status() == 2) {
icon.setImageDrawable(mContext.getDrawable(R.mipmap.icon_msg_sys_gift));
} else {
icon.setImageDrawable(mContext.getDrawable(R.mipmap.icon_msg_sys_gifted));
}
messageContext.setVisibility(View.GONE);
radius.setVisibility((bean.getRead_status() == 2) ? View.VISIBLE : View.GONE);
layoutMore.setVisibility(View.VISIBLE);
} else {
layoutMore.setVisibility(TextUtils.isEmpty(bean.getLink()) ? View.GONE : View.VISIBLE);
}
itemLayout.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
itemLongListener.onItemLong(bean);
return false;
//普通消息
icon.setImageDrawable(mContext.getDrawable(R.mipmap.icon_notification_speaker));
if (StringUtils.isEmpty(bean.getLink())) {
//无跳转
messageContext.setVisibility(View.VISIBLE);
layoutMore.setVisibility(View.GONE);
} else {
messageContext.setVisibility(View.GONE);
}
});
layoutMore.setOnClickListener(new View.OnClickListener() {
layoutMore.setVisibility(TextUtils.isEmpty(bean.getLink()) ? View.GONE : View.VISIBLE);
radius.setVisibility((bean.getRead_status() == 2 && !TextUtils.isEmpty(bean.getLink())) ? View.VISIBLE : View.GONE);
}
if (!StringUtils.isEmpty(bean.getImgBanner())) {
ImgLoader.display(mContext, bean.getImgBanner(), img_content);
img_content.setVisibility(View.VISIBLE);
bannerImgLayout.setVisibility(View.VISIBLE);
} else {
img_content.setVisibility(View.GONE);
bannerImgLayout.setVisibility(View.GONE);
}
itemLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bean.getSystem_message_type() == 2) {//普通消息
//普通消息
if (bean.getSystem_message_type() == 1) {
if (bean.getLink() != null && !bean.getLink().equals("")) {
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
StringBuffer urlBuffer = new StringBuffer();
urlBuffer.append(bean.getLink()).append("&uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&isZh=").append(WordUtil.isNewZh() ? "1" : 0);
mContext.startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", urlBuffer.toString()));
}
} else if (bean.getSystem_message_type() == 1) {//礼包消息
RouteUtil.forwardLiveCompensateActivity("", false);
} else {
RouteUtil.forwardLiveCompensateActivity(mContext, String.valueOf(bean.getId()), bean.getImgBanner(), bean.getTitle(), bean.getContent(), bean.getAddtime(), bean.getLink(), bean.getGet_status() == 2);
}
//未读才调用
if (bean.getRead_status() == 2) {
ImHttpUtil.readMsg(bean.getId(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
}
});
radius.setVisibility(View.GONE);
}
}
});
itemLayout.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
itemLongListener.onItemLong(bean, position, del);
return true;
}
});
}
}
public interface ItemLongListener {
void onItemLong(SystemMessageBean bean);
void onItemLong(SystemMessageBean bean, int position, View view);
}
}

View File

@ -5,6 +5,15 @@ public class MsgSysGiftInfoBean {
String item_name;
String restrict_time;
String item_image;
String str_value;
public String getStr_value() {
return str_value;
}
public void setStr_value(String str_value) {
this.str_value = str_value;
}
public int getId() {
return id;

View File

@ -23,6 +23,15 @@ public class SystemMessageBean {
private int get_status; // 1 已领取 2 未领取
private int read_status; // 1 已读 2 未读
public int getRead_status() {
return read_status;
}
public void setRead_status(int read_status) {
this.read_status = read_status;
}
public int getSystem_message_type() {
return system_message_type;

View File

@ -78,9 +78,36 @@ public class ImHttpUtil {
/**
* 获取补偿消息详情
*/
public static void getMessageGiftInfo(int msgid, HttpCallback callback) {
public static void getMessageGiftInfo(String msgid, HttpCallback callback) {
HttpClient.getInstance().get("Message.getMessageGiftInfo", ImHttpConsts.GET_MESSAGEGIFTINFO)
.params("message_id", msgid)
.execute(callback);
}
/**
* 删除系统消息
*/
public static void delMsg(String msgid, HttpCallback callback) {
HttpClient.getInstance().get("Message.deleteSystemMessage", ImHttpConsts.GET_MESSAGEGIFTINFO)
.params("message_id", msgid)
.execute(callback);
}
/**
* 已读 系统消息
*/
public static void readMsg(String msgid, HttpCallback callback) {
HttpClient.getInstance().get("Message.systemMessageRead", ImHttpConsts.GET_MESSAGEGIFTINFO)
.params("message_id", msgid)
.execute(callback);
}
/**
* 领取礼物
*/
public static void receiveGift(String msgid, HttpCallback callback) {
HttpClient.getInstance().get("Message.getMessageGiftDetails", ImHttpConsts.GET_MESSAGEGIFTINFO)
.params("message_id", msgid)
.execute(callback);
}
}

View File

@ -44,6 +44,8 @@ import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition;
import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
@ -55,11 +57,15 @@ import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.interfaces.OnItemLongClickListener;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.common.views.MsgSysDelPopupView;
import com.yunbao.common.views.PlaySettingPopupView;
import com.yunbao.live.R;
import com.yunbao.live.activity.EditNameRemarksActivity;
import com.yunbao.live.activity.SystemMessageActivity;
@ -246,6 +252,11 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
EventBus.getDefault().register(SystemMessageViewHolder.this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void refreshStatus(SystemMessageBean systemMessageBean) {
mRefreshView.initData();
}
//点击加号等各类事件
@Override
public void onClick(View v) {
@ -343,6 +354,33 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
}
/**
* 删除消息
*
* @param msgId
* @param position
* @param size
*/
public void delMsg(String msgId, int position, int size) {
ImHttpUtil.delMsg(msgId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
ToastUtil.show(R.string.del_suc);
}
List<SystemMessageBean> systemMessageBeanList = mAdapter.getList();
systemMessageBeanList.remove(position);
if (position == 0 && size == 1) {
mRefreshView.initData();
} else if (position == 0) {
mAdapter.notifyDataSetChanged();
} else {
mAdapter.notifyItemRemoved(position);
}
}
});
}
//非单聊列表适配
private void setSysApt() {
if (SystemMessageActivity.type.equals("1") || SystemMessageActivity.type.equals("4")) {
@ -364,13 +402,33 @@ public class SystemMessageViewHolder extends AbsViewHolder implements View.OnCli
} else if (mAdapter == null && SystemMessageActivity.type.equals("4")) {//系统消息
mAdapter = new SystemMessageNewAdapter(mContext, new SystemMessageNewAdapter.ItemLongListener() {
@Override
public void onItemLong(SystemMessageBean bean) {
DialogUitl.showDelSysMsg(mContext, mContext.getString(com.yunbao.common.R.string.msg_del_sys01), new DialogUitl.SimpleCallback() {
public void onItemLong(SystemMessageBean bean, int position, View view) {
XPopup.Builder builder = new XPopup.Builder(mContext).atView(view);
builder.hasShadowBg(false).isDestroyOnDismiss(true).isLightStatusBar(false).popupPosition(PopupPosition.Top).asCustom(new MsgSysDelPopupView(mContext, new MsgSysDelPopupView.ItemDelListener() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
public void onItemDel() {
if (bean.getSystem_message_type() == 2 && bean.getGet_status() == 2) {//礼包消息并且未领取
DialogUitl.showDelSysMsg(mContext, mContext.getString(com.yunbao.common.R.string.msg_del_sys01), new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
delMsg(bean.getId(), position, mAdapter.getList().size());
}
});
} else {
if (!SpUtil.getInstance().getBooleanValue(SpUtil.MESSAGE_SYS_DEL)) {
DialogUitl.showDelSysMsg(mContext, mContext.getString(com.yunbao.common.R.string.msg_del_sys02), new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
delMsg(bean.getId(), position, mAdapter.getList().size());
}
});
} else {
delMsg(bean.getId(), position, mAdapter.getList().size());
}
SpUtil.getInstance().setBooleanValue(SpUtil.MESSAGE_SYS_DEL, true);
}
}
});
})).show();
}
});
}

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="133dp" />
<solid android:color="#9FAAB7" />
</shape>

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="5dp"/>
<solid android:color="#E7E7E7"/>
</shape>

View File

@ -51,18 +51,31 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:layout_marginRight="50dp"
android:background="@drawable/bg_gray_time"
android:gravity="center_horizontal"
android:text="2024年1月4号 10:05" />
<LinearLayout
android:id="@+id/lt_advertisement"
android:layout_width="match_parent"
android:layout_height="102dp"
android:layout_height="115dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="12dp"
android:visibility="gone"
android:layout_marginTop="15dp"
android:layout_marginRight="15dp">
<androidx.cardview.widget.CardView
android:id="@+id/cv_chatcontent_img1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/transparent"
app:cardCornerRadius="10dp"
app:cardElevation="0dp">
@ -78,28 +91,28 @@
</LinearLayout>
<TextView
android:id="@+id/msg"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp" />
android:layout_margin="20dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/hor_recycler"
android:layout_width="wrap_content"
android:layout_height="120dp"
android:layout_gravity="center"
android:scrollbars="none" />
<Button
android:id="@+id/submit"
android:layout_width="170dp"
android:layout_height="50dp"
android:layout_height="45dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:background="@mipmap/icon_sys_receive"
android:paddingBottom="3dp"
android:text="領取"
android:text="@string/receive1"
android:textColor="@color/yellow_ff6c00"
android:textSize="18dp"
android:textStyle="bold" />

View File

@ -1,15 +1,15 @@
<?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="130dp"
android:layout_width="100dp"
android:layout_height="135dp"
android:gravity="center"
android:orientation="vertical">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/avatar"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_width="55dp"
android:layout_height="55dp"
android:scaleType="centerCrop"
app:riv_oval="true" />

View File

@ -91,6 +91,18 @@
android:src="@mipmap/icon_more_live_menu" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:id="@+id/radius"
android:layout_width="7dp"
android:layout_height="7dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
app:cardBackgroundColor="#FF0000"
android:visibility="gone"
app:cardCornerRadius="20dp" />
</RelativeLayout>

View File

@ -1,6 +1,7 @@
<?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:id="@+id/bodyLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -23,6 +24,7 @@
android:orientation="horizontal">
<!--通知小喇叭-->
<ImageView
android:id="@+id/icon"
android:layout_width="37dp"
android:layout_height="37dp"
android:layout_marginStart="11dp"
@ -33,60 +35,138 @@
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="42dp"
android:clickable="false"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="12dp"
app:cardElevation="0dp">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/message_context"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="11dp"
android:text="親愛的用戶昵稱恭喜你獲得23年7月1日-23年7月31日的xx禮物冠名權冠名生效期間您可使用專屬禮物冠名皮膚。小PD已給您佩戴了專屬送禮特效也可在個性裝扮中取消佩戴。"
android:textColor="#040404"
android:textSize="15sp" />
<LinearLayout
android:id="@+id/layout_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="visible">
<View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1.2dp"
android:layout_marginStart="11dp"
android:layout_marginEnd="11dp"
android:background="#F6F6F6" />
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="11dp"
android:layout_marginTop="11dp"
android:layout_marginEnd="11dp"
android:layout_marginBottom="11dp"
android:layout_weight="1"
android:maxLines="2"
android:text="標題"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/del"
android:layout_width="60dp"
android:layout_height="25dp"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_gray_del"
android:gravity="center"
android:text="@string/delete"
android:textColor="@color/white"
android:visibility="invisible" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:id="@+id/cv_img_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="6dp"
android:visibility="gone"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<ImageView
android:id="@+id/img_content"
android:layout_width="match_parent"
android:layout_height="87dp"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:id="@+id/message_context"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="11dp"
android:text="@string/live_user_mailbox_more_text"
android:textColor="#838383"
android:textSize="14sp" />
<ImageView
android:layout_width="13dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginStart="11dp"
android:layout_marginEnd="11dp"
android:src="@mipmap/icon_arrow_right" />
</FrameLayout>
android:layout_marginBottom="11dp"
android:text="親愛的用戶昵稱恭喜你獲得23年7月1日-23年7月31日的xx禮物冠名權冠名生效期間您可使用專屬禮物冠名皮膚。小PD已給您佩戴了專屬送禮特效也可在個性裝扮中取消佩戴。"
android:textColor="#040404"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1.2dp"
android:layout_marginStart="11dp"
android:layout_marginEnd="11dp"
android:background="#F6F6F6" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="11dp"
android:text="@string/live_user_mailbox_more_text"
android:textColor="#838383"
android:textSize="14sp" />
<ImageView
android:layout_width="13dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginEnd="11dp"
android:src="@mipmap/icon_arrow_right" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<androidx.cardview.widget.CardView
android:id="@+id/radius"
android:layout_width="7dp"
android:layout_height="7dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:visibility="gone"
app:cardBackgroundColor="#FF0000"
app:cardCornerRadius="20dp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB