Explorar o código

修改老师端学生端首页推荐模块的更多按钮逻辑

Pq %!s(int64=2) %!d(string=hai) anos
pai
achega
eadf807f5a

+ 102 - 0
BaseLibrary/src/main/java/com/cooleshow/base/widgets/dialog/RecommendMoreMenuDialog.java

@@ -0,0 +1,102 @@
+package com.cooleshow.base.widgets.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+
+import com.cooleshow.base.R;
+import com.cooleshow.base.utils.ToastUtil;
+
+import java.util.ArrayList;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+
+/**
+ * Author by pq, Date on 2022/6/11.
+ */
+public class RecommendMoreMenuDialog extends Dialog implements View.OnClickListener {
+    private OnEventListener mEventListener;
+    private String[] titles = new String[]{"连麦中", "申请中"};
+
+
+    public RecommendMoreMenuDialog(@NonNull Context context) {
+        super(context, R.style.BottomDialogStyle);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialog_recommend_more_menu_layout);
+        Window window = getWindow();
+        //设置dialog在屏幕底部
+        window.setGravity(Gravity.BOTTOM);
+        //设置dialog弹出时的动画效果,从屏幕底部向上弹出
+        window.setWindowAnimations(com.cooleshow.base.R.style.BottomAnimation);
+        window.getDecorView().setPadding(0, 0, 0, 0);
+        //获得window窗口的属性
+        WindowManager.LayoutParams lp = window.getAttributes();
+        //设置窗口宽度为充满全屏
+        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
+        //设置窗口高度为包裹内容
+        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
+        lp.horizontalMargin = 0;
+        lp.verticalMargin = 0;
+        //将设置好的属性set回去
+        window.setAttributes(lp);
+
+        findViewById(R.id.tv_more).setOnClickListener(this);
+        findViewById(R.id.tv_reduce_recommend).setOnClickListener(this);
+        findViewById(R.id.tv_cancel).setOnClickListener(this);
+    }
+
+    private void initListener() {
+    }
+
+
+    @Override
+    public void onClick(View v) {
+        int id = v.getId();
+        if (id == R.id.tv_more) {
+            //更多
+            if (mEventListener != null) {
+                mEventListener.onClickMore();
+            }
+            dismiss();
+            return;
+        }
+        if (id == R.id.tv_reduce_recommend) {
+            //减少此类推送
+            ToastUtil.getInstance().showShort("我们将减少此类推送");
+            if (mEventListener != null) {
+                mEventListener.onReduceRecommend();
+            }
+            dismiss();
+            return;
+        }
+        if (id == R.id.tv_cancel) {
+            //取消
+            dismiss();
+            return;
+        }
+    }
+
+    public void setOnEventListener(OnEventListener listener) {
+        this.mEventListener = listener;
+    }
+
+    public interface OnEventListener {
+        void onClickMore();
+
+        void onReduceRecommend();
+    }
+}

BIN=BIN
BaseLibrary/src/main/res/drawable-xhdpi/icon_more_point.png


BIN=BIN
BaseLibrary/src/main/res/drawable-xxhdpi/icon_more_point.png


+ 55 - 0
BaseLibrary/src/main/res/layout/dialog_recommend_more_menu_layout.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:background="@color/white"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/tv_more"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:gravity="center"
+        android:text="更多"
+        android:textColor="@color/color_333333"
+        android:textSize="@dimen/sp_16"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:layout_marginStart="16dp"
+        android:layout_marginEnd="16dp"
+        android:background="@color/color_e2e2e2" />
+
+    <TextView
+        android:id="@+id/tv_reduce_recommend"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:gravity="center"
+        android:text="减少此类推送"
+        android:textColor="@color/color_333333"
+        android:textSize="@dimen/sp_16"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:layout_marginStart="16dp"
+        android:layout_marginEnd="16dp"
+        android:background="@color/color_e2e2e2" />
+
+    <TextView
+        android:id="@+id/tv_cancel"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:gravity="center"
+        android:text="取消"
+        android:textColor="@color/color_333333"
+        android:textSize="@dimen/sp_16"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+</LinearLayout>

+ 16 - 0
BaseLibrary/src/main/res/values/styles.xml

@@ -476,4 +476,20 @@
     <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
         <item name="elevation">0dp</item><!--去掉toolbar阴影-->
     </style>
+
+    <style name="BottomDialogStyle" parent="@android:style/Theme.Holo.Dialog">
+        <!-- 是否有边框 -->
+        <item name="android:windowFrame">@null</item>
+        <!--是否在悬浮Activity之上  -->
+        <item name="android:windowIsFloating">true</item>
+        <!-- 标题 -->
+        <item name="android:windowNoTitle">true</item>
+        <!--阴影  -->
+        <item name="android:windowIsTranslucent">true</item><!--半透明-->
+        <!--背景透明-->
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:backgroundDimAmount">0.6</item>
+        <!-- 还可以加入一些弹出和退出的动画 (lan)-->
+        <item name="android:windowAnimationStyle">@style/BottomAnimation</item>
+    </style>
 </resources>

+ 45 - 6
student/src/main/java/com/cooleshow/student/ui/main/NewHomeFragment.java

@@ -25,6 +25,7 @@ import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.utils.helper.WebStartHelper;
 import com.cooleshow.base.widgets.CommonItemDecoration;
 import com.cooleshow.base.widgets.dialog.AwardTipDialog;
+import com.cooleshow.base.widgets.dialog.RecommendMoreMenuDialog;
 import com.cooleshow.musictuner.MusicTunerActivity;
 import com.cooleshow.student.R;
 import com.cooleshow.student.adapter.HomeBottomPageAdapter;
@@ -840,11 +841,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             if (UiUtils.isFastClick()) {
                 return;
             }
-            //老师风采
-            ARouter.getInstance()
-                    .build(RouterPath.WebCenter.ACTIVITY_HTML)
-                    .withString(WebConstants.WEB_URL, WebConstants.STUDENT_TEACHER_ELEGANT)
-                    .navigation();
+            showRecommendTalentMenuDialog();
             return;
         }
         if (id == R.id.tv_hot_album_more) {
@@ -866,7 +863,13 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             WebStartHelper.startHotMusicSheetList();
             return;
         }
-        if (id == R.id.tv_recommend_track_more || id == R.id.tv_latest_track_more) {
+        if (id == R.id.tv_recommend_track_more) {
+            //推荐曲目 最新曲目更多
+            showRecommendMenuDialog();
+            return;
+        }
+
+        if (id == R.id.tv_latest_track_more) {
             //推荐曲目 最新曲目更多
             WebStartHelper.startHotMusicSheetList();
             return;
@@ -896,6 +899,42 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         }
     }
 
+    private void showRecommendTalentMenuDialog() {
+        RecommendMoreMenuDialog recommendMoreMenuDialog = new RecommendMoreMenuDialog(getContext());
+        recommendMoreMenuDialog.setOnEventListener(new RecommendMoreMenuDialog.OnEventListener() {
+            @Override
+            public void onClickMore() {
+                //老师风采
+                ARouter.getInstance()
+                        .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                        .withString(WebConstants.WEB_URL, WebConstants.STUDENT_TEACHER_ELEGANT)
+                        .navigation();
+            }
+
+            @Override
+            public void onReduceRecommend() {
+                mViewBinding.csRecommendTalent.setVisibility(View.GONE);
+            }
+        });
+        recommendMoreMenuDialog.show();
+    }
+
+    private void showRecommendMenuDialog() {
+        RecommendMoreMenuDialog recommendMoreMenuDialog = new RecommendMoreMenuDialog(getContext());
+        recommendMoreMenuDialog.setOnEventListener(new RecommendMoreMenuDialog.OnEventListener() {
+            @Override
+            public void onClickMore() {
+                WebStartHelper.startHotMusicSheetList();
+            }
+
+            @Override
+            public void onReduceRecommend() {
+                mViewBinding.clRecommendTrack.setVisibility(View.GONE);
+            }
+        });
+        recommendMoreMenuDialog.show();
+    }
+
     /**
      * 切换tab样式
      *

+ 7 - 24
student/src/main/res/layout/fragment_new_home_layout.xml

@@ -464,13 +464,14 @@
                             android:layout_height="wrap_content"
                             android:layout_marginTop="@dimen/dp_18"
                             android:visibility="gone"
+                            tools:visibility="visible"
                             app:layout_constraintTop_toBottomOf="@+id/cl_hot_album">
 
                             <View
                                 android:id="@+id/tv_recommend_track_line"
                                 android:layout_width="4dp"
                                 android:layout_height="17dp"
-                                android:layout_marginStart="25dp"
+                                android:layout_marginStart="14dp"
                                 android:background="@drawable/shape_course_title_tag_bg"
                                 app:layout_constraintBottom_toBottomOf="@+id/tv_recommend_track"
                                 app:layout_constraintLeft_toLeftOf="parent"
@@ -489,22 +490,13 @@
                                 app:layout_constraintLeft_toRightOf="@+id/tv_recommend_track_line"
                                 app:layout_constraintTop_toTopOf="parent" />
 
-                            <TextView
+                            <ImageView
                                 android:id="@+id/tv_recommend_track_more"
                                 android:layout_width="wrap_content"
                                 android:layout_height="wrap_content"
                                 android:layout_marginRight="@dimen/dp_14"
-                                android:background="@drawable/shape_1a2dc7aa_10dp"
-                                android:drawableEnd="@drawable/icon_arrow_right_green"
-                                android:drawablePadding="5dp"
                                 android:gravity="center"
-                                android:paddingStart="7dp"
-                                android:paddingTop="2dp"
-                                android:paddingEnd="5dp"
-                                android:paddingBottom="2dp"
-                                android:text="更多"
-                                android:textColor="@color/color_2dc7aa"
-                                android:textSize="@dimen/sp_12"
+                                android:src="@drawable/icon_more_point"
                                 app:layout_constraintBottom_toBottomOf="@+id/tv_recommend_track"
                                 app:layout_constraintRight_toRightOf="parent"
                                 app:layout_constraintTop_toTopOf="@+id/tv_recommend_track" />
@@ -534,7 +526,7 @@
                                 android:id="@+id/tv_latest_track_line"
                                 android:layout_width="4dp"
                                 android:layout_height="17dp"
-                                android:layout_marginStart="25dp"
+                                android:layout_marginStart="14dp"
                                 android:background="@drawable/shape_course_title_tag_bg"
                                 app:layout_constraintBottom_toBottomOf="@+id/tv_latest_track"
                                 app:layout_constraintLeft_toLeftOf="parent"
@@ -679,22 +671,13 @@
                                 app:layout_constraintLeft_toRightOf="@+id/tv_recommend_teacher_line"
                                 app:layout_constraintTop_toTopOf="parent" />
 
-                            <TextView
+                            <ImageView
                                 android:id="@+id/tv_recommend_teacher_more"
                                 android:layout_width="wrap_content"
                                 android:layout_height="wrap_content"
                                 android:layout_marginRight="@dimen/dp_14"
-                                android:background="@drawable/shape_1a2dc7aa_10dp"
-                                android:drawableEnd="@drawable/icon_arrow_right_green"
-                                android:drawablePadding="5dp"
+                                android:src="@drawable/icon_more_point"
                                 android:gravity="center"
-                                android:paddingStart="7dp"
-                                android:paddingTop="2dp"
-                                android:paddingEnd="5dp"
-                                android:paddingBottom="2dp"
-                                android:text="更多"
-                                android:textColor="@color/color_2dc7aa"
-                                android:textSize="@dimen/sp_12"
                                 app:layout_constraintBottom_toBottomOf="@+id/tv_recommend_teacher_title"
                                 app:layout_constraintRight_toRightOf="parent"
                                 app:layout_constraintTop_toTopOf="@+id/tv_recommend_teacher_title" />

+ 25 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/main/NewHomeFragment.java

@@ -19,6 +19,7 @@ import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.utils.helper.WebStartHelper;
 import com.cooleshow.base.widgets.dialog.AwardTipDialog;
+import com.cooleshow.base.widgets.dialog.RecommendMoreMenuDialog;
 import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.adapter.HomeGoodMusicSheetAdapter;
 import com.cooleshow.teacher.adapter.HomeHotAlbumAdapter;
@@ -683,7 +684,13 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
             WebStartHelper.startHotMusicSheetList();
             return;
         }
-        if (id == R.id.tv_recommend_track_more || id == R.id.tv_latest_track_more) {
+        if (id == R.id.tv_recommend_track_more) {
+            //推荐曲目 最新曲目更多
+            showRecommendMenuDialog();
+            return;
+        }
+
+        if (id == R.id.tv_latest_track_more) {
             //推荐曲目 最新曲目更多
             WebStartHelper.startHotMusicSheetList();
             return;
@@ -694,6 +701,23 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         }
     }
 
+    private void showRecommendMenuDialog() {
+        RecommendMoreMenuDialog recommendMoreMenuDialog = new RecommendMoreMenuDialog(getContext());
+        recommendMoreMenuDialog.setOnEventListener(new RecommendMoreMenuDialog.OnEventListener() {
+            @Override
+            public void onClickMore() {
+                WebStartHelper.startHotMusicSheetList();
+            }
+
+            @Override
+            public void onReduceRecommend() {
+                mViewBinding.clRecommendTrack.setVisibility(View.GONE);
+            }
+        });
+        recommendMoreMenuDialog.show();
+    }
+
+
     private void showCertTipDialog() {
         HomeCertTipDialog homeCertTipDialog = new HomeCertTipDialog(getContext());
         homeCertTipDialog.show();

+ 2 - 11
teacher/src/main/res/layout/fragment_new_home_layout.xml

@@ -596,22 +596,13 @@
                         app:layout_constraintLeft_toRightOf="@+id/tv_recommend_track_line"
                         app:layout_constraintTop_toTopOf="parent" />
 
-                    <TextView
+                    <ImageView
                         android:id="@+id/tv_recommend_track_more"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginRight="@dimen/dp_14"
-                        android:background="@drawable/shape_1a2dc7aa_10dp"
-                        android:drawableEnd="@drawable/icon_arrow_right_green"
                         android:drawablePadding="5dp"
-                        android:gravity="center"
-                        android:paddingStart="7dp"
-                        android:paddingTop="2dp"
-                        android:paddingEnd="5dp"
-                        android:paddingBottom="2dp"
-                        android:text="更多"
-                        android:textColor="@color/color_2dc7aa"
-                        android:textSize="@dimen/sp_12"
+                        android:src="@drawable/icon_more_point"
                         app:layout_constraintBottom_toBottomOf="@+id/tv_recommend_track"
                         app:layout_constraintRight_toRightOf="parent"
                         app:layout_constraintTop_toTopOf="@+id/tv_recommend_track" />