Quellcode durchsuchen

修改机构端曲目首页滚动效果

Pq vor 1 Jahr
Ursprung
Commit
51b00cff99

+ 7 - 0
institution/src/main/java/com/cooleshow/institution/stu/ui/main/HomeMusicFragment.java

@@ -47,6 +47,7 @@ import java.util.List;
 import androidx.annotation.NonNull;
 import androidx.lifecycle.ViewModelProviders;
 import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.LinearSnapHelper;
 
 /**
  * Author by pq, Date on 2023/9/12.
@@ -111,6 +112,8 @@ public class HomeMusicFragment extends BaseMVPFragment<FgHomeMusicLayoutBinding,
         LinearLayoutManager recommendMusicSheetManager = new LinearLayoutManager(getContext());
         recommendMusicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
         mRecommendAdapter = new HomeHotMusicSheetAdapter();
+        LinearSnapHelper recommendlinearSnapHelper = new LinearSnapHelper();
+        recommendlinearSnapHelper.attachToRecyclerView(mViewBinding.rvRecommendTrack);
         HomeHotMusicSheetItemDecoration itemDecoration1 = new HomeHotMusicSheetItemDecoration(0, SizeUtils.dp2px(12), 0, SizeUtils.dp2px(12), 0);
         mViewBinding.rvRecommendTrack.addItemDecoration(itemDecoration1);
         mViewBinding.rvRecommendTrack.setLayoutManager(recommendMusicSheetManager);
@@ -120,6 +123,8 @@ public class HomeMusicFragment extends BaseMVPFragment<FgHomeMusicLayoutBinding,
         LinearLayoutManager latestMusicSheetManager = new LinearLayoutManager(getContext());
         latestMusicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
         mLatestAdapter = new HomeHotMusicSheetAdapter();
+        LinearSnapHelper lastTrackSnapHelper = new LinearSnapHelper();
+        lastTrackSnapHelper.attachToRecyclerView(mViewBinding.rvLatestTrack);
         HomeHotMusicSheetItemDecoration itemDecoration2 = new HomeHotMusicSheetItemDecoration(0, SizeUtils.dp2px(12), 0, SizeUtils.dp2px(12), 0);
         mViewBinding.rvLatestTrack.addItemDecoration(itemDecoration2);
         mViewBinding.rvLatestTrack.setLayoutManager(latestMusicSheetManager);
@@ -130,6 +135,8 @@ public class HomeMusicFragment extends BaseMVPFragment<FgHomeMusicLayoutBinding,
         LinearLayoutManager musicSheetManager = new LinearLayoutManager(getContext());
         musicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
         mHomeHotMusicSheetAdapter = new HomeHotMusicSheetAdapter();
+        LinearSnapHelper hotSnapHelper = new LinearSnapHelper();
+        hotSnapHelper.attachToRecyclerView(mViewBinding.rvHotTrack);
         HomeHotMusicSheetItemDecoration itemDecoration = new HomeHotMusicSheetItemDecoration(0, 0, 0, SizeUtils.dp2px(12), 0);
         mViewBinding.rvHotTrack.addItemDecoration(itemDecoration);
         mViewBinding.rvHotTrack.setLayoutManager(musicSheetManager);