Browse Source

增加老师端首页精品曲目

Pq 2 years ago
parent
commit
bcc2214c23

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

@@ -0,0 +1,52 @@
+package com.cooleshow.teacher.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.teacher.R;
+import com.cooleshow.teacher.bean.HomeHotMusicSheetBean;
+import com.cooleshow.teacher.bean.HomeHotMusicSheetItemBean;
+import com.cooleshow.teacher.ui.main.NewHomeFragment;
+import com.cooleshow.teacher.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
teacher/src/main/java/com/cooleshow/teacher/contract/HomeContract.java

@@ -32,6 +32,8 @@ public interface HomeContract {
         void getHotAlbumListSuccess(HomeHotAlbumListBean homeHotAlbumListBean);
 
         void getHotMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean);
+
+        void getGoodMusicSheetListSuccess(HomeHotMusicSheetBean homeHotMusicSheetBean);
     }
 
     interface Presenter {

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

@@ -220,4 +220,28 @@ 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);
+                }
+            }
+        });
+    }
 }

+ 4 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/main/HomeFragment.kt

@@ -436,6 +436,10 @@ class HomeFragment : BaseMVPFragment<FragmentHomeLayoutBinding, HomePresenter>()
         TODO("Not yet implemented")
     }
 
+    override fun getGoodMusicSheetListSuccess(homeHotMusicSheetBean: HomeHotMusicSheetBean?) {
+        TODO("Not yet implemented")
+    }
+
     /**
      * 跳转直播课详情页面
      *

+ 53 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/main/NewHomeFragment.java

@@ -18,6 +18,7 @@ import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.utils.helper.WebStartHelper;
 import com.cooleshow.teacher.R;
+import com.cooleshow.teacher.adapter.HomeGoodMusicSheetAdapter;
 import com.cooleshow.teacher.adapter.HomeHotAlbumAdapter;
 import com.cooleshow.teacher.adapter.HomeHotMusicSheetAdapter;
 import com.cooleshow.teacher.adapter.HomeMenuPageAdapter;
@@ -62,6 +63,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
  * Author by pq, Date on 2022/8/8.
  */
 public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBinding, HomePresenter> implements HomeContract.HomeView, View.OnClickListener {
+    public static final int MAX_HOT_MUSIC_LIST_PAGE = 4;//热门曲目一页最大条数
+    public static final int MAX_GOOD_MUSIC_LIST_PAGE = 4;//精品曲目一页最大条数
     public static final String STYLE_TYPE = "STYLE";
     public static final String VIDEON_TYPE = "VIDEO";
     public static final String LIVE_TYPE = "LIVE";
@@ -78,6 +81,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
     private int degreeFlag = 0;//老师学历认证
     private String entryStatus = "";//达人认证状态
     private SmartRefreshLayout refreshLayout;
+    private HomeGoodMusicSheetAdapter mGoodMusicSheetAdapter;
 
     @Override
     protected void initView(View rootView) {
@@ -96,6 +100,14 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         mViewBinding.rvHotAlbum.addItemDecoration(hotAlbumItemDecoration);
         mViewBinding.rvHotAlbum.setAdapter(mAlbumAdapter);
 
+        mGoodMusicSheetAdapter = new HomeGoodMusicSheetAdapter();
+        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
+        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
+        HomeHotMusicSheetItemDecoration itemDecoration2 = new HomeHotMusicSheetItemDecoration(0, SizeUtils.dp2px(12), 0, SizeUtils.dp2px(12), 0);
+        mViewBinding.rvGoodTrack.addItemDecoration(itemDecoration2);
+        mViewBinding.rvGoodTrack.setLayoutManager(layoutManager);
+        mViewBinding.rvGoodTrack.setAdapter(mGoodMusicSheetAdapter);
+
         LinearLayoutManager musicSheetManager = new LinearLayoutManager(getContext());
         musicSheetManager.setOrientation(LinearLayoutManager.HORIZONTAL);
         mHomeHotMusicSheetAdapter = new HomeHotMusicSheetAdapter();
@@ -139,10 +151,13 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         mViewBinding.bgAnnouncement2.setOnClickListener(this);
         mViewBinding.tvHotAlbumMore.setOnClickListener(this);
         mViewBinding.tvHotTrackMore.setOnClickListener(this);
+        mViewBinding.tvGoodTrackMore.setOnClickListener(this);
         mViewBinding.refreshLayout.setOnRefreshListener(refreshLayout -> {
             mViewBinding.refreshLayout.finishRefresh();
             presenter.getHotAlbumList();
             presenter.getHotMusicSheetList();
+            //精品曲目
+            presenter.getGoodMusicSheetList();
             presenter.queryCountOfUnread();
             presenter.queryLiveAndVideo();
             presenter.appHome();
@@ -190,6 +205,8 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             presenter.getHotAlbumList();
             //热门曲目
             presenter.getHotMusicSheetList();
+            //精品曲目
+            presenter.getGoodMusicSheetList();
         }
     }
 
@@ -424,6 +441,37 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         }
     }
 
+    @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);
+        }
+    }
+
 
     public void getTeacherInfoSuccess(TeacherUserInfo teacherUserInfo) {
         if (teacherUserInfo == null) {
@@ -591,6 +639,11 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             WebStartHelper.startHotMusicSheetList();
             return;
         }
+        if(id == R.id.tv_good_track_more){
+            //精品曲目更多
+            WebStartHelper.startGoodMusicSheetList();
+            return;
+        }
         if (id == R.id.view_badge) {
             showBadgeDialog();
             return;

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

@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
@@ -35,6 +36,8 @@ public class HomeHotMusicSheetItemView extends FrameLayout {
     private LinearLayout mLlMusicSubject;
     private View mViewLine;
     private HomeHotMusicSheetBean.RowsBean mBean;
+    private boolean isGood = false;//是否是精品曲目
+    private ImageView mIvGoodTag;
 
     public HomeHotMusicSheetItemView(@NonNull Context context) {
         this(context, null);
@@ -57,6 +60,7 @@ public class HomeHotMusicSheetItemView extends FrameLayout {
         mTvUploadAuthor = findViewById(R.id.tv_upload_author);
         mLlMusicSubject = findViewById(R.id.ll_music_subject);
         mViewLine = findViewById(R.id.view_line);
+        mIvGoodTag = findViewById(R.id.iv_good_tag);
         setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -133,6 +137,16 @@ public class HomeHotMusicSheetItemView extends FrameLayout {
         mLlMusicSubject.addView(textView, params);
     }
 
+    /**
+     * 设置是否是精品
+     */
+    public void setIsGood(boolean isGood) {
+        this.isGood = isGood;
+        if (mIvGoodTag != null) {
+            mIvGoodTag.setVisibility(isGood ? View.VISIBLE : View.GONE);
+        }
+    }
+
     public void setDividingLineIsShow(boolean isShow) {
         if (mViewLine != null) {
             mViewLine.setVisibility(isShow ? View.VISIBLE : View.INVISIBLE);

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


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


+ 63 - 1
teacher/src/main/res/layout/fragment_new_home_layout.xml

@@ -560,6 +560,68 @@
 
                 </androidx.constraintlayout.widget.ConstraintLayout>
 
+                <androidx.constraintlayout.widget.ConstraintLayout
+                    android:id="@+id/cl_good_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_hot_album">
+
+                    <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="wrap_content"
+                        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"
@@ -567,7 +629,7 @@
                     android:layout_height="wrap_content"
                     android:layout_marginTop="@dimen/dp_18"
                     android:visibility="visible"
-                    app:layout_constraintTop_toBottomOf="@+id/cl_hot_album">
+                    app:layout_constraintTop_toBottomOf="@+id/cl_good_track">
 
                     <View
                         android:id="@+id/tv_hot_track_line"

+ 9 - 0
teacher/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>

+ 13 - 1
teacher/src/main/res/layout/view_hot_music_sheet_child_layout.xml

@@ -19,6 +19,18 @@
         app:layout_constraintLeft_toLeftOf="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
         android:id="@+id/tv_name"
         android:layout_width="wrap_content"
@@ -31,7 +43,7 @@
         android:textColor="@color/color_1a1a1a"
         android:textSize="@dimen/sp_16"
         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_constraintTop_toTopOf="@+id/tv_tag"
         tools:text="维瓦尔第 E第一维瓦尔第维瓦尔第维瓦尔第" />