diff --git a/live/src/main/res/layout/item_main_com2.xml b/live/src/main/res/layout/item_main_com2.xml new file mode 100644 index 000000000..4b11feb18 --- /dev/null +++ b/live/src/main/res/layout/item_main_com2.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_attention.png b/live/src/main/res/mipmap-hdpi/ic_yola_attention.png new file mode 100644 index 000000000..31fe27134 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_attention.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_camera.png b/live/src/main/res/mipmap-hdpi/ic_yola_camera.png new file mode 100644 index 000000000..02a1af412 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_camera.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_comment.png b/live/src/main/res/mipmap-hdpi/ic_yola_comment.png new file mode 100644 index 000000000..9ca3b9e38 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_comment.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_has_attention.png b/live/src/main/res/mipmap-hdpi/ic_yola_has_attention.png new file mode 100644 index 000000000..19527f3eb Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_has_attention.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_like.png b/live/src/main/res/mipmap-hdpi/ic_yola_like.png new file mode 100644 index 000000000..dd7c9c705 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_like.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_play_video.png b/live/src/main/res/mipmap-hdpi/ic_yola_play_video.png new file mode 100644 index 000000000..6c803cfb7 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_play_video.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_search.png b/live/src/main/res/mipmap-hdpi/ic_yola_search.png new file mode 100644 index 000000000..a90e380d8 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_search.png differ diff --git a/live/src/main/res/mipmap-hdpi/ic_yola_share.png b/live/src/main/res/mipmap-hdpi/ic_yola_share.png new file mode 100644 index 000000000..6edc3a7f0 Binary files /dev/null and b/live/src/main/res/mipmap-hdpi/ic_yola_share.png differ diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_attention.png b/live/src/main/res/mipmap-mdpi/ic_yola_attention.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_attention.png rename to live/src/main/res/mipmap-mdpi/ic_yola_attention.png diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_camera.png b/live/src/main/res/mipmap-mdpi/ic_yola_camera.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_camera.png rename to live/src/main/res/mipmap-mdpi/ic_yola_camera.png diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_comment.png b/live/src/main/res/mipmap-mdpi/ic_yola_comment.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_comment.png rename to live/src/main/res/mipmap-mdpi/ic_yola_comment.png diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_has_attention.png b/live/src/main/res/mipmap-mdpi/ic_yola_has_attention.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_has_attention.png rename to live/src/main/res/mipmap-mdpi/ic_yola_has_attention.png diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_like.png b/live/src/main/res/mipmap-mdpi/ic_yola_like.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_like.png rename to live/src/main/res/mipmap-mdpi/ic_yola_like.png diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_play_video.png b/live/src/main/res/mipmap-mdpi/ic_yola_play_video.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_play_video.png rename to live/src/main/res/mipmap-mdpi/ic_yola_play_video.png diff --git a/main/src/main/res/mipmap-mdpi/ic_yola_search.png b/live/src/main/res/mipmap-mdpi/ic_yola_search.png similarity index 100% rename from main/src/main/res/mipmap-mdpi/ic_yola_search.png rename to live/src/main/res/mipmap-mdpi/ic_yola_search.png diff --git a/live/src/main/res/mipmap-mdpi/ic_yola_share.png b/live/src/main/res/mipmap-mdpi/ic_yola_share.png new file mode 100644 index 000000000..5f9b826f0 Binary files /dev/null and b/live/src/main/res/mipmap-mdpi/ic_yola_share.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_attention.png b/live/src/main/res/mipmap-xhdpi/ic_yola_attention.png new file mode 100644 index 000000000..90a664c10 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_attention.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_camera.png b/live/src/main/res/mipmap-xhdpi/ic_yola_camera.png new file mode 100644 index 000000000..77daf005a Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_camera.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_comment.png b/live/src/main/res/mipmap-xhdpi/ic_yola_comment.png new file mode 100644 index 000000000..905f58406 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_comment.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_has_attention.png b/live/src/main/res/mipmap-xhdpi/ic_yola_has_attention.png new file mode 100644 index 000000000..392f31e72 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_has_attention.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_like.png b/live/src/main/res/mipmap-xhdpi/ic_yola_like.png new file mode 100644 index 000000000..25e087aaf Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_like.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_play_video.png b/live/src/main/res/mipmap-xhdpi/ic_yola_play_video.png new file mode 100644 index 000000000..09324823a Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_play_video.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_search.png b/live/src/main/res/mipmap-xhdpi/ic_yola_search.png new file mode 100644 index 000000000..18b66944f Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_search.png differ diff --git a/live/src/main/res/mipmap-xhdpi/ic_yola_share.png b/live/src/main/res/mipmap-xhdpi/ic_yola_share.png new file mode 100644 index 000000000..7fc501af3 Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/ic_yola_share.png differ diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_attention.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_attention.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_attention.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_attention.png diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_camera.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_camera.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_camera.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_camera.png diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_comment.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_comment.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_comment.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_comment.png diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_has_attention.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_has_attention.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_has_attention.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_has_attention.png diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_like.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_like.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_like.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_like.png diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_play_video.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_play_video.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_play_video.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_play_video.png diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_yola_search.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_search.png similarity index 100% rename from main/src/main/res/mipmap-xxxhdpi/ic_yola_search.png rename to live/src/main/res/mipmap-xxxhdpi/ic_yola_search.png diff --git a/live/src/main/res/mipmap-xxxhdpi/ic_yola_share.png b/live/src/main/res/mipmap-xxxhdpi/ic_yola_share.png new file mode 100644 index 000000000..b2503167d Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/ic_yola_share.png differ diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java new file mode 100644 index 000000000..c13474eef --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter2.java @@ -0,0 +1,259 @@ +package com.yunbao.main.adapter; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Color; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.facebook.share.widget.ShareDialog; +import com.momo.mcamera.util.JsonUtil; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.custom.RatioRoundImageView; +import com.yunbao.common.dialog.ImagePreviewDialog; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.NineGridLayout; +import com.yunbao.main.R; +import com.yunbao.main.activity.CommunityDetailsActivity; +import com.yunbao.share.bean.ShareBean; +import com.yunbao.share.ui.SharePopDialog; + +import java.util.ArrayList; +import java.util.List; + + +/** + * Created by cxf on 2018/9/26. + * 首页 社区 + */ + +public class MainHomeComAdapter2 extends RefreshAdapter { + + private Context mContext; + + private View.OnClickListener mOnClickListener; + + public MainHomeComAdapter2(Context context) { + super(context); + this.mContext = context; + mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag != null && mOnItemClickListener != null) { + mOnItemClickListener.onItemClick((ActiveBean) tag, 0); + } + } + }; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(com.yunbao.live.R.layout.item_main_com2, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { + ((Vh) vh).setData(mList.get(position), position); + } + + @Override + public int getItemCount() { + return super.getItemCount(); + } + + class Vh extends RecyclerView.ViewHolder { + + private RatioRoundImageView author; + private TextView name; + private TextView time; + private ImageView attentionImg; + private TextView content; + + private NineGridLayout mNineGridLayout; + private ImageView shareImg; + private TextView shareText; + private ImageView msgImg, videoImage, videoStartImage; + private TextView msgText; + private ImageView likeImg; + private TextView likeText; + + + public Vh(View itemView) { + super(itemView); + // 初始化控件 + author = itemView.findViewById(R.id.author); + name = itemView.findViewById(R.id.name); + time = itemView.findViewById(R.id.time); + attentionImg = itemView.findViewById(R.id.attentionImg); + content = itemView.findViewById(R.id.content); + mNineGridLayout = itemView.findViewById(R.id.nine_grid_layout); + shareImg = itemView.findViewById(R.id.shareImg); + shareText = itemView.findViewById(R.id.shareText); + msgImg = itemView.findViewById(R.id.msgImg); + msgText = itemView.findViewById(R.id.msgText); + likeImg = itemView.findViewById(R.id.likeImg); + likeText = itemView.findViewById(R.id.likeText); + videoImage = itemView.findViewById(R.id.videoImage); + videoStartImage = itemView.findViewById(R.id.videoStartImage); + itemView.setOnClickListener(mOnClickListener); + mNineGridLayout.setActionListener(new NineGridLayout.ActionListener() { + @Override + public void onItemClick(List dataList, int position) { + ImagePreviewDialog dialog = new ImagePreviewDialog(); + dialog.setImageInfo(dataList.size(), position, false, new ImagePreviewDialog.ActionListener() { + @Override + public void loadImage(ImageView imageView, int position) { + ImgLoader.display(mContext, (String) (dataList.get(position)), imageView); + } + + @Override + public void onDeleteClick(int position) { + + } + }); + dialog.show(((AbsActivity) mContext).getSupportFragmentManager(), "ImagePreviewDialog"); + } + + @Override + public void displayImage(Object path, ImageView imageView) { + ImgLoader.display(mNineGridLayout.getContext(), String.valueOf(path), imageView); + } + }); + } + + void setData(ActiveBean bean, int position) { + itemView.setTag(bean); + if (bean == null) { + return; + } + ImgLoader.display(mContext, bean.getUser_avatar(), author); + name.setText(bean.getUser_name()); + time.setText(bean.getCreate_time()); + if (bean.getIs_attention().equals("1")) {//关注 + attentionImg.setImageResource(R.mipmap.ic_yola_has_attention); + } else { + attentionImg.setImageResource(R.mipmap.ic_yola_attention); + } + + likeImg.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommonHttpUtil.dynamicLove(bean.getId(), new HttpCallback() { + @SuppressLint("SetTextI18n") + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ToastUtil.show(msg); + if (bean.getIs_love().equals("1")) { + bean.setIs_love("0"); + msgText.setText(String.valueOf(Integer.parseInt(bean.getComment_num()) - 1)); + bean.setLove_num(String.valueOf(Integer.parseInt(bean.getLove_num()) + 1)); + } else { + msgText.setText(String.valueOf(Integer.parseInt(bean.getComment_num()) + 1)); + bean.setLove_num(String.valueOf(Integer.parseInt(bean.getLove_num()) + 1)); + bean.setIs_love("1"); + } + } + } + }); + } + }); + + attentionImg.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommonHttpUtil.setAttention(bean.getUser_id(), new CommonCallback() { + @Override + public void callback(Integer isAttention) { + if (isAttention == 1) { + bean.setIs_attention("0"); + attentionImg.setImageResource(R.mipmap.ic_yola_has_attention); + } else { + bean.setIs_attention("1"); + attentionImg.setImageResource(R.mipmap.ic_yola_attention); + + } + } + }); + } + }); + shareImg.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v) { + String image = null; + if (bean.getImg_or_video().equals("1")) { + JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json()); + if (!jsonArray.isEmpty()) { + image = jsonArray.getString(0); + } + } else { + image = bean.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) ? bean.getUser_avatar() : image) + .setTitle(StringUtil.isEmpty(bean.getContent()) ? bean.getUser_name() : JSONObject.parseObject(bean.getContent()).getString("msg")) + .setAnchorId(bean.getUser_id()).setAnchorName(bean.getUser_name()).setAnchorAvatar(bean.getUser_avatar()). + setExtraData(bean.getId()).build()).showDialog(); + } + }); + + + + if (!StringUtil.isEmpty(bean.getContent())) { + try { + content.setText(String.valueOf(JSONObject.parseObject(bean.getContent()).get("msg"))); + } catch (Exception e) { + + } +// Log.i("MainHomeComAdapter2", "getContent:" + bean.getContent()); +// content.setText(bean.getContent()); + } + if (bean.getImg_or_video().equals("1")) {//图片 + videoStartImage.setVisibility(View.GONE); + videoImage.setVisibility(View.GONE); + mNineGridLayout.setVisibility(View.VISIBLE); + JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json()); + List tempList = new ArrayList<>(); + for (int i = 0; i < jsonArray.size(); i++) { + tempList.add(String.valueOf(jsonArray.get(i))); + } + mNineGridLayout.setData(tempList); + Log.i("MainHomeComAdapter2", "图片个数:" + jsonArray.size()); + } else { + videoStartImage.setVisibility(View.VISIBLE); + videoImage.setVisibility(View.VISIBLE); + mNineGridLayout.setVisibility(View.GONE); + Log.i("MainHomeComAdapter2", "是视频:"); + ImgLoader.display(videoImage.getContext(), bean.getVideo() + "?vframe/jpg/offset/0", videoImage); + } + + likeText.setText(bean.getLove_num()); + shareText.setText(bean.getShare_num()); + msgText.setText(bean.getComment_num()); + } + } +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java index b5a99ff6a..6c4215c9a 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java @@ -19,6 +19,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.NewCommunityType; +import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.custom.CommonRefreshWaterfallView; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; @@ -29,7 +30,7 @@ import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.main.R; -import com.yunbao.main.adapter.MainHomeComAdapter; +import com.yunbao.main.adapter.MainHomeComAdapter2; import com.yunbao.main.adapter.MainHomeComClassAdapter; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; @@ -53,9 +54,9 @@ import java.util.Map; public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { private View mBtnDismiss; - public static CommonRefreshWaterfallView mRefreshView; + public static CommonRefreshView mRefreshView; private RecyclerView mClassRecyclerViewTop; - private MainHomeComAdapter mAdapter; + private MainHomeComAdapter2 mAdapter; private ObjectAnimator mShowAnimator; private ObjectAnimator mHideAnimator; public static ImageView btnUseIco; @@ -112,18 +113,18 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements } } }); - mRefreshView = (CommonRefreshWaterfallView) findViewById(R.id.refreshView); + mRefreshView = findViewById(R.id.refreshView); btnUseIco = (ImageView) findViewById(R.id.btn_use_ico); mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live); EventBus.getDefault().register(this); - + mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mRefreshView.setLoadMoreEnable(true); mRefreshView.setRecyclerViewAdapter(mAdapter); - mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { @Override public RefreshAdapter getAdapter() { if (mAdapter == null) { - mAdapter = new MainHomeComAdapter(mContext); + mAdapter = new MainHomeComAdapter2(mContext); mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this); } return mAdapter; diff --git a/main/src/main/res/layout/view_main_home_com_hot.xml b/main/src/main/res/layout/view_main_home_com_hot.xml index 8a7f0f42b..797fe6ed8 100644 --- a/main/src/main/res/layout/view_main_home_com_hot.xml +++ b/main/src/main/res/layout/view_main_home_com_hot.xml @@ -15,7 +15,7 @@ tools:listitem="@layout/item_main_home_com_class" android:overScrollMode="never" /> -