Commit bafa2052 by 段启岩

动态列表框架优化

parent 1e01f6c6
...@@ -36,8 +36,8 @@ public class BlogListRecyclerViewAdapter extends BaseQuickAdapter<Blog ,BaseView ...@@ -36,8 +36,8 @@ public class BlogListRecyclerViewAdapter extends BaseQuickAdapter<Blog ,BaseView
binding.blogCover.setVisibility(View.VISIBLE); binding.blogCover.setVisibility(View.VISIBLE);
RequestOptions options = new RequestOptions() RequestOptions options = new RequestOptions()
.centerCrop() .centerCrop()
.placeholder(R.drawable.pre_load_blog) .placeholder(R.drawable.placeholder_rectangle)
.error(R.drawable.pre_load_blog) .error(R.drawable.placeholder_rectangle)
.priority(Priority.HIGH) .priority(Priority.HIGH)
.skipMemoryCache(true) .skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE) .diskCacheStrategy(DiskCacheStrategy.NONE)
......
...@@ -14,6 +14,10 @@ import android.widget.Toast; ...@@ -14,6 +14,10 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder; import com.chad.library.adapter.base.BaseViewHolder;
...@@ -22,6 +26,7 @@ import java.util.List; ...@@ -22,6 +26,7 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import cn.yunliyunwai.beyondclouds.R;
import cn.yunliyunwai.beyondclouds.data.model.Post; import cn.yunliyunwai.beyondclouds.data.model.Post;
import cn.yunliyunwai.beyondclouds.databinding.PostItemBinding; import cn.yunliyunwai.beyondclouds.databinding.PostItemBinding;
import cn.yunliyunwai.beyondclouds.util.DateUtils; import cn.yunliyunwai.beyondclouds.util.DateUtils;
...@@ -59,7 +64,7 @@ public class DynamicListRecyclerViewAdapter extends BaseQuickAdapter<Post,BaseVi ...@@ -59,7 +64,7 @@ public class DynamicListRecyclerViewAdapter extends BaseQuickAdapter<Post,BaseVi
private static final Pattern TOPIC_LINK_PATTERN = Pattern.compile("<a.+?href=['\"](.+?)['\"]>(.+?)</a>"); private static final Pattern TOPIC_LINK_PATTERN = Pattern.compile("<a.+?href=['\"](.+?)['\"]>(.+?)</a>");
private static final String TOPIC_BARRIER = "#"; private static final String TOPIC_BARRIER = "#";
private static final GlideRoundTransform glideRoundTransform = new GlideRoundTransform(3); private static final GlideRoundTransform glideRoundTransform = new GlideRoundTransform(20);
public DynamicListRecyclerViewAdapter(int layoutResId) { public DynamicListRecyclerViewAdapter(int layoutResId) {
super(layoutResId); super(layoutResId);
} }
...@@ -69,8 +74,19 @@ public class DynamicListRecyclerViewAdapter extends BaseQuickAdapter<Post,BaseVi ...@@ -69,8 +74,19 @@ public class DynamicListRecyclerViewAdapter extends BaseQuickAdapter<Post,BaseVi
PostItemBinding binding = PostItemBinding.bind(helper.itemView); PostItemBinding binding = PostItemBinding.bind(helper.itemView);
parseAndSetContent(binding.txtContent, post.getContent()); parseAndSetContent(binding.txtContent, post.getContent());
binding.txtAuthor.setText(post.getUserNick()); binding.txtUserNick.setText(post.getUserNick());
binding.txtCreateTime.setText(DateUtils.format(post.getCreateTime())); binding.txtCreateTime.setText(DateUtils.format(post.getCreateTime()));
if (null != post.getUserAvatar() && !TextUtils.isEmpty(post.getUserAvatar().trim()) && post.getUserAvatar().startsWith("http")) {
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.drawable.placeholder_square)
.error(R.drawable.placeholder_square)
.priority(Priority.HIGH)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.transform(glideRoundTransform);
Glide.with(binding.getRoot()).applyDefaultRequestOptions(options).load(post.getUserAvatar()).into(binding.imgUserAvatar);
}
} }
......
...@@ -36,8 +36,8 @@ public class ProjectListRecyclerViewAdapter extends BaseQuickAdapter<Project,Bas ...@@ -36,8 +36,8 @@ public class ProjectListRecyclerViewAdapter extends BaseQuickAdapter<Project,Bas
binding.blogCover.setVisibility(View.VISIBLE); binding.blogCover.setVisibility(View.VISIBLE);
RequestOptions options = new RequestOptions() RequestOptions options = new RequestOptions()
.centerCrop() .centerCrop()
.placeholder(R.drawable.pre_load_blog) .placeholder(R.drawable.placeholder_rectangle)
.error(R.drawable.pre_load_blog) .error(R.drawable.placeholder_rectangle)
.priority(Priority.HIGH) .priority(Priority.HIGH)
.skipMemoryCache(true) .skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE) .diskCacheStrategy(DiskCacheStrategy.NONE)
......
...@@ -8,23 +8,50 @@ ...@@ -8,23 +8,50 @@
android:clickable="true" android:clickable="true"
android:paddingStart="12dp" android:paddingStart="12dp"
android:paddingLeft="12dp" android:paddingLeft="12dp"
android:paddingTop="16dp" android:paddingTop="18dp"
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:paddingRight="12dp"> android:paddingRight="12dp">
<ImageView
android:id="@+id/img_user_avatar"
android:src="@drawable/placeholder_square"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="40dp"
android:layout_height="40dp" />
<TextView <TextView
android:id="@+id/txt_title" android:id="@+id/txt_user_nick"
android:text="段启岩"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="60dp"
android:layout_marginLeft="60dp"
app:layout_constraintTop_toTopOf="parent"
android:textColor="@color/colorTextAccent"
android:textSize="14sp"
android:gravity="center_vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="22dp" />
<TextView
android:id="@+id/txt_create_time"
android:text="2020-2-18 10:24:00"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> android:layout_marginStart="60dp"
android:layout_marginLeft="60dp"
android:layout_marginTop="3dp"
app:layout_constraintTop_toBottomOf="@id/txt_user_nick"
android:textColor="#999999"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.constraintlayout.widget.Barrier <androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_user_info" android:id="@+id/barrier_user_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:barrierDirection="bottom" app:barrierDirection="bottom"
app:constraint_referenced_ids="txt_title" app:constraint_referenced_ids="img_user_avatar,txt_user_nick,txt_create_time"
tools:layout_editor_absoluteX="12dp" tools:layout_editor_absoluteX="12dp"
tools:layout_editor_absoluteY="16dp" /> tools:layout_editor_absoluteY="16dp" />
...@@ -34,7 +61,7 @@ ...@@ -34,7 +61,7 @@
android:text="SpringBoot迭代发布JRA瘦身配置" android:text="SpringBoot迭代发布JRA瘦身配置"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:textSize="14sp"
android:textColorHint="@color/colorPrimaryTouched" android:textColorHint="@color/colorPrimaryTouched"
android:linksClickable="true" android:linksClickable="true"
android:textColorHighlight="@color/colorBackgroundTopicTouched" android:textColorHighlight="@color/colorBackgroundTopicTouched"
...@@ -53,55 +80,11 @@ ...@@ -53,55 +80,11 @@
tools:layout_editor_absoluteX="12dp" tools:layout_editor_absoluteX="12dp"
tools:layout_editor_absoluteY="16dp" /> tools:layout_editor_absoluteY="16dp" />
<TextView
android:id="@+id/txt_author"
android:layout_marginTop="10dp"
android:text="段启岩"
android:textSize="10sp"
android:textColor="@color/colorText"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txt_dot"
android:text="·"
android:layout_marginTop="10dp"
android:textSize="10sp"
android:textStyle="bold"
android:textColor="@color/colorText"
app:layout_constraintTop_toBottomOf="@id/barrier_content"
app:layout_constraintStart_toEndOf="@id/txt_author"
android:paddingStart="6dp"
android:paddingLeft="6dp"
android:paddingEnd="6dp"
android:paddingRight="6dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txt_create_time"
android:layout_marginTop="10dp"
android:textSize="10sp"
android:textColor="@color/colorText"
android:text="2020-2-18 10:24:00"
app:layout_constraintTop_toBottomOf="@id/barrier_content"
app:layout_constraintStart_toEndOf="@id/txt_dot"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="txt_create_time,txt_author,txt_dot"
tools:layout_editor_absoluteX="12dp"
tools:layout_editor_absoluteY="16dp" />
<View <View
app:layout_constraintTop_toBottomOf="@id/barrier_info"
android:layout_marginTop="18dp" android:layout_marginTop="18dp"
app:layout_constraintTop_toBottomOf="@id/barrier_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="1dp" android:layout_height="1dp"
android:background="#efefef" /> android:background="#efefef" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment