|  | @@ -1,7 +1,11 @@
 | 
	
		
			
				|  |  |  package com.cooleshow.teacher.ui.homepage;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import android.text.TextUtils;
 | 
	
		
			
				|  |  | +import android.view.LayoutInflater;
 | 
	
		
			
				|  |  |  import android.view.View;
 | 
	
		
			
				|  |  | +import android.view.ViewGroup;
 | 
	
		
			
				|  |  | +import android.widget.FrameLayout;
 | 
	
		
			
				|  |  | +import android.widget.TextView;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import androidx.annotation.NonNull;
 | 
	
		
			
				|  |  |  import androidx.recyclerview.widget.LinearLayoutManager;
 | 
	
	
		
			
				|  | @@ -13,6 +17,7 @@ import com.chad.library.adapter.base.listener.OnLoadMoreListener;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.common.WebConstants;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.constanst.Constants;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.router.RouterPath;
 | 
	
		
			
				|  |  | +import com.cooleshow.base.utils.SizeUtils;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.utils.TimeUtils;
 | 
	
		
			
				|  |  |  import com.cooleshow.base.widgets.EmptyViewLayout;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.R;
 | 
	
	
		
			
				|  | @@ -25,6 +30,7 @@ import com.cooleshow.teacher.constants.TeacherInfoConstants;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.contract.LiveCoursePageContract;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.databinding.FragmentLiveCoursePageLayoutBinding;
 | 
	
		
			
				|  |  |  import com.cooleshow.teacher.presenter.homePage.LiveCoursePagePresenter;
 | 
	
		
			
				|  |  | +import com.cooleshow.teacher.widgets.HomePageCourseCommonHeaderView;
 | 
	
		
			
				|  |  |  import com.cooleshow.usercenter.bean.TeacherUserInfo;
 | 
	
		
			
				|  |  |  import com.scwang.smart.refresh.layout.api.RefreshLayout;
 | 
	
		
			
				|  |  |  import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
 | 
	
	
		
			
				|  | @@ -45,19 +51,25 @@ public class LiveCoursePageFragment extends BaseMVPFragment<FragmentLiveCoursePa
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //是否有直播权限 0 否 1 是
 | 
	
		
			
				|  |  |      private int liveFlag;
 | 
	
		
			
				|  |  | +    //是否认证 0 否 1 是
 | 
	
		
			
				|  |  | +    private int certFlag;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      protected void initView(View rootView) {
 | 
	
		
			
				|  |  | -        mViewBinding.tvOpen.setOnClickListener(this);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      protected void initData() {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        mViewBinding.commonHeader.setDataStyle(TIP_CACHE_KEY, R.drawable.icon_vip_custom_course_des_tag, getString(R.string.live_course_des_title), getString(com.cooleshow.base.R.string.live_course_tip_str), R.drawable.icon_live_course_set,getString(R.string.create_live_course_text), new View.OnClickListener() {
 | 
	
		
			
				|  |  | +        mViewBinding.commonHeader.setDataStyle(TIP_CACHE_KEY, R.drawable.icon_vip_custom_course_des_tag, getString(R.string.live_course_des_title), getString(com.cooleshow.base.R.string.live_course_tip_str), R.drawable.icon_live_course_set, getString(R.string.create_live_course_text), new HomePageCourseCommonHeaderView.OnEventListener() {
 | 
	
		
			
				|  |  |              @Override
 | 
	
		
			
				|  |  | -            public void onClick(View v) {
 | 
	
		
			
				|  |  | -                goCreate();
 | 
	
		
			
				|  |  | +            public void onCloseTip() {
 | 
	
		
			
				|  |  | +                updateEmptyViewLayoutParams();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public void goCreate() {
 | 
	
		
			
				|  |  | +                LiveCoursePageFragment.this.goCreate();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -106,11 +118,11 @@ public class LiveCoursePageFragment extends BaseMVPFragment<FragmentLiveCoursePa
 | 
	
		
			
				|  |  |      public void onClick(View view) {
 | 
	
		
			
				|  |  |          switch (view.getId()) {
 | 
	
		
			
				|  |  |              case R.id.tv_open:
 | 
	
		
			
				|  |  | -                if (mViewBinding.tvOpen.getText().toString().equals("去认证")) {
 | 
	
		
			
				|  |  | +                if (certFlag == 0) {
 | 
	
		
			
				|  |  |                      ARouter.getInstance().build(RouterPath.WebCenter.ACTIVITY_HTML)
 | 
	
		
			
				|  |  |                              .withString(WebConstants.WEB_URL, WebConstants.TEACHER_CERT)
 | 
	
		
			
				|  |  |                              .navigation();
 | 
	
		
			
				|  |  | -                } else if (mViewBinding.tvOpen.getText().toString().equals("立即开通")) {
 | 
	
		
			
				|  |  | +                } else if (liveFlag == 0) {
 | 
	
		
			
				|  |  |                      ARouter.getInstance()
 | 
	
		
			
				|  |  |                              .build(RouterPath.WebCenter.ACTIVITY_HTML)
 | 
	
		
			
				|  |  |                              .withString(WebConstants.WEB_URL, WebConstants.TEACHER_OPEN_LIVE)
 | 
	
	
		
			
				|  | @@ -162,8 +174,6 @@ public class LiveCoursePageFragment extends BaseMVPFragment<FragmentLiveCoursePa
 | 
	
		
			
				|  |  |                      if (liveCourseListBean.rows != null && liveCourseListBean.rows.size() > 0) {
 | 
	
		
			
				|  |  |                          checkHasNext(liveCourseListBean.rows.size());
 | 
	
		
			
				|  |  |                          mAdapter.setNewInstance(liveCourseListBean.rows);
 | 
	
		
			
				|  |  | -                    } else {
 | 
	
		
			
				|  |  | -                        showEmptyView();
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              } else {
 | 
	
	
		
			
				|  | @@ -200,44 +210,77 @@ public class LiveCoursePageFragment extends BaseMVPFragment<FragmentLiveCoursePa
 | 
	
		
			
				|  |  |          hasNext = dataSize >= Constants.DEFAULT_DATA_SIZE;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void showEmptyView() {
 | 
	
		
			
				|  |  | +    private void setEmptyView() {
 | 
	
		
			
				|  |  |          if (mEmptyView == null) {
 | 
	
		
			
				|  |  |              mEmptyView = new EmptyViewLayout(getContext());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        boolean isVis = mViewBinding.commonHeader.contentIsVisibility();
 | 
	
		
			
				|  |  | +        if (isVis) {
 | 
	
		
			
				|  |  | +            //如果顶部内容显示,需要自适应WRAP_CONTENT高度,不然页面折叠状态下可能因为Recyclerview高度比较小,导致无法展示完缺省图
 | 
	
		
			
				|  |  | +            ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 | 
	
		
			
				|  |  | +            mEmptyView.setLayoutParams(layoutParams);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          mEmptyView.setContent(com.cooleshow.base.R.drawable.icon_empty_course, "暂无内容");
 | 
	
		
			
				|  |  |          mAdapter.setEmptyView(mEmptyView);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void showNotHasLivePermissionView(String text, boolean isShowOpenBt, String btText) {
 | 
	
		
			
				|  |  | +        View noPermissionTipView = LayoutInflater.from(getContext()).inflate(R.layout.view_no_option_permission_tip_layout, mAdapter.getEmptyLayout(), false);
 | 
	
		
			
				|  |  | +        noPermissionTipView.findViewById(R.id.tv_open).setOnClickListener(this);
 | 
	
		
			
				|  |  | +        TextView tv_empty_hint = noPermissionTipView.findViewById(R.id.tv_empty_hint);
 | 
	
		
			
				|  |  | +        TextView tv_open = noPermissionTipView.findViewById(R.id.tv_open);
 | 
	
		
			
				|  |  | +        tv_empty_hint.setText(text);
 | 
	
		
			
				|  |  | +        tv_open.setVisibility(isShowOpenBt ? View.VISIBLE : View.GONE);
 | 
	
		
			
				|  |  | +        tv_open.setText(btText);
 | 
	
		
			
				|  |  | +        boolean isVis = mViewBinding.commonHeader.contentIsVisibility();
 | 
	
		
			
				|  |  | +        if (isVis) {
 | 
	
		
			
				|  |  | +            //如果顶部内容显示,需要自适应WRAP_CONTENT高度,不然页面折叠状态下可能因为Recyclerview高度比较小,导致无法展示完缺省图
 | 
	
		
			
				|  |  | +            ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 | 
	
		
			
				|  |  | +            noPermissionTipView.setLayoutParams(layoutParams);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        mAdapter.setEmptyView(noPermissionTipView);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void getTeacherInfoSuccess(TeacherUserInfo teacherUserInfo) {
 | 
	
		
			
				|  |  |          if (TextUtils.equals(teacherUserInfo.entryStatus, TeacherInfoConstants.ENTRY_STATUS_DOING)) {
 | 
	
		
			
				|  |  |              //入驻审核中
 | 
	
		
			
				|  |  | -            mViewBinding.llContent.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | -            mViewBinding.clEmptyFlag.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | -            mViewBinding.tvEmptyHint.setText("老师认证审核中!");
 | 
	
		
			
				|  |  | -            mViewBinding.tvOpen.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +            certFlag = 0;
 | 
	
		
			
				|  |  | +            mViewBinding.commonHeader.handleCreateBt(false);
 | 
	
		
			
				|  |  | +            showNotHasLivePermissionView("老师认证审核中!", false, "");
 | 
	
		
			
				|  |  |          } else if (TextUtils.equals(teacherUserInfo.entryStatus, TeacherInfoConstants.ENTRY_STATUS_PASS)) {
 | 
	
		
			
				|  |  |              //入驻审核通过
 | 
	
		
			
				|  |  | +            certFlag = 1;
 | 
	
		
			
				|  |  |              if (teacherUserInfo.liveFlag == 0) {
 | 
	
		
			
				|  |  | -                mViewBinding.refreshLayout.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | -                mViewBinding.clEmptyFlag.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | -                mViewBinding.tvEmptyHint.setText("您尚未开通直播服务\n开通后即可创建直播课程");
 | 
	
		
			
				|  |  | -                mViewBinding.tvOpen.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | -                mViewBinding.tvOpen.setText("立即开通");
 | 
	
		
			
				|  |  | -            }else{
 | 
	
		
			
				|  |  | -                mViewBinding.llContent.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | -                mViewBinding.clEmptyFlag.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | +                mViewBinding.commonHeader.handleCreateBt(false);
 | 
	
		
			
				|  |  | +                showNotHasLivePermissionView("您尚未开通直播服务\n开通后即可创建直播课程", true, "立即开通");
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                mViewBinding.commonHeader.handleCreateBt(true);
 | 
	
		
			
				|  |  | +                setEmptyView();
 | 
	
		
			
				|  |  |                  currentPage = 1;
 | 
	
		
			
				|  |  |                  queryCourse();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              //未通过或者未申请
 | 
	
		
			
				|  |  | -            mViewBinding.llContent.setVisibility(View.GONE);
 | 
	
		
			
				|  |  | -            mViewBinding.clEmptyFlag.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | -            mViewBinding.tvEmptyHint.setText("您还没有完成老师认证\n认证后才可创建直播课哦~");
 | 
	
		
			
				|  |  | -            mViewBinding.tvOpen.setVisibility(View.VISIBLE);
 | 
	
		
			
				|  |  | -            mViewBinding.tvOpen.setText("去认证");
 | 
	
		
			
				|  |  | +            certFlag = 0;
 | 
	
		
			
				|  |  | +            mViewBinding.commonHeader.handleCreateBt(false);
 | 
	
		
			
				|  |  | +            showNotHasLivePermissionView("您还没有完成老师认证\n认证后才可创建直播课哦~", true, "去认证");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          liveFlag = teacherUserInfo.liveFlag;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private void updateEmptyViewLayoutParams() {
 | 
	
		
			
				|  |  | +        if (mAdapter != null) {
 | 
	
		
			
				|  |  | +            //为了实现居中显示空视图,所以重新设置一下缺省图
 | 
	
		
			
				|  |  | +            FrameLayout emptyLayout = mAdapter.getEmptyLayout();
 | 
	
		
			
				|  |  | +            if (emptyLayout != null) {
 | 
	
		
			
				|  |  | +                View childAt = emptyLayout.getChildAt(0);
 | 
	
		
			
				|  |  | +                ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
 | 
	
		
			
				|  |  | +                layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
 | 
	
		
			
				|  |  | +                layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
 | 
	
		
			
				|  |  | +                childAt.setLayoutParams(layoutParams);
 | 
	
		
			
				|  |  | +                mAdapter.setEmptyView(childAt);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |