From 2e9d1cb3dd04a7b4448a094680c4cbc8e5ca3bc8 Mon Sep 17 00:00:00 2001 From: hch <16607480311@163.com> Date: Thu, 28 Mar 2024 13:36:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=20[=E4=BF=AE=E5=A4=8D-=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5-=E7=82=B9=E5=87=BB=E8=A7=86=E9=A2=91-?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/adapter/UserCommunityAdapter.java | 22 +++++++---- .../main/activity/UserHomeActivity.java | 39 ++++++++++++------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java b/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java index 465885796..5e58c426e 100644 --- a/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java @@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSONObject; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.ActiveOtherBean; import com.yunbao.common.dialog.ImagePreviewDialog; import com.yunbao.common.glide.ImgLoader; @@ -27,7 +28,7 @@ import java.util.ArrayList; import java.util.List; public class UserCommunityAdapter extends RecyclerView.Adapter { - private List commentBeanList; + private List commentBeanList; private Context mContext; private onItemClickListener onItemClickListener; private boolean isMe; @@ -36,7 +37,7 @@ public class UserCommunityAdapter extends RecyclerView.Adapter { this.onItemClickListener = onItemClickListener; } - public UserCommunityAdapter(Context content, List commentBeanList, boolean isMe) { + public UserCommunityAdapter(Context content, List commentBeanList, boolean isMe) { this.mContext = content; this.commentBeanList = commentBeanList; this.isMe = isMe; @@ -90,7 +91,7 @@ public class UserCommunityAdapter extends RecyclerView.Adapter { @Override public void onClick(View v) { if (onItemClickListener != null) { - onItemClickListener.onItemMore((ActiveOtherBean) v.getTag(), getPosition()); + onItemClickListener.onItemMore((ActiveBean) v.getTag(), getPosition()); } } }); @@ -98,14 +99,19 @@ public class UserCommunityAdapter extends RecyclerView.Adapter { @Override public void onClick(View v) { if (onItemClickListener != null) { - onItemClickListener.onImgItem((ActiveOtherBean) v.getTag(), getPosition()); + ActiveBean activeOtherBean = (ActiveBean) v.getTag(); + if (activeOtherBean.getImg_or_video().equals("1")) { + onItemClickListener.onImgItem(activeOtherBean, getPosition()); + } else { + onItemClickListener.onItemVideo(activeOtherBean, getPosition()); + } } } }); } @SuppressLint("SetTextI18n") - public void setData(ActiveOtherBean bean) { + public void setData(ActiveBean bean) { itemView.setTag(bean); mAvatar.setTag(bean); more_del.setTag(bean); @@ -161,8 +167,10 @@ public class UserCommunityAdapter extends RecyclerView.Adapter { } public interface onItemClickListener { - void onImgItem(ActiveOtherBean activeBean, int position); + void onImgItem(ActiveBean activeBean, int position); - void onItemMore(ActiveOtherBean activeBean, int position); + void onItemMore(ActiveBean activeBean, int position); + + void onItemVideo(ActiveBean activeBean, int position); } } diff --git a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java index 8070f6ed0..56d26b854 100644 --- a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java @@ -71,6 +71,8 @@ import com.yunbao.common.views.UserHomeImgsViewHolder; import com.yunbao.live.activity.LiveRyAnchorActivity; import com.yunbao.live.dialog.GiftWallDialog; import com.yunbao.live.views.ShowBigPhoto; +import com.yunbao.video.activity.VideoPlayActivity; +import com.yunbao.video.utils.VideoStorge; import java.io.File; import java.util.ArrayList; @@ -152,7 +154,7 @@ public class UserHomeActivity extends AbsActivity { private LinearLayout bottomEditLayout; private UploadQnImpl mUploadStrategy; private List videoList = new ArrayList<>(); - List beanList = new ArrayList<>(); + List beanList = new ArrayList<>(); private UserHomeImgsViewHolder userHomeImgsViewHolder; private Map gotoRoomKey = new HashMap<>(); @@ -183,26 +185,21 @@ public class UserHomeActivity extends AbsActivity { CommonHttpUtil.getOtherDynamicList(uid, new com.yunbao.common.http.HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - beanList = JSONArray.parseArray(Arrays.toString(info), ActiveOtherBean.class); + beanList = JSONArray.parseArray(Arrays.toString(info), ActiveBean.class); + for (int j = 0; j < beanList.size(); j++) { + if (beanList.get(j).getImg_or_video().equals("2")) { + videoList.add(beanList.get(j)); + } + } UserCommunityAdapter userCommunityAdapter = new UserCommunityAdapter(mContext, beanList, isMe); userCommunityAdapter.setOnItemClickListener(new UserCommunityAdapter.onItemClickListener() { @Override - public void onImgItem(ActiveOtherBean bean, int position) { - if (bean.getImg_or_video().equals("1")) { - RouteUtil.forwardCommunity(bean.getId()); - } else { - /*int playPosition = 0; - for (int i = 0; i < videoList.size(); i++) { - if (videoList.get(i).getId().equals(bean.getId())) { - playPosition = i; - } - } - RouteUtil.forwardVideoActivity();*/ - } + public void onImgItem(ActiveBean bean, int position) { + RouteUtil.forwardCommunity(bean.getId()); } @Override - public void onItemMore(ActiveOtherBean bean, int position) { + public void onItemMore(ActiveBean bean, int position) { DialogUitl.showSimpleDialog(mContext, getResources().getString(com.yunbao.main.R.string.msg_del_sure), false, new DialogUitl.SimpleCallback() { @Override public void onConfirmClick(Dialog dialog, String content) { @@ -218,6 +215,18 @@ public class UserHomeActivity extends AbsActivity { } }); } + + @Override + public void onItemVideo(ActiveBean activeBean, int position) { + int playPosition = 0; + for (int i = 0; i < videoList.size(); i++) { + if (videoList.get(i).getId().equals(activeBean.getId())) { + playPosition = i; + } + } + VideoStorge.getInstance().put(Constants.VIDEO_HOME, videoList); + VideoPlayActivity.forward(mContext, playPosition, Constants.VIDEO_HOME, 1); + } }); communityRecyclerView.setAdapter(userCommunityAdapter); }