|  | @@ -3,8 +3,11 @@ package com.cooleshow.teacher.ui.main;
 | 
	
		
			
				|  |  |  import android.text.TextUtils;
 | 
	
		
			
				|  |  |  import android.view.Gravity;
 | 
	
		
			
				|  |  |  import android.view.View;
 | 
	
		
			
				|  |  | +import android.widget.TextView;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.android.arouter.launcher.ARouter;
 | 
	
		
			
				|  |  | +import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
 | 
	
		
			
				|  |  | +import com.bigkoo.pickerview.view.OptionsPickerView;
 | 
	
		
			
				|  |  |  import com.bumptech.glide.Glide;
 | 
	
		
			
				|  |  |  import com.chad.library.adapter.base.BaseQuickAdapter;
 | 
	
		
			
				|  |  |  import com.chad.library.adapter.base.listener.OnItemClickListener;
 | 
	
	
		
			
				|  | @@ -34,6 +37,8 @@ import com.cooleshow.teacher.bean.HomeHotMusicSheetBean;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.bean.HomeHotMusicSheetItemBean;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.bean.HomeLiveAndVideoBean;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.bean.HomeMenuBean;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.bean.QuerySubjectBean;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.bean.SubjectBean;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.bean.TeacherUserInfo;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.constants.CourseConstants;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.constants.TeacherInfoConstants;
 | 
	
	
		
			
				|  | @@ -88,7 +93,10 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |      private SmartRefreshLayout refreshLayout;
 | 
	
		
			
				|  |  |      private HomeHotMusicSheetAdapter mRecommendAdapter;
 | 
	
		
			
				|  |  |      private HomeHotMusicSheetAdapter mLatestAdapter;
 | 
	
		
			
				|  |  | -    //    private HomeGoodMusicSheetAdapter mGoodMusicSheetAdapter;
 | 
	
		
			
				|  |  | +    private OptionsPickerView pvOptions;
 | 
	
		
			
				|  |  | +    private List<SubjectBean> subjectBeanList = new ArrayList<>();
 | 
	
		
			
				|  |  | +    private int currentSelectSubjectPosition = 0;
 | 
	
		
			
				|  |  | +    private String currentSubjectId = "";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      protected void initView(View rootView) {
 | 
	
	
		
			
				|  | @@ -171,10 +179,10 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |          mViewBinding.tvHotTrackMore.setOnClickListener(this);
 | 
	
		
			
				|  |  |          mViewBinding.tvRecommendTrackMore.setOnClickListener(this);
 | 
	
		
			
				|  |  |          mViewBinding.tvLatestTrackMore.setOnClickListener(this);
 | 
	
		
			
				|  |  | +        mViewBinding.tvCurrentSubject.setOnClickListener(this);
 | 
	
		
			
				|  |  |          mViewBinding.refreshLayout.setOnRefreshListener(refreshLayout -> {
 | 
	
		
			
				|  |  |              mViewBinding.refreshLayout.finishRefresh();
 | 
	
		
			
				|  |  | -            presenter.getHotAlbumList();
 | 
	
		
			
				|  |  | -            presenter.getHotMusicSheetList();
 | 
	
		
			
				|  |  | +            refreshMusicData();
 | 
	
		
			
				|  |  |              presenter.queryCountOfUnread();
 | 
	
		
			
				|  |  |              presenter.queryLiveAndVideo();
 | 
	
		
			
				|  |  |              presenter.appHome();
 | 
	
	
		
			
				|  | @@ -218,10 +226,6 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |              presenter.queryCountOfUnread();
 | 
	
		
			
				|  |  |              presenter.queryLiveAndVideo();
 | 
	
		
			
				|  |  |              presenter.appHome();
 | 
	
		
			
				|  |  | -            //热门专辑
 | 
	
		
			
				|  |  | -            presenter.getHotAlbumList();
 | 
	
		
			
				|  |  | -            //热门曲目
 | 
	
		
			
				|  |  | -            presenter.getHotMusicSheetList();
 | 
	
		
			
				|  |  |              //获取领奖状态
 | 
	
		
			
				|  |  |              presenter.getAwardStatus();
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -526,6 +530,11 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |          if (mViewBinding == null || mViewBinding.tvTeacherName == null) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        //处理声部
 | 
	
		
			
				|  |  | +        currentSubjectId = teacherUserInfo.defaultSubject;
 | 
	
		
			
				|  |  | +        mViewBinding.tvCurrentSubject.setText(!TextUtils.isEmpty(teacherUserInfo.defaultSubjectName) ? teacherUserInfo.defaultSubjectName : "全部");
 | 
	
		
			
				|  |  | +        handleSubjects(teacherUserInfo.subjectName, teacherUserInfo.subjectId);
 | 
	
		
			
				|  |  | +        refreshMusicData();
 | 
	
		
			
				|  |  |          //昵称
 | 
	
		
			
				|  |  |          if (teacherUserInfo != null) {
 | 
	
		
			
				|  |  |              String teacherName = UserHelper.getTeacherName(teacherUserInfo.username, teacherUserInfo.userId);
 | 
	
	
		
			
				|  | @@ -580,6 +589,24 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void handleSubjects(String subjectName, String subjectId) {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            subjectBeanList.clear();
 | 
	
		
			
				|  |  | +            String[] subjectNames = UiUtils.splitSubjectName(subjectName);
 | 
	
		
			
				|  |  | +            String[] subjectIds = UiUtils.splitSubjectId(subjectId);
 | 
	
		
			
				|  |  | +            if (subjectIds != null && subjectIds.length > 0) {
 | 
	
		
			
				|  |  | +                for (int i = 0; i < subjectIds.length; i++) {
 | 
	
		
			
				|  |  | +                    String id = subjectIds[i];
 | 
	
		
			
				|  |  | +                    String name = subjectNames[i];
 | 
	
		
			
				|  |  | +                    SubjectBean querySubjectBean = new SubjectBean(name, id);
 | 
	
		
			
				|  |  | +                    subjectBeanList.add(querySubjectBean);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void handleBadgeUI(String tag) {
 | 
	
		
			
				|  |  |          int badgeAbleCount = 0;
 | 
	
		
			
				|  |  |          boolean enableStyleBadge = isEnableForBadge(tag, STYLE_TYPE);
 | 
	
	
		
			
				|  | @@ -699,6 +726,11 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |              showBadgeDialog();
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (id == R.id.tv_current_subject) {
 | 
	
		
			
				|  |  | +            selectSubject();
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void showRecommendMenuDialog() {
 | 
	
	
		
			
				|  | @@ -728,4 +760,46 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |          BadgeDesDialog badgeDesDialog = new BadgeDesDialog(getContext());
 | 
	
		
			
				|  |  |          badgeDesDialog.show();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void selectSubject() {
 | 
	
		
			
				|  |  | +        if (subjectBeanList.size() == 0) {
 | 
	
		
			
				|  |  | +            subjectBeanList.add(new SubjectBean("全部", ""));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pvOptions = new OptionsPickerBuilder(getContext(), (options1, options2, options3, v) -> {
 | 
	
		
			
				|  |  | +            this.currentSelectSubjectPosition = options1;
 | 
	
		
			
				|  |  | +            SubjectBean bean = subjectBeanList.get(options1);
 | 
	
		
			
				|  |  | +            currentSubjectId = bean.id;
 | 
	
		
			
				|  |  | +            mViewBinding.tvCurrentSubject.setText(bean.name);
 | 
	
		
			
				|  |  | +            if (presenter != null) {
 | 
	
		
			
				|  |  | +                //同步选中id
 | 
	
		
			
				|  |  | +                presenter.syncSubjectFilter(currentSubjectId);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            refreshMusicData();
 | 
	
		
			
				|  |  | +        }).setLayoutRes(R.layout.pickerview_address_layout, v -> {
 | 
	
		
			
				|  |  | +            //自定义布局中的控件初始化及事件处理
 | 
	
		
			
				|  |  | +            final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
 | 
	
		
			
				|  |  | +            TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
 | 
	
		
			
				|  |  | +            tvSubmit.setOnClickListener(v12 -> {
 | 
	
		
			
				|  |  | +                pvOptions.returnData();
 | 
	
		
			
				|  |  | +                pvOptions.dismiss();
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            ivCancel.setOnClickListener(v1 -> pvOptions.dismiss());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }).isDialog(false).build();
 | 
	
		
			
				|  |  | +        pvOptions.setPicker(subjectBeanList);
 | 
	
		
			
				|  |  | +        if (currentSelectSubjectPosition < subjectBeanList.size()) {
 | 
	
		
			
				|  |  | +            pvOptions.setSelectOptions(currentSelectSubjectPosition);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pvOptions.show();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 刷新专辑和曲目数据
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void refreshMusicData() {
 | 
	
		
			
				|  |  | +        //热门专辑
 | 
	
		
			
				|  |  | +        presenter.getHotAlbumList(currentSubjectId);
 | 
	
		
			
				|  |  | +        //热门曲目
 | 
	
		
			
				|  |  | +        presenter.getHotMusicSheetList(currentSubjectId);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |