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); }