热门条目ui调整完成

This commit is contained in:
ningwenqiang 2024-10-30 11:10:09 +08:00
parent 0f0ede4040
commit ac1b8eeae5
43 changed files with 439 additions and 8 deletions

View File

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.yunbao.common.custom.RatioRoundImageView
android:id="@+id/author"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:layout_marginTop="18dp"
android:scaleType="centerCrop"
android:src="@mipmap/user_info_bg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:riv_corner_radius="18dp" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textColor="#333333"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@+id/author"
app:layout_constraintTop_toTopOf="@+id/author"
tools:text="栗子栗子🌰zzz" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="02 - 11发布"
android:textColor="#999999"
android:textSize="10sp"
app:layout_constraintStart_toStartOf="@+id/name"
app:layout_constraintTop_toBottomOf="@+id/name" />
<ImageView
android:id="@+id/attentionImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="18dp"
android:src="@mipmap/ic_yola_attention"
app:layout_constraintBottom_toBottomOf="@+id/author"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/author" />
<TextView
android:id="@+id/content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="哇这里我也太想去了!真是太漂亮了 请问一下路边结冰了吗?会不会封路?"
android:textColor="#333333"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="@+id/attentionImg"
app:layout_constraintStart_toStartOf="@+id/name"
app:layout_constraintTop_toBottomOf="@+id/author" />
<ImageView
android:id="@+id/videoImage"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="1.78"
app:layout_constraintEnd_toEndOf="@+id/attentionImg"
app:layout_constraintStart_toStartOf="@+id/name"
app:layout_constraintTop_toBottomOf="@+id/content" />
<ImageView
android:id="@+id/videoStartImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
android:src="@mipmap/ic_yola_play_video"
app:layout_constraintBottom_toBottomOf="@+id/videoImage"
app:layout_constraintEnd_toEndOf="@+id/videoImage"
app:layout_constraintStart_toStartOf="@+id/videoImage"
app:layout_constraintTop_toTopOf="@+id/videoImage" />
<com.yunbao.common.views.NineGridLayout
android:id="@+id/nine_grid_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="@+id/attentionImg"
app:layout_constraintStart_toStartOf="@+id/name"
app:layout_constraintTop_toBottomOf="@+id/videoImage"
app:ngl_corner_radius="5dp"
app:ngl_divider_width="6dp"
app:ngl_space="95dp" />
<ImageView
android:id="@+id/shareImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="-5dp"
android:layout_marginTop="15dp"
android:padding="5dp"
android:src="@mipmap/ic_yola_share"
app:layout_constraintStart_toStartOf="@+id/content"
app:layout_constraintTop_toBottomOf="@+id/nine_grid_layout" />
<TextView
android:id="@+id/shareText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@+id/shareImg"
app:layout_constraintStart_toEndOf="@+id/shareImg"
app:layout_constraintTop_toTopOf="@+id/shareImg"
tools:text="98" />
<ImageView
android:id="@+id/msgImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="-5dp"
android:layout_marginTop="15dp"
android:padding="5dp"
android:src="@mipmap/ic_yola_comment"
app:layout_constraintEnd_toEndOf="@+id/content"
app:layout_constraintHorizontal_bias="0.26"
app:layout_constraintStart_toStartOf="@+id/content"
app:layout_constraintTop_toBottomOf="@+id/nine_grid_layout" />
<TextView
android:id="@+id/msgText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@+id/msgImg"
app:layout_constraintStart_toEndOf="@+id/msgImg"
app:layout_constraintTop_toTopOf="@+id/msgImg"
tools:text="98" />
<ImageView
android:id="@+id/likeImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="-5dp"
android:layout_marginTop="15dp"
android:padding="5dp"
android:src="@mipmap/ic_yola_like"
app:layout_constraintEnd_toEndOf="@+id/content"
app:layout_constraintHorizontal_bias="0.52"
app:layout_constraintStart_toStartOf="@+id/content"
app:layout_constraintTop_toBottomOf="@+id/nine_grid_layout" />
<TextView
android:id="@+id/likeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@+id/likeImg"
app:layout_constraintStart_toEndOf="@+id/likeImg"
app:layout_constraintTop_toTopOf="@+id/likeImg"
tools:text="98" />
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

View File

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 294 B

View File

Before

Width:  |  Height:  |  Size: 648 B

After

Width:  |  Height:  |  Size: 648 B

View File

Before

Width:  |  Height:  |  Size: 430 B

After

Width:  |  Height:  |  Size: 430 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 907 B

After

Width:  |  Height:  |  Size: 907 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -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<ActiveBean> {
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<Integer>() {
@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<String> 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());
}
}
}

View File

@ -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<ActiveBean> {
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<ActiveBean>() {
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<ActiveBean>() {
@Override
public RefreshAdapter<ActiveBean> getAdapter() {
if (mAdapter == null) {
mAdapter = new MainHomeComAdapter(mContext);
mAdapter = new MainHomeComAdapter2(mContext);
mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this);
}
return mAdapter;

View File

@ -15,7 +15,7 @@
tools:listitem="@layout/item_main_home_com_class"
android:overScrollMode="never" />
<com.yunbao.common.custom.CommonRefreshWaterfallView
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
android:layout_width="match_parent"
android:layout_height="match_parent"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB