Pq před 3 roky
rodič
revize
176a551c33

+ 5 - 1
student/src/main/java/com/cooleshow/student/ui/main/HomeFragment.java

@@ -30,6 +30,7 @@ import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
 import com.cooleshow.base.utils.GlideUtils;
 import com.cooleshow.base.utils.SPUtils;
+import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.TimeUtils;
 import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.helper.QMUIDisplayHelper;
@@ -53,6 +54,7 @@ import com.cooleshow.student.databinding.FragmentHomeLayoutBinding;
 import com.cooleshow.student.presenter.main.HomePresenter;
 import com.cooleshow.student.ui.course.SparringCourseDetailActivity;
 import com.cooleshow.student.widgets.DialogUtils;
+import com.cooleshow.student.widgets.HomeHotAlbumDecoration;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.daya.live_teaching.utils.DisplayUtils;
 import com.scwang.smart.refresh.layout.api.RefreshLayout;
@@ -289,7 +291,9 @@ public class HomeFragment extends BaseMVPFragment<FragmentHomeLayoutBinding, Hom
         LinearLayoutManager manager = new LinearLayoutManager(getContext());
         manager.setOrientation(LinearLayoutManager.HORIZONTAL);
         mViewBinding.rvHotAlbum.setLayoutManager(manager);
+        HomeHotAlbumDecoration homeHotAlbumDecoration = new HomeHotAlbumDecoration(0, 0, 0, SizeUtils.dp2px(14), 0);
         HomeHotAlbumAdapter albumAdapter = new HomeHotAlbumAdapter(data.rows);
+        mViewBinding.rvHotAlbum.addItemDecoration(homeHotAlbumDecoration);
         mViewBinding.rvHotAlbum.setAdapter(albumAdapter);
         albumAdapter.setOnItemClickListener((adapter, view, position) -> {
             HotAlbumBean.RowsBean item = (HotAlbumBean.RowsBean) adapter.getItem(position);
@@ -366,7 +370,7 @@ public class HomeFragment extends BaseMVPFragment<FragmentHomeLayoutBinding, Hom
         }
         mViewBinding.clLive.setVisibility(View.VISIBLE);
         GlideUtils.INSTANCE.loadImage(getContext(), recentCourses.avatar, mViewBinding.imLiveHeader, R.drawable.icon_student_default_head);
-        mViewBinding.tvLiveTitle.setText(recentCourses.courseGroupName+"即将开始");
+        mViewBinding.tvLiveTitle.setText(recentCourses.courseGroupName + "即将开始");
         String currentTime = TimeUtils.date2String(new Date(System.currentTimeMillis()), "yyyy-MM-dd");
         String startTime = TimeUtils.date2String(TimeUtils.getDate(recentCourses.courseStartTime), "yyyy-MM-dd");
         if (!TextUtils.isEmpty(recentCourses.courseStartTime) && TextUtils.equals(currentTime, startTime)) {

+ 35 - 0
student/src/main/java/com/cooleshow/student/widgets/HomeHotAlbumDecoration.java

@@ -0,0 +1,35 @@
+package com.cooleshow.student.widgets;
+
+import android.graphics.Rect;
+import android.view.View;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+/**
+ * Author by pq, Date on 2021/3/18 0018.
+ */
+public class HomeHotAlbumDecoration extends RecyclerView.ItemDecoration {
+
+    private int top;
+    private int left;
+    private int bottom;
+    private int right;
+    private int center;
+
+    public HomeHotAlbumDecoration(int top, int left, int bottom, int right, int center) {
+        this.top = top;
+        this.left = left;
+        this.bottom = bottom;
+        this.right = right;
+        this.center = center;
+    }
+
+    @Override
+    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
+        //每行都只有2个
+        int childLayoutPosition = parent.getChildLayoutPosition(view);
+        outRect.top = top;
+        outRect.bottom = bottom;
+        outRect.right = right;
+    }
+}

+ 1 - 2
student/src/main/res/layout/fragment_home_layout.xml

@@ -294,13 +294,12 @@
                         app:layout_constraintTop_toTopOf="@+id/tv_hot_album" />
 
                     <androidx.recyclerview.widget.RecyclerView
+                        android:layout_marginStart="14dp"
                         android:id="@+id/rv_hot_album"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_marginTop="12dp"
                         android:overScrollMode="never"
-                        android:paddingLeft="@dimen/dp_7"
-                        android:paddingRight="@dimen/dp_7"
                         android:scrollbars="none"
                         app:layout_constraintTop_toBottomOf="@+id/tv_hot_album" />
 

+ 0 - 2
student/src/main/res/layout/layout_home_hot_album_item.xml

@@ -9,8 +9,6 @@
         android:id="@+id/im_pic"
         android:layout_width="@dimen/dp_94"
         android:layout_height="@dimen/dp_94"
-        android:layout_marginLeft="@dimen/dp_7"
-        android:layout_marginRight="@dimen/dp_7"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintTop_toTopOf="parent" />