Explorar el Código

增加我的曲谱搜索功能部分交互

Pq hace 2 años
padre
commit
15bfdf4086

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

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <solid android:color="@color/white" />
+    <corners
+        android:radius="13dp" />
+</shape>

+ 6 - 0
BaseLibrary/src/main/res/drawable/shape_f8f8f8_14dp_border_1dp.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="@color/color_F8F8F8"/>
+    <corners android:radius="14dp"/>
+    <stroke android:color="@color/color_f0f0f0" android:width="1dp"/>
+</shape>

+ 18 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/homepage/SheetMusicPageFragment.java

@@ -11,6 +11,7 @@ import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.constanst.Constants;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
+import com.cooleshow.base.utils.KeyboardUtils;
 import com.cooleshow.base.utils.helper.WebStartHelper;
 import com.cooleshow.base.widgets.EmptyViewLayout;
 import com.cooleshow.base.widgets.poplist.PopMenuBean;
@@ -89,6 +90,14 @@ public class SheetMusicPageFragment extends BaseMVPFragment<FragmentSheetMusicPa
                 }
             }
         });
+        KeyboardUtils.registerSoftInputChangedListener(this.getActivity(), new KeyboardUtils.OnSoftInputChangedListener() {
+            @Override
+            public void onSoftInputChanged(int height) {
+                if (height == 0) {
+                    mViewBinding.searchView.clearEditFocus();
+                }
+            }
+        });
     }
 
     @Override
@@ -108,6 +117,7 @@ public class SheetMusicPageFragment extends BaseMVPFragment<FragmentSheetMusicPa
                 selectVocalPart();
             });
             mViewBinding.searchView.setOnSearchListener(v -> {
+                mViewBinding.searchView.clearEditFocus();
                 musicSearch();
             });
             queryList(true);
@@ -284,4 +294,12 @@ public class SheetMusicPageFragment extends BaseMVPFragment<FragmentSheetMusicPa
             return;
         }
     }
+
+    @Override
+    public void onDestroy() {
+        if (getActivity() != null) {
+            KeyboardUtils.unregisterSoftInputChangedListener(this.getActivity().getWindow());
+        }
+        super.onDestroy();
+    }
 }

+ 12 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/score/MineScoreActivity.java

@@ -17,6 +17,8 @@ import com.alibaba.android.arouter.launcher.ARouter;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
 import com.cooleshow.base.utils.FileUtils;
+import com.cooleshow.base.utils.KeyboardUtils;
+import com.cooleshow.base.utils.SoftKeyboardUtils;
 import com.cooleshow.base.utils.ToastUtil;
 import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.Utils;
@@ -108,6 +110,7 @@ public class MineScoreActivity extends BaseMVPActivity<ActivityMineScoreBinding,
         viewBinding.searchView.setOnSearchListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                viewBinding.searchView.clearEditFocus();
                 String target = viewBinding.searchView.getSearchEdit().getText().toString().trim();
                 currentSearchStr = target;
                 updateByFilter();
@@ -117,6 +120,14 @@ public class MineScoreActivity extends BaseMVPActivity<ActivityMineScoreBinding,
         viewBinding.searchView.setOnLeftClickListener(v -> {
             selectVocalPart();
         });
+        KeyboardUtils.registerSoftInputChangedListener(this, new KeyboardUtils.OnSoftInputChangedListener() {
+            @Override
+            public void onSoftInputChanged(int height) {
+                if (height == 0) {
+                    viewBinding.searchView.clearEditFocus();
+                }
+            }
+        });
     }
 
     @Override
@@ -355,5 +366,6 @@ public class MineScoreActivity extends BaseMVPActivity<ActivityMineScoreBinding,
     public void onDestroy() {
         super.onDestroy();
         UMShareAPI.get(MineScoreActivity.this).release();
+        KeyboardUtils.unregisterSoftInputChangedListener(this.getWindow());
     }
 }

+ 28 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/CourseSearchView.java

@@ -6,11 +6,13 @@ import android.util.AttributeSet;
 import android.view.View;
 import android.widget.EditText;
 import android.widget.FrameLayout;
+import android.widget.ImageView;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
+import com.cooleshow.base.utils.SoftKeyboardUtils;
 import com.cooleshow.teacher.R;
 
 /**
@@ -26,6 +28,8 @@ public class CourseSearchView extends FrameLayout {
     private String mLeftSearchText;
     private String mSearchHintText;
     private String mSearchBtnText;
+    private View mViewSubjectBg;
+    private ImageView mIvArrowDown;
 
     public CourseSearchView(@NonNull Context context) {
         this(context, null);
@@ -51,10 +55,28 @@ public class CourseSearchView extends FrameLayout {
         mTvAgency = view.findViewById(R.id.tv_agency);
         mSearchEdit = view.findViewById(R.id.search_edit);
         mSearchBtn = view.findViewById(R.id.search_btn);
+        mViewSubjectBg = view.findViewById(R.id.view_subject);
+        mIvArrowDown = view.findViewById(R.id.iv_arrow_down);
 
         setLeftText(mLeftSearchText);
         setSearchHint(mSearchHintText);
         setBtnText(mSearchBtnText);
+        mSearchEdit.setOnFocusChangeListener(new OnFocusChangeListener() {
+            @Override
+            public void onFocusChange(View v, boolean hasFocus) {
+                if(hasFocus){
+                    switchSubjectUI(false);
+                }else{
+                    switchSubjectUI(true);
+                }
+            }
+        });
+    }
+
+    private void switchSubjectUI(boolean isShow) {
+        mTvAgency.setVisibility(isShow ? View.VISIBLE : View.GONE);
+        mViewSubjectBg.setVisibility(isShow ? View.VISIBLE : View.GONE);
+        mIvArrowDown.setVisibility(isShow ? View.VISIBLE : View.GONE);
     }
 
     public void setLeftText(String text) {
@@ -85,6 +107,12 @@ public class CourseSearchView extends FrameLayout {
         mSearchBtn.setOnClickListener(listener);
     }
 
+    public void clearEditFocus(){
+        if (mSearchEdit != null) {
+            mSearchEdit.clearFocus();
+        }
+    }
+
     public void setOnLeftClickListener(View.OnClickListener listener) {
         mTvAgency.setOnClickListener(listener);
     }

+ 1 - 1
teacher/src/main/res/layout/activity_mine_score.xml

@@ -31,7 +31,7 @@
         android:layout_marginTop="10dp"
         app:layout_constraintTop_toBottomOf="@+id/toolbar_include"
         app:left_search_text="声部"
-        app:search_edit_hint="请输入曲目名称" />
+        app:search_edit_hint="曲目" />
 
     <com.google.android.material.tabs.TabLayout
         android:id="@+id/tablayout"

+ 44 - 20
teacher/src/main/res/layout/course_search_view.xml

@@ -5,33 +5,57 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
 
+    <View
+        android:layout_marginStart="14dp"
+        app:layout_constraintBottom_toBottomOf="@+id/search_view"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toLeftOf="@+id/search_view"
+        app:layout_constraintTop_toTopOf="@+id/search_view"
+        android:gravity="center"
+        android:background="@drawable/shape_f8f8f8_14dp_border_1dp"
+        android:id="@+id/view_subject"
+        android:layout_width="82dp"
+        android:layout_height="28dp"/>
+
     <TextView
+        app:layout_constraintRight_toLeftOf="@+id/iv_arrow_down"
+        app:layout_constraintBottom_toBottomOf="@+id/view_subject"
+        app:layout_constraintTop_toTopOf="@+id/view_subject"
+        app:layout_constraintLeft_toLeftOf="@+id/view_subject"
         android:id="@+id/tv_agency"
-        android:layout_width="wrap_content"
-        android:layout_height="0dp"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
         android:layout_marginLeft="@dimen/dp_14"
-        android:drawableRight="@drawable/icon_arrow_down"
-        android:drawablePadding="6dp"
         android:ellipsize="end"
         android:gravity="center"
         android:includeFontPadding="false"
         android:maxLines="1"
         android:text="声部"
-        android:textColor="@color/color_666666"
+        android:layout_marginStart="10dp"
+        tools:text="声部声部声部声部"
+        android:textColor="@color/color_999999"
         android:textSize="@dimen/sp_14"
-        app:layout_constraintBottom_toBottomOf="@+id/search_view"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toLeftOf="@+id/search_view"
-        app:layout_constraintTop_toTopOf="@+id/search_view" />
+        />
+
+    <ImageView
+        android:layout_marginEnd="10dp"
+        app:layout_constraintBottom_toBottomOf="@+id/view_subject"
+        app:layout_constraintTop_toTopOf="@+id/view_subject"
+        app:layout_constraintRight_toRightOf="@+id/view_subject"
+        android:id="@+id/iv_arrow_down"
+        android:layout_width="8dp"
+        android:layout_height="wrap_content"
+        android:src="@drawable/icon_arrow_down"
+        app:tint="@color/color_2dc7aa" />
 
     <View
         android:id="@+id/search_view"
         android:layout_width="0dp"
-        android:layout_height="@dimen/dp_36"
+        android:layout_height="@dimen/dp_28"
+        android:layout_marginStart="10dp"
         android:layout_marginRight="@dimen/dp_14"
-        android:layout_marginStart="5dp"
-        android:background="@drawable/bg_white_18dp"
-        app:layout_constraintLeft_toRightOf="@+id/tv_agency"
+        android:background="@drawable/shape_f8f8f8_14dp_border_1dp"
+        app:layout_constraintLeft_toRightOf="@+id/view_subject"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
 
@@ -48,26 +72,26 @@
     <EditText
         android:id="@+id/search_edit"
         android:layout_width="0dp"
-        android:layout_height="@dimen/dp_36"
+        android:layout_height="@dimen/dp_28"
         android:background="@color/transparent"
         android:hint="请输入曲目名称"
         android:paddingLeft="@dimen/dp_41"
         android:textColor="@color/color_333333"
         android:textColorHint="@color/color_999999"
-        android:textSize="@dimen/sp_13"
+        android:textSize="@dimen/sp_14"
         app:layout_constraintLeft_toLeftOf="@+id/search_view"
         app:layout_constraintRight_toLeftOf="@+id/search_btn"
         app:layout_constraintTop_toTopOf="@+id/search_view" />
 
     <TextView
         android:id="@+id/search_btn"
-        android:layout_width="@dimen/dp_56"
-        android:layout_height="@dimen/dp_28"
+        android:layout_width="@dimen/dp_37"
+        android:layout_height="@dimen/dp_26"
         android:layout_marginRight="@dimen/dp_4"
-        android:background="@drawable/shape_click_btn"
+        android:background="@drawable/bg_white_13dp"
         android:gravity="center"
-        android:text="@string/search"
-        android:textColor="@color/white"
+        android:text=""
+        android:textColor="@color/color_2dc7aa"
         android:textSize="@dimen/sp_14"
         app:layout_constraintBottom_toBottomOf="@+id/search_view"
         app:layout_constraintRight_toRightOf="@id/search_view"

+ 1 - 1
teacher/src/main/res/layout/fragment_sheet_music_page_layout.xml

@@ -26,7 +26,7 @@
         app:layout_constraintBottom_toBottomOf="@+id/view_top_bg"
         app:layout_constraintTop_toTopOf="@+id/view_top_bg"
         app:left_search_text="声部"
-        app:search_edit_hint="请输入曲目名称" />
+        app:search_edit_hint="曲目" />
 
     <TextView
         android:id="@+id/tv_upload_sheet_music"