Forráskód Böngészése

增加学生端首页精品曲目

Pq 2 éve
szülő
commit
f893ff40d6

BIN
BaseLibrary/src/main/res/drawable-xhdpi/icon_home_good_music_sheet_tag.png


BIN
BaseLibrary/src/main/res/drawable-xxhdpi/icon_home_good_music_sheet_tag.png


+ 7 - 0
BaseLibrary/src/main/res/drawable/shape_home_good_music_sheet_bg.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <gradient android:startColor="@color/color_fff4ec"
+        android:angle="215"
+        android:endColor="@color/color_fffdfb"/>
+    <corners android:radius="10dp"/>
+</shape>

+ 2 - 0
BaseLibrary/src/main/res/values/colors.xml

@@ -139,6 +139,8 @@
     <color name="color_def2ff">#DEF2FF</color>
     <color name="color_def2ff">#DEF2FF</color>
     <color name="color_ecfffc">#ecfffc</color>
     <color name="color_ecfffc">#ecfffc</color>
     <color name="color_b4fff3">#B4FFF3</color>
     <color name="color_b4fff3">#B4FFF3</color>
+    <color name="color_fff4ec">#fff4ec</color>
+    <color name="color_fffdfb">#FFFDFB</color>
 
 
     <color name="color_25292e">#25292E</color>
     <color name="color_25292e">#25292E</color>
     <color name="color_F8F8F8">#F8F8F8</color>
     <color name="color_F8F8F8">#F8F8F8</color>

+ 52 - 0
student/src/main/java/com/cooleshow/student/adapter/HomeGoodMusicSheetAdapter.java

@@ -0,0 +1,52 @@
+package com.cooleshow.student.adapter;
+
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.viewholder.BaseViewHolder;
+import com.cooleshow.base.utils.ScreenUtils;
+import com.cooleshow.student.R;
+import com.cooleshow.student.bean.HomeHotMusicSheetBean;
+import com.cooleshow.student.bean.HomeHotMusicSheetItemBean;
+import com.cooleshow.student.ui.main.NewHomeFragment;
+import com.cooleshow.student.widgets.HomeHotMusicSheetItemView;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2022/8/8.
+ */
+public class HomeGoodMusicSheetAdapter extends BaseQuickAdapter<HomeHotMusicSheetItemBean, BaseViewHolder> {
+    private int maxWidth = 0;
+
+    public HomeGoodMusicSheetAdapter() {
+        super(R.layout.item_home_good_music_sheet_layout);
+        int screenWidth = ScreenUtils.getScreenWidth();
+        maxWidth = (int) (screenWidth * 0.83);
+    }
+
+    @Override
+    protected void convert(@NonNull BaseViewHolder holder, HomeHotMusicSheetItemBean homeHotMusicSheetItemBean) {
+        LinearLayout ll_container = holder.getView(R.id.ll_container);
+        ViewGroup.LayoutParams layoutParams = ll_container.getLayoutParams();
+        layoutParams.width = maxWidth;
+        ll_container.setLayoutParams(layoutParams);
+        ll_container.removeAllViews();
+        if (homeHotMusicSheetItemBean.sheetBeans != null && homeHotMusicSheetItemBean.sheetBeans.size() > 0) {
+            for (int i = 0; i < homeHotMusicSheetItemBean.sheetBeans.size(); i++) {
+                HomeHotMusicSheetBean.RowsBean homeHotMusicSheetBean = homeHotMusicSheetItemBean.sheetBeans.get(i);
+                HomeHotMusicSheetItemView hotMusicSheetItemView = new HomeHotMusicSheetItemView(getContext());
+                hotMusicSheetItemView.setIsGood(true);
+                hotMusicSheetItemView.setData(homeHotMusicSheetBean);
+                int result = i % (NewHomeFragment.MAX_HOT_MUSIC_LIST_PAGE - 1);
+                if (i == homeHotMusicSheetItemBean.sheetBeans.size() - 1 && result == 0) {
+                    hotMusicSheetItemView.setDividingLineIsShow(false);
+                } else {
+                    hotMusicSheetItemView.setDividingLineIsShow(true);
+                }
+                ll_container.addView(hotMusicSheetItemView);
+            }
+        }
+    }
+}

+ 2 - 0
student/src/main/java/com/cooleshow/student/contract/HomeContract.java

@@ -40,6 +40,8 @@ public interface HomeContract {
 
 
         void getHotMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean);
         void getHotMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean);
 
 
+        void getGoodMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean);
+
         void getRecommendTalentSuccess(ArrayList<RecommendTalentListBean> talentListBeans);
         void getRecommendTalentSuccess(ArrayList<RecommendTalentListBean> talentListBeans);
 
 
         void getHotNewsSuccess(int page, HomeHotNewsBean homeHotNewsBean);
         void getHotNewsSuccess(int page, HomeHotNewsBean homeHotNewsBean);

+ 24 - 0
student/src/main/java/com/cooleshow/student/presenter/main/HomePresenter.java

@@ -386,6 +386,30 @@ public class HomePresenter extends BasePresenter<HomeContract.HomeView> implemen
     }
     }
 
 
     /**
     /**
+     * 获取热门曲目
+     */
+    public void getGoodMusicSheetList() {
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.putOpt("myself", false);
+            jsonObject.putOpt("exquisiteFlag", "1");//精品标志(0:否;1:是)
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        addSubscribe(create(APIService.class).getHotMusicSheetList(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString())), new BaseObserver<HomeHotMusicSheetBean>(getView()) {
+            @Override
+            protected void onSuccess(HomeHotMusicSheetBean data) {
+                if (null != getView()) {
+                    getView().getGoodMusicSheetListSuccess(data);
+                }
+            }
+        });
+    }
+
+    /**
      * 获取推荐达人列表
      * 获取推荐达人列表
      */
      */
     public void getRecommendTalentList() {
     public void getRecommendTalentList() {

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

@@ -627,6 +627,11 @@ public class HomeFragment extends BaseMVPFragment<FragmentHomeLayoutBinding, Hom
     }
     }
 
 
     @Override
     @Override
+    public void getGoodMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean) {
+
+    }
+
+    @Override
     public void getRecommendTalentSuccess(ArrayList<RecommendTalentListBean> talentListBeans) {
     public void getRecommendTalentSuccess(ArrayList<RecommendTalentListBean> talentListBeans) {
 
 
     }
     }

+ 48 - 0
student/src/main/java/com/cooleshow/student/ui/main/NewHomeFragment.java

@@ -25,6 +25,7 @@ import com.cooleshow.base.utils.helper.WebStartHelper;
 import com.cooleshow.base.widgets.CommonItemDecoration;
 import com.cooleshow.base.widgets.CommonItemDecoration;
 import com.cooleshow.student.R;
 import com.cooleshow.student.R;
 import com.cooleshow.student.adapter.HomeBottomPageAdapter;
 import com.cooleshow.student.adapter.HomeBottomPageAdapter;
+import com.cooleshow.student.adapter.HomeGoodMusicSheetAdapter;
 import com.cooleshow.student.adapter.HomeHotAlbumAdapter;
 import com.cooleshow.student.adapter.HomeHotAlbumAdapter;
 import com.cooleshow.student.adapter.HomeHotMusicSheetAdapter;
 import com.cooleshow.student.adapter.HomeHotMusicSheetAdapter;
 import com.cooleshow.student.adapter.HomeMenuPagerAdapter;
 import com.cooleshow.student.adapter.HomeMenuPagerAdapter;
@@ -82,6 +83,7 @@ import static com.cooleshow.student.constants.CourseConstants.PIANO_ROOM_COURSE;
  */
  */
 public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBinding, HomePresenter> implements HomeContract.HomeView, View.OnClickListener, TalentStyleFragment.OnEventListener, HotNewsFragment.OnEventListener {
 public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBinding, HomePresenter> implements HomeContract.HomeView, View.OnClickListener, TalentStyleFragment.OnEventListener, HotNewsFragment.OnEventListener {
     public static final int MAX_HOT_MUSIC_LIST_PAGE = 3;//热门曲目一页最大条数
     public static final int MAX_HOT_MUSIC_LIST_PAGE = 3;//热门曲目一页最大条数
+    public static final int MAX_GOOD_MUSIC_LIST_PAGE = 3;//精品曲目一页最大条数
     private Banner banner;
     private Banner banner;
     private SmartRefreshLayout refreshLayout;
     private SmartRefreshLayout refreshLayout;
     private ArrayList<AppHomeBean.ItemBean> itemBeans = new ArrayList<>();
     private ArrayList<AppHomeBean.ItemBean> itemBeans = new ArrayList<>();
@@ -106,6 +108,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             switchTabStyle(position);
             switchTabStyle(position);
         }
         }
     };
     };
+    private HomeGoodMusicSheetAdapter mGoodMusicSheetAdapter;
 
 
     @Override
     @Override
     protected FragmentNewHomeLayoutBinding getLayoutView() {
     protected FragmentNewHomeLayoutBinding getLayoutView() {
@@ -147,6 +150,16 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         mViewBinding.rvHotAlbum.addItemDecoration(hotAlbumItemDecoration);
         mViewBinding.rvHotAlbum.addItemDecoration(hotAlbumItemDecoration);
         mViewBinding.rvHotAlbum.setAdapter(mAlbumAdapter);
         mViewBinding.rvHotAlbum.setAdapter(mAlbumAdapter);
 
 
+        //精品曲目
+        LinearLayoutManager goodMusicSheetManager = new LinearLayoutManager(getContext());
+        goodMusicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
+        mGoodMusicSheetAdapter = new HomeGoodMusicSheetAdapter();
+        HomeHotMusicSheetItemDecoration goodMusicSheetItemDecoration = new HomeHotMusicSheetItemDecoration(0, 0, 0, SizeUtils.dp2px(12), 0);
+        mViewBinding.rvGoodTrack.addItemDecoration(goodMusicSheetItemDecoration);
+        mViewBinding.rvGoodTrack.setLayoutManager(goodMusicSheetManager);
+        mViewBinding.rvGoodTrack.setAdapter(mGoodMusicSheetAdapter);
+
+
         //热门曲目
         //热门曲目
         LinearLayoutManager musicSheetManager = new LinearLayoutManager(getContext());
         LinearLayoutManager musicSheetManager = new LinearLayoutManager(getContext());
         musicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
         musicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
@@ -260,6 +273,8 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             presenter.appHome();
             presenter.appHome();
             presenter.userAccountPage();
             presenter.userAccountPage();
             presenter.getHotMusicSheetList();
             presenter.getHotMusicSheetList();
+            //获取精品曲目
+            presenter.getGoodMusicSheetList();
             presenter.getRecommendTalentList();
             presenter.getRecommendTalentList();
             refreshBottomData();
             refreshBottomData();
         });
         });
@@ -384,6 +399,8 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             presenter.userAccountPage();
             presenter.userAccountPage();
             //获取热门曲目
             //获取热门曲目
             presenter.getHotMusicSheetList();
             presenter.getHotMusicSheetList();
+            //获取精品曲目
+            presenter.getGoodMusicSheetList();
         }
         }
     }
     }
 
 
@@ -644,6 +661,37 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
     }
     }
 
 
     @Override
     @Override
+    public void getGoodMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean) {
+        if (isDetached() || homeHotMusicSheetBean == null) {
+            return;
+        }
+        ArrayList<HomeHotMusicSheetItemBean> itemBeans = new ArrayList<>();
+        List<HomeHotMusicSheetBean.RowsBean> rows = homeHotMusicSheetBean.rows;
+        if (rows != null && rows.size() > 0) {
+            mViewBinding.clGoodTrack.setVisibility(View.VISIBLE);
+            int pageCount = 0;
+            int pageResult = rows.size() % MAX_GOOD_MUSIC_LIST_PAGE;
+            if (pageResult == 0) {
+                pageCount = rows.size() / MAX_GOOD_MUSIC_LIST_PAGE;
+            } else {
+                pageCount = (rows.size() / MAX_GOOD_MUSIC_LIST_PAGE) + 1;
+            }
+            for (int i = 0; i < pageCount; i++) {
+                HomeHotMusicSheetItemBean hotMusicSheetItemBean = new HomeHotMusicSheetItemBean();
+                for (int k = i * MAX_GOOD_MUSIC_LIST_PAGE; k < rows.size() && k < (i + 1) * MAX_GOOD_MUSIC_LIST_PAGE; k++) {
+                    hotMusicSheetItemBean.sheetBeans.add(rows.get(k));
+                }
+                itemBeans.add(hotMusicSheetItemBean);
+            }
+            if (mGoodMusicSheetAdapter != null) {
+                mGoodMusicSheetAdapter.setNewInstance(itemBeans);
+            }
+        } else {
+            mViewBinding.clGoodTrack.setVisibility(View.GONE);
+        }
+    }
+
+    @Override
     public void getRecommendTalentSuccess(ArrayList<RecommendTalentListBean> talentListBeans) {
     public void getRecommendTalentSuccess(ArrayList<RecommendTalentListBean> talentListBeans) {
         if (isDetached()) {
         if (isDetached()) {
             return;
             return;

+ 14 - 0
student/src/main/java/com/cooleshow/student/widgets/HomeHotMusicSheetItemView.java

@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
 import android.widget.FrameLayout;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.TextView;
 
 
@@ -35,6 +36,8 @@ public class HomeHotMusicSheetItemView extends FrameLayout {
     private LinearLayout mLlMusicSubject;
     private LinearLayout mLlMusicSubject;
     private View mViewLine;
     private View mViewLine;
     private HomeHotMusicSheetBean.RowsBean mBean;
     private HomeHotMusicSheetBean.RowsBean mBean;
+    private boolean isGood = false;//是否是精品曲目
+    private ImageView mIvGoodTag;
 
 
     public HomeHotMusicSheetItemView(@NonNull Context context) {
     public HomeHotMusicSheetItemView(@NonNull Context context) {
         this(context, null);
         this(context, null);
@@ -52,6 +55,7 @@ public class HomeHotMusicSheetItemView extends FrameLayout {
     private void init() {
     private void init() {
         LayoutInflater.from(getContext()).inflate(R.layout.view_hot_music_sheet_child_layout, this);
         LayoutInflater.from(getContext()).inflate(R.layout.view_hot_music_sheet_child_layout, this);
         mTvTag = findViewById(R.id.tv_tag);
         mTvTag = findViewById(R.id.tv_tag);
+        mIvGoodTag = findViewById(R.id.iv_good_tag);
         mTvName = findViewById(R.id.tv_name);
         mTvName = findViewById(R.id.tv_name);
         mTvAuthor = findViewById(R.id.tv_author);
         mTvAuthor = findViewById(R.id.tv_author);
         mTvUploadAuthor = findViewById(R.id.tv_upload_author);
         mTvUploadAuthor = findViewById(R.id.tv_upload_author);
@@ -77,6 +81,16 @@ public class HomeHotMusicSheetItemView extends FrameLayout {
 
 
     }
     }
 
 
+    /**
+     * 设置是否是精品
+     */
+    public void setIsGood(boolean isGood) {
+        this.isGood = isGood;
+        if (mIvGoodTag != null) {
+            mIvGoodTag.setVisibility(isGood ? View.VISIBLE : View.GONE);
+        }
+    }
+
     public void setData(HomeHotMusicSheetBean.RowsBean data) {
     public void setData(HomeHotMusicSheetBean.RowsBean data) {
         this.mBean = data;
         this.mBean = data;
         //曲谱名称
         //曲谱名称

BIN
student/src/main/res/drawable-xhdpi/icon_music_sheet_play.png


BIN
student/src/main/res/drawable-xxhdpi/icon_music_sheet_play.png


+ 64 - 1
student/src/main/res/layout/fragment_new_home_layout.xml

@@ -460,7 +460,7 @@
 
 
 
 
                         <androidx.constraintlayout.widget.ConstraintLayout
                         <androidx.constraintlayout.widget.ConstraintLayout
-                            android:id="@+id/cl_hot_track"
+                            android:id="@+id/cl_good_track"
                             android:layout_width="match_parent"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:layout_height="wrap_content"
                             android:layout_marginTop="@dimen/dp_30"
                             android:layout_marginTop="@dimen/dp_30"
@@ -468,6 +468,69 @@
                             app:layout_constraintTop_toBottomOf="@+id/cl_hot_album">
                             app:layout_constraintTop_toBottomOf="@+id/cl_hot_album">
 
 
                             <View
                             <View
+                                android:id="@+id/tv_good_track_line"
+                                android:layout_width="4dp"
+                                android:layout_height="17dp"
+                                android:layout_marginStart="14dp"
+                                android:background="@drawable/shape_course_title_tag_bg"
+                                app:layout_constraintBottom_toBottomOf="@+id/tv_good_track"
+                                app:layout_constraintLeft_toLeftOf="parent"
+                                app:layout_constraintTop_toTopOf="@+id/tv_good_track" />
+
+                            <TextView
+                                android:id="@+id/tv_good_track"
+                                android:layout_width="wrap_content"
+                                android:layout_height="wrap_content"
+                                android:layout_marginLeft="@dimen/dp_6"
+                                android:gravity="center"
+                                android:text="精品曲目"
+                                android:textColor="@color/color_333333"
+                                android:textSize="@dimen/sp_18"
+                                android:textStyle="bold"
+                                app:layout_constraintLeft_toRightOf="@+id/tv_good_track_line"
+                                app:layout_constraintTop_toTopOf="parent" />
+
+                            <TextView
+                                android:id="@+id/tv_good_track_more"
+                                android:layout_width="wrap_content"
+                                android:layout_height="wrap_content"
+                                android:layout_marginRight="@dimen/dp_14"
+                                android:background="@drawable/shape_f2f2f2_9dp"
+                                android:drawableEnd="@drawable/icon_next_right"
+                                android:drawablePadding="1dp"
+                                android:gravity="center"
+                                android:paddingStart="7dp"
+                                android:paddingTop="2dp"
+                                android:paddingEnd="3dp"
+                                android:paddingBottom="2dp"
+                                android:text="更多"
+                                android:textColor="@color/color_999999"
+                                android:textSize="@dimen/sp_12"
+                                app:layout_constraintBottom_toBottomOf="@+id/tv_good_track"
+                                app:layout_constraintRight_toRightOf="parent"
+                                app:layout_constraintTop_toTopOf="@+id/tv_good_track" />
+
+                            <androidx.recyclerview.widget.RecyclerView
+                                android:id="@+id/rv_good_track"
+                                android:layout_width="match_parent"
+                                android:layout_height="239dp"
+                                android:layout_marginTop="12dp"
+                                android:overScrollMode="never"
+                                android:paddingLeft="@dimen/dp_14"
+                                android:scrollbars="none"
+                                app:layout_constraintTop_toBottomOf="@+id/tv_good_track" />
+
+                        </androidx.constraintlayout.widget.ConstraintLayout>
+
+                        <androidx.constraintlayout.widget.ConstraintLayout
+                            android:id="@+id/cl_hot_track"
+                            android:layout_width="match_parent"
+                            android:layout_height="wrap_content"
+                            android:layout_marginTop="@dimen/dp_30"
+                            android:visibility="gone"
+                            app:layout_constraintTop_toBottomOf="@+id/cl_good_track">
+
+                            <View
                                 android:id="@+id/tv_hot_track_line"
                                 android:id="@+id/tv_hot_track_line"
                                 android:layout_width="4dp"
                                 android:layout_width="4dp"
                                 android:layout_height="17dp"
                                 android:layout_height="17dp"

+ 9 - 0
student/src/main/res/layout/item_home_good_music_sheet_layout.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/ll_container"
+    android:layout_width="312dp"
+    android:layout_height="match_parent"
+    android:background="@drawable/shape_home_good_music_sheet_bg"
+    android:orientation="vertical">
+
+</LinearLayout>

+ 12 - 1
student/src/main/res/layout/view_hot_music_sheet_child_layout.xml

@@ -20,6 +20,17 @@
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
         app:layout_constraintTop_toTopOf="parent" />
 
 
+    <ImageView
+        android:visibility="gone"
+        android:id="@+id/iv_good_tag"
+        android:layout_marginStart="5dp"
+        app:layout_constraintLeft_toRightOf="@+id/tv_tag"
+        app:layout_constraintBottom_toBottomOf="@+id/tv_tag"
+        app:layout_constraintTop_toTopOf="@+id/tv_tag"
+        android:src="@drawable/icon_home_good_music_sheet_tag"
+        android:layout_width="14dp"
+        android:layout_height="17dp"/>
+
     <TextView
     <TextView
         android:id="@+id/tv_name"
         android:id="@+id/tv_name"
         android:layout_width="wrap_content"
         android:layout_width="wrap_content"
@@ -32,7 +43,7 @@
         android:textColor="@color/color_1a1a1a"
         android:textColor="@color/color_1a1a1a"
         android:textSize="@dimen/sp_16"
         android:textSize="@dimen/sp_16"
         app:layout_constraintBottom_toBottomOf="@+id/tv_tag"
         app:layout_constraintBottom_toBottomOf="@+id/tv_tag"
-        app:layout_constraintLeft_toRightOf="@+id/tv_tag"
+        app:layout_constraintLeft_toRightOf="@+id/iv_good_tag"
         app:layout_constraintRight_toLeftOf="@+id/tv_author"
         app:layout_constraintRight_toLeftOf="@+id/tv_author"
         app:layout_constraintTop_toTopOf="@+id/tv_tag"
         app:layout_constraintTop_toTopOf="@+id/tv_tag"
         tools:text="维瓦尔第 E第一维瓦尔第维瓦尔第维瓦尔第" />
         tools:text="维瓦尔第 E第一维瓦尔第维瓦尔第维瓦尔第" />