From 661c2fd334c5f5bc78a50f36aef087abe6f4b579 Mon Sep 17 00:00:00 2001 From: hch <16607480311@163.com> Date: Tue, 9 Jan 2024 14:52:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/adapter/RefreshAdapter.java | 7 + .../yunbao/common/utils/DateFormatUtil.java | 13 ++ .../com/yunbao/common/utils/RouteUtil.java | 22 ++- .../java/com/yunbao/common/utils/SpUtil.java | 12 +- .../common/views/MsgSysDelPopupView.java | 42 +++++ .../src/main/res/layout/view_msg_sys_del.xml | 18 +++ common/src/main/res/values-en-rUS/string.xml | 10 ++ common/src/main/res/values-zh-rHK/strings.xml | 11 ++ common/src/main/res/values-zh-rTW/strings.xml | 11 ++ common/src/main/res/values-zh/strings.xml | 10 ++ common/src/main/res/values/colors.xml | 2 + common/src/main/res/values/strings.xml | 11 ++ .../live/activity/CompensateActivity.java | 105 +++++++++---- .../live/activity/SystemMessageActivity.java | 12 +- .../live/adapter/MsgSysGiftAdapter.java | 4 +- .../live/adapter/SystemMessageAdapter.java | 25 ++- .../live/adapter/SystemMessageNewAdapter.java | 91 ++++++++--- .../yunbao/live/bean/MsgSysGiftInfoBean.java | 9 ++ .../yunbao/live/bean/SystemMessageBean.java | 9 ++ .../java/com/yunbao/live/http/ImHttpUtil.java | 29 +++- .../live/views/SystemMessageViewHolder.java | 68 +++++++- live/src/main/res/drawable/bg_gray_del.xml | 5 + live/src/main/res/drawable/bg_gray_time.xml | 5 + .../main/res/layout/activity_compensate.xml | 29 +++- .../src/main/res/layout/item_msg_sys_gift.xml | 8 +- live/src/main/res/layout/item_sys_msg.xml | 12 ++ live/src/main/res/layout/item_sys_msg_new.xml | 146 ++++++++++++++---- .../res/mipmap-mdpi/icon_msg_sys_gift.png | Bin 0 -> 11631 bytes .../res/mipmap-mdpi/icon_msg_sys_gifted.png | Bin 0 -> 13681 bytes 29 files changed, 608 insertions(+), 118 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/views/MsgSysDelPopupView.java create mode 100644 common/src/main/res/layout/view_msg_sys_del.xml create mode 100644 live/src/main/res/drawable/bg_gray_del.xml create mode 100644 live/src/main/res/drawable/bg_gray_time.xml create mode 100644 live/src/main/res/mipmap-mdpi/icon_msg_sys_gift.png create mode 100644 live/src/main/res/mipmap-mdpi/icon_msg_sys_gifted.png diff --git a/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java b/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java index 5e28ba8f6..a0d174681 100644 --- a/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java @@ -67,6 +67,13 @@ public abstract class RefreshAdapter extends RecyclerView.Adapter { } } + public void refreshDel(){ + if (mRecyclerView != null) { + notifyDataSetChanged(); + } + } + + public void refreshData(List list) { if (mRecyclerView != null && list != null) { mList.clear(); diff --git a/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java b/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java index 006366acf..853e0e0ef 100644 --- a/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java @@ -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()); } diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 127c31122..ea92f5cc5 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -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(); } diff --git a/common/src/main/java/com/yunbao/common/utils/SpUtil.java b/common/src/main/java/com/yunbao/common/utils/SpUtil.java index 40604a237..11184c438 100644 --- a/common/src/main/java/com/yunbao/common/utils/SpUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/SpUtil.java @@ -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); } /** diff --git a/common/src/main/java/com/yunbao/common/views/MsgSysDelPopupView.java b/common/src/main/java/com/yunbao/common/views/MsgSysDelPopupView.java new file mode 100644 index 000000000..bb4a9de5d --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MsgSysDelPopupView.java @@ -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(); + } +} diff --git a/common/src/main/res/layout/view_msg_sys_del.xml b/common/src/main/res/layout/view_msg_sys_del.xml new file mode 100644 index 000000000..557943950 --- /dev/null +++ b/common/src/main/res/layout/view_msg_sys_del.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index dc02898f8..dcc5642d8 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -1400,4 +1400,14 @@ Limited ride And limited avatar frame The items inside have not been claimed yet.Are you sure to delete the message? Are you sure to delete the message? + + Successfully claimed + Receive + Received + + Delete successful + + - + - + diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index 81b093cf6..9ed1062bb 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1398,4 +1398,15 @@ 支付取消 支付成功 支付失敗 + + 領取成功 + 領取 + 已領取 + + 刪除成功 + + + + + diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index 7519e5317..9c1643cfc 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1397,4 +1397,15 @@ 支付取消 支付成功 支付失敗 + + 領取成功 + 領取 + 已領取 + + 刪除成功 + + + + + diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 946f0142c..1b76cd239 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1396,4 +1396,14 @@ 內含物品還未領取,是否確定刪除消息? 是否確定刪除消息? + 領取成功 + 领取 + 已領取 + + 刪除成功 + + + + + diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml index 6e444f1f3..d7a566eca 100644 --- a/common/src/main/res/values/colors.xml +++ b/common/src/main/res/values/colors.xml @@ -82,4 +82,6 @@ #F6F7FB #FFF6F6F6 + + #F4F4F4 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index b90049f19..2ff6c73e2 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1404,4 +1404,15 @@ Limited ride And limited avatar frame Payment cancellation Payment successful Payment failed + + Successfully claimed + Receive + Received + + Delete successful + + - + - + + diff --git a/live/src/main/java/com/yunbao/live/activity/CompensateActivity.java b/live/src/main/java/com/yunbao/live/activity/CompensateActivity.java index ea6078fc2..ed697700d 100644 --- a/live/src/main/java/com/yunbao/live/activity/CompensateActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/CompensateActivity.java @@ -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 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 list = new ArrayList<>(); - if (info != null) { - list = JSON.parseArray(info[0], MsgSysGiftInfoBean.class); - } + List list = JSON.parseArray(Arrays.toString(info), MsgSysGiftInfoBean.class); msgSysGiftAdapter.setList(list); - - List 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 map_ekv = new HashMap(); - 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())); + } } } diff --git a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java index 461ae839d..4ba054ea5 100644 --- a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java @@ -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 diff --git a/live/src/main/java/com/yunbao/live/adapter/MsgSysGiftAdapter.java b/live/src/main/java/com/yunbao/live/adapter/MsgSysGiftAdapter.java index 474e36881..fb6799557 100644 --- a/live/src/main/java/com/yunbao/live/adapter/MsgSysGiftAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/MsgSysGiftAdapter.java @@ -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 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())); } } diff --git a/live/src/main/java/com/yunbao/live/adapter/SystemMessageAdapter.java b/live/src/main/java/com/yunbao/live/adapter/SystemMessageAdapter.java index 80df52146..a86dad413 100644 --- a/live/src/main/java/com/yunbao/live/adapter/SystemMessageAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/SystemMessageAdapter.java @@ -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 { 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 { 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 { @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 { } } } - } diff --git a/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java b/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java index a7015f824..7d6d76ebf 100644 --- a/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/SystemMessageNewAdapter.java @@ -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 { @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 { 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); } - } diff --git a/live/src/main/java/com/yunbao/live/bean/MsgSysGiftInfoBean.java b/live/src/main/java/com/yunbao/live/bean/MsgSysGiftInfoBean.java index 72a74f1db..bb3ae621e 100644 --- a/live/src/main/java/com/yunbao/live/bean/MsgSysGiftInfoBean.java +++ b/live/src/main/java/com/yunbao/live/bean/MsgSysGiftInfoBean.java @@ -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; diff --git a/live/src/main/java/com/yunbao/live/bean/SystemMessageBean.java b/live/src/main/java/com/yunbao/live/bean/SystemMessageBean.java index ee113ea60..fc9ea313d 100644 --- a/live/src/main/java/com/yunbao/live/bean/SystemMessageBean.java +++ b/live/src/main/java/com/yunbao/live/bean/SystemMessageBean.java @@ -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; diff --git a/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java b/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java index 5a8403ad7..ab3dfc4ab 100644 --- a/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java +++ b/live/src/main/java/com/yunbao/live/http/ImHttpUtil.java @@ -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); + } } diff --git a/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java b/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java index 84317cf4d..2b2ac9158 100644 --- a/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/SystemMessageViewHolder.java @@ -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 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(); } }); } diff --git a/live/src/main/res/drawable/bg_gray_del.xml b/live/src/main/res/drawable/bg_gray_del.xml new file mode 100644 index 000000000..353a426a9 --- /dev/null +++ b/live/src/main/res/drawable/bg_gray_del.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_gray_time.xml b/live/src/main/res/drawable/bg_gray_time.xml new file mode 100644 index 000000000..768e63d5e --- /dev/null +++ b/live/src/main/res/drawable/bg_gray_time.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/activity_compensate.xml b/live/src/main/res/layout/activity_compensate.xml index be2769dfa..a4dafaf6e 100644 --- a/live/src/main/res/layout/activity_compensate.xml +++ b/live/src/main/res/layout/activity_compensate.xml @@ -51,18 +51,31 @@ android:layout_height="match_parent" android:orientation="vertical"> + + @@ -78,28 +91,28 @@ + android:layout_margin="20dp" />