From ab6d871b38a5825a99f0519771e73690456b2847 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 21 Mar 2024 14:48:10 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=8A=A8=E6=80=81&=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/share/bean/ShareBean.java | 62 ++++++++++++------- .../com/yunbao/share/platform/Internal.java | 3 +- .../com/yunbao/share/ui/SharePopDialog.java | 1 + .../provider/MessageChatCardItemProvider.java | 19 ++++++ .../com/yunbao/common/utils/RouteUtil.java | 10 +++ .../res/layout/activity_community_details.xml | 1 + .../live/activity/LiveAudienceActivity.java | 1 + .../activity/CommunityDetailsActivity.java | 27 ++++++++ .../activity/PDLiveConversationActivity.java | 4 ++ .../PDLiveCustomConversationProvider.java | 4 ++ video/build.gradle | 7 ++- .../video/activity/VideoPlayActivity.java | 8 +++ .../video/views/VideoPlayWrapViewHolder.java | 30 ++++++++- 13 files changed, 150 insertions(+), 27 deletions(-) diff --git a/Share/src/main/java/com/yunbao/share/bean/ShareBean.java b/Share/src/main/java/com/yunbao/share/bean/ShareBean.java index d6a65da..4b2fe8e 100644 --- a/Share/src/main/java/com/yunbao/share/bean/ShareBean.java +++ b/Share/src/main/java/com/yunbao/share/bean/ShareBean.java @@ -29,6 +29,7 @@ public class ShareBean { private int shareType; private String cover; private String title; + private String extraData; public static String createLiveShareLink(String shareUid, String anchorId, String anchorName, String anchorAvatar) { @@ -119,6 +120,14 @@ public class ShareBean { this.anchorAvatar = anchorAvatar; } + public String getExtraData() { + return extraData; + } + + public void setExtraData(String extraData) { + this.extraData = extraData; + } + public ShareBean setText(String text) { this.text = text; return this; @@ -163,32 +172,33 @@ public class ShareBean { } /** - * private String text; - * private String link; - * private File file; - * private int type; - * private String uid; - * private String anchorId; - * private String anchorName; - * private String anchorAvatar; - * private int shareType; - * private String cover; - * private String title; + * private String text; + * private String link; + * private File file; + * private int type; + * private String uid; + * private String anchorId; + * private String anchorName; + * private String anchorAvatar; + * private int shareType; + * private String cover; + * private String title; */ @NonNull @Override - public ShareBean clone(){ - ShareBean bean=new ShareBean(type); - bean.anchorId=anchorId; - bean.anchorName=anchorName; - bean.anchorAvatar=anchorAvatar; - bean.text=text; - bean.link=link; - bean.file=file; - bean.uid=uid; - bean.shareType=shareType; - bean.cover=cover; - bean.title=title; + public ShareBean clone() { + ShareBean bean = new ShareBean(type); + bean.anchorId = anchorId; + bean.anchorName = anchorName; + bean.anchorAvatar = anchorAvatar; + bean.text = text; + bean.link = link; + bean.file = file; + bean.uid = uid; + bean.shareType = shareType; + bean.cover = cover; + bean.title = title; + bean.extraData = extraData; return bean; } @@ -248,6 +258,12 @@ public class ShareBean { bean.setFile(file); return this; } + + public ShareBuilder setExtraData(String extraData) { + bean.setExtraData(extraData); + return this; + } + public ShareBean build() { return bean; } diff --git a/Share/src/main/java/com/yunbao/share/platform/Internal.java b/Share/src/main/java/com/yunbao/share/platform/Internal.java index 56cb0ec..49a0993 100644 --- a/Share/src/main/java/com/yunbao/share/platform/Internal.java +++ b/Share/src/main/java/com/yunbao/share/platform/Internal.java @@ -9,6 +9,7 @@ import com.yunbao.share.AbsShareInterface; import com.yunbao.share.ICallback; import com.yunbao.share.bean.ShareBean; import com.yunbao.share.ui.AppInternalShareDialog; +import com.yunbao.share.ui.SharePopDialog; import com.yunbao.share.ui.ShareSuccessNotifyDialog; import io.rong.imlib.model.Conversation; @@ -46,7 +47,7 @@ public class Internal extends AbsShareInterface { builder.getAnchorName(), builder.getAnchorId(), builder.getShareType() + "", - builder.getAnchorId() + builder.getExtraData() ), new OnSendMessageListener() { @Override diff --git a/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java b/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java index 81fd552..ecf2c40 100644 --- a/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/SharePopDialog.java @@ -29,6 +29,7 @@ import java.util.List; public class SharePopDialog extends AbsDialogPopupWindow { public static final int TYPE_LIVE = 1; public static final int TYPE_DYNAMIC = 0; + public static final int TYPE_VIDEO = 2; private ShareAppAdapter adapter; private RecyclerView list; private RoundedImageView avatar; diff --git a/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java b/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java index 83abc14..2d72e7d 100644 --- a/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java +++ b/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java @@ -1,15 +1,19 @@ package com.yunbao.common.provider; import android.content.Context; +import android.content.Intent; import android.text.Spannable; import android.view.ViewGroup; import com.alibaba.fastjson.JSON; +import com.yunbao.common.Constants; import com.yunbao.common.R; +import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.message.content.MessageChatCardContent; import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.MicStatusManager; @@ -18,6 +22,7 @@ import com.yunbao.common.utils.StringUtil; import org.greenrobot.eventbus.EventBus; +import java.util.ArrayList; import java.util.List; import io.rong.imkit.conversation.messgelist.provider.BaseMessageItemProvider; @@ -56,6 +61,20 @@ public class MessageChatCardItemProvider extends BaseMessageItemProvider list, IViewProviderListener listener) { if ("1".equals(content.getType())) { gotoLive(content.getExtraData()); + }else if("0".equals(content.getType())){ + RouteUtil.forwardCommunity(content.getExtraData()); + }else if("2".equals(content.getType())){ + LiveNetManager.get(mContext).getDynamicInfo(content.getExtraData(), new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(ActiveBean data) { + RouteUtil.forwardVideoPlayActivity(data); + } + + @Override + public void onError(String error) { + + } + }); } return false; } 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 05b7a8d..08b25fb 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -10,10 +10,12 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; +import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.RedPacketListBean; import com.yunbao.common.manager.IMLoginManager; +import java.util.List; import java.util.Locale; /** @@ -53,6 +55,7 @@ public class RouteUtil { public static final String PATH_VIDEO_ACTIVITY = "/activity/VideoPlayActivity"; public static final String PATH_COMMUNITY = "/main/CommunityDetailsActivity"; public static final String PATH_USER_HOME = "/main/UserHomeActivity"; + public static final String PATH_VIDEO_PLAY = "/video/VideoPlayActivity"; public static void forwardUserHome(String uid) { ARouter.getInstance().build(PATH_USER_HOME) @@ -393,4 +396,11 @@ public class RouteUtil { public static void forwardActivity(String path) { ARouter.getInstance().build(path).navigation(); } + + public static void forwardVideoPlayActivity(ActiveBean bean) { + ARouter.getInstance().build(PATH_VIDEO_PLAY) + .withParcelable("ActiveBean",bean) + .withString(Constants.VIDEO_KEY,Constants.VIDEO_SINGLE) + .navigation(); + } } diff --git a/common/src/main/res/layout/activity_community_details.xml b/common/src/main/res/layout/activity_community_details.xml index d8e610d..502d17e 100644 --- a/common/src/main/res/layout/activity_community_details.xml +++ b/common/src/main/res/layout/activity_community_details.xml @@ -149,6 +149,7 @@ android:textSize="12dp" /> diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 161c2b1..9f20d81 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1470,6 +1470,7 @@ public class LiveAudienceActivity extends LiveActivity { .setAnchorId(event.getBean().getUid()) .setAnchorName(event.getBean().getUserNiceName()) .setAnchorAvatar(event.getBean().getAvatar()) + .setExtraData(event.getBean().getUid()) .build() ) .showDialog(); diff --git a/main/src/main/java/com/yunbao/main/activity/CommunityDetailsActivity.java b/main/src/main/java/com/yunbao/main/activity/CommunityDetailsActivity.java index bb7a9cb..0ed25f6 100644 --- a/main/src/main/java/com/yunbao/main/activity/CommunityDetailsActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/CommunityDetailsActivity.java @@ -41,6 +41,8 @@ import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.NineGridLayout; import com.yunbao.common.views.TopGradual; +import com.yunbao.share.bean.ShareBean; +import com.yunbao.share.ui.SharePopDialog; import java.util.ArrayList; import java.util.Arrays; @@ -239,6 +241,31 @@ public class CommunityDetailsActivity extends AbsActivity { } }); + findViewById(R.id.share).setOnClickListener(view -> { + String image = null; + if (activeBean.getImg_or_video().equals("1")) { + JSONArray jsonArray = (JSONArray) JSONArray.parse(activeBean.getImg_json()); + if (!jsonArray.isEmpty()) { + image = jsonArray.getString(0); + } + }else{ + image=activeBean.getVideo() + "?vframe/jpg/offset/0"; + } + new SharePopDialog(mContext) + .setShareType(SharePopDialog.TYPE_DYNAMIC) + .setShareData(ShareBean.ShareBuilder.create() + .setShareType(SharePopDialog.TYPE_DYNAMIC) + .setUid(CommonAppConfig.getInstance().getUid()) + .setCover(StringUtil.isEmpty(image) ? activeBean.getUser_avatar() : image) + .setTitle(StringUtil.isEmpty(activeBean.getContent()) ? activeBean.getUser_name() : JSONObject.parseObject(activeBean.getContent()).getString("msg")) + .setAnchorId(activeBean.getUser_id()) + .setAnchorName(activeBean.getUser_name()) + .setAnchorAvatar(activeBean.getUser_avatar()) + .setExtraData(activeId) + .build() + ) + .showDialog(); + }); } //回复评论 diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java index a816b13..72b2ab8 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java @@ -40,6 +40,7 @@ import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.NoviceInstructorManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ViewUtils; @@ -249,6 +250,9 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl } }); + ViewUtils.findViewById(card, R.id.rc_conversation_portrait, ImageView.class).setOnClickListener(view -> { + RouteUtil.forwardUserHome(targetId); + }); } catch (Exception e) { e.printStackTrace(); diff --git a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java index 7887687..73316c2 100644 --- a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java +++ b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java @@ -15,6 +15,7 @@ import com.google.gson.Gson; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.R; import java.text.SimpleDateFormat; @@ -89,5 +90,8 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider { //设置时间 String date =new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date(uiConversation.mCore.getSentTime())); holder.setText(R.id.rc_conversation_date, date); + holder.getView(R.id.rc_conversation_portrait).setOnClickListener(view -> { + RouteUtil.forwardUserHome(targetId); + }); } } diff --git a/video/build.gradle b/video/build.gradle index 7368bed..d0cd005 100644 --- a/video/build.gradle +++ b/video/build.gradle @@ -33,6 +33,11 @@ android { ndk { abiFilters "armeabi-v7a","arm64-v8a" } + javaCompileOptions { + annotationProcessorOptions { + arguments = [AROUTER_MODULE_NAME: project.getName()] + } + } } aaptOptions { cruncherEnabled = false @@ -63,5 +68,5 @@ dependencies { implementation project(path: ':common') implementation project(path: ':live') - + annotationProcessor rootProject.ext.dependencies["arouter-compiler"] } diff --git a/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java b/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java index 668314b..bf2ccd1 100644 --- a/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java +++ b/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java @@ -9,6 +9,7 @@ import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.ImageView; +import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSON; import com.binioter.guideview.Guide; import com.binioter.guideview.GuideBuilder; @@ -37,6 +38,7 @@ import java.util.List; * Created by cxf on 2018/11/26. */ +@Route(path = RouteUtil.PATH_VIDEO_PLAY) public class VideoPlayActivity extends AbsVideoPlayActivity { private View viewBottom; @@ -105,6 +107,12 @@ public class VideoPlayActivity extends AbsVideoPlayActivity { if (TextUtils.isEmpty(mVideoKey)) { return; } + ActiveBean bean=intent.getParcelableExtra("ActiveBean"); + if(bean!=null){ + List list = new ArrayList<>(); + list.add(bean); + VideoStorge.getInstance().put(Constants.VIDEO_SINGLE, list); + } int position = intent.getIntExtra(Constants.VIDEO_POSITION, 0); int page = intent.getIntExtra(Constants.VIDEO_PAGE, 1); mVideoScrollViewHolder = new VideoScrollViewHolder(mContext, (ViewGroup) findViewById(R.id.container), position, mVideoKey, page); diff --git a/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java index 55454d2..3fa7931 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java @@ -19,6 +19,7 @@ import android.widget.SeekBar; import android.widget.TextView; import com.alibaba.android.arouter.utils.TextUtils; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.xuexiang.xui.widget.flowlayout.FlowTagLayout; import com.yunbao.common.CommonAppConfig; @@ -33,6 +34,8 @@ import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.AbsViewHolder; +import com.yunbao.share.bean.ShareBean; +import com.yunbao.share.ui.SharePopDialog; import com.yunbao.video.R; import com.yunbao.video.activity.AbsVideoPlayActivity; import com.yunbao.video.dialog.VideoShareDialogFragment; @@ -489,11 +492,34 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli if (mVideoBean == null) { return; } - VideoShareDialogFragment fragment = new VideoShareDialogFragment(); + /* VideoShareDialogFragment fragment = new VideoShareDialogFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(Constants.VIDEO_BEAN, mVideoBean); fragment.setArguments(bundle); - fragment.show(((AbsVideoPlayActivity) mContext).getSupportFragmentManager(), "VideoShareDialogFragment"); + fragment.show(((AbsVideoPlayActivity) mContext).getSupportFragmentManager(), "VideoShareDialogFragment");*/ + String image = null; + if (mVideoBean.getImg_or_video().equals("1")) { + JSONArray jsonArray = (JSONArray) JSONArray.parse(mVideoBean.getImg_json()); + if (!jsonArray.isEmpty()) { + image = jsonArray.getString(0); + } + }else{ + image=mVideoBean.getVideo() + "?vframe/jpg/offset/0"; + } + new SharePopDialog(mContext) + .setShareType(SharePopDialog.TYPE_VIDEO) + .setShareData(ShareBean.ShareBuilder.create() + .setShareType(SharePopDialog.TYPE_VIDEO) + .setUid(CommonAppConfig.getInstance().getUid()) + .setCover(StringUtil.isEmpty(image) ? mVideoBean.getUser_avatar() : image) + .setTitle(StringUtil.isEmpty(mVideoBean.getContent()) ? mVideoBean.getUser_name() : JSONObject.parseObject(mVideoBean.getContent()).getString("msg")) + .setAnchorId(mVideoBean.getUser_id()) + .setAnchorName(mVideoBean.getUser_name()) + .setAnchorAvatar(mVideoBean.getUser_avatar()) + .setExtraData(mVideoBean.getId()) + .build() + ) + .showDialog(); } public void release() {