|  | @@ -1,6 +1,7 @@
 | 
	
		
			
				|  |  |  package com.cooleshow.student.ui.main;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import android.text.TextUtils;
 | 
	
		
			
				|  |  | +import android.util.Log;
 | 
	
		
			
				|  |  |  import android.view.View;
 | 
	
		
			
				|  |  |  import android.widget.ImageView;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -40,8 +41,10 @@ import com.cooleshow.student.constants.CourseConstants;
 | 
	
		
			
				|  |  |  import com.cooleshow.student.contract.HomeContract;
 | 
	
		
			
				|  |  |  import com.cooleshow.student.databinding.FragmentNewHomeLayoutBinding;
 | 
	
		
			
				|  |  |  import com.cooleshow.student.presenter.main.HomePresenter;
 | 
	
		
			
				|  |  | +import com.cooleshow.student.widgets.AppBarLayoutStateChangeListener;
 | 
	
		
			
				|  |  |  import com.cooleshow.student.widgets.HomeHotAlbumDecoration;
 | 
	
		
			
				|  |  |  import com.cooleshow.student.widgets.HomeHotMusicSheetItemDecoration;
 | 
	
		
			
				|  |  | +import com.google.android.material.appbar.AppBarLayout;
 | 
	
		
			
				|  |  |  import com.scwang.smart.refresh.layout.SmartRefreshLayout;
 | 
	
		
			
				|  |  |  import com.youth.banner.Banner;
 | 
	
		
			
				|  |  |  import com.youth.banner.adapter.BannerImageAdapter;
 | 
	
	
		
			
				|  | @@ -163,17 +166,18 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |          mViewBinding.rvHotAlbum.setNestedScrollingEnabled(false);
 | 
	
		
			
				|  |  |          mViewBinding.rvVideoCourse.setNestedScrollingEnabled(false);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        HomeBottomPageAdapter homeBottomPageAdapter = new HomeBottomPageAdapter(this);
 | 
	
		
			
				|  |  |          ArrayList<Fragment> bottomFragments = new ArrayList<>();
 | 
	
		
			
				|  |  |          mTalentStyleFragment = new TalentStyleFragment();
 | 
	
		
			
				|  |  |          mHotNewsFragment = new HotNewsFragment();
 | 
	
		
			
				|  |  |          bottomFragments.add(mTalentStyleFragment);
 | 
	
		
			
				|  |  |          bottomFragments.add(mHotNewsFragment);
 | 
	
		
			
				|  |  | -        homeBottomPageAdapter.setFragments(bottomFragments);
 | 
	
		
			
				|  |  | +        HomeBottomPageAdapter homeBottomPageAdapter = new HomeBottomPageAdapter(this.getChildFragmentManager(), bottomFragments);
 | 
	
		
			
				|  |  | +//        getChildFragmentManager().beginTransaction()
 | 
	
		
			
				|  |  | +//                .add(R.id.fl_talent_style_container, mTalentStyleFragment)
 | 
	
		
			
				|  |  | +//                .add(R.id.fl_hot_news_container, mHotNewsFragment).commit();
 | 
	
		
			
				|  |  |          mViewBinding.viewPagerBottom.setOffscreenPageLimit(bottomFragments.size());
 | 
	
		
			
				|  |  |          mViewBinding.viewPagerBottom.setAdapter(homeBottomPageAdapter);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          mMenuPagerAdapter = new HomeMenuPagerAdapter(getParentFragmentManager(), fragments);
 | 
	
		
			
				|  |  |          mViewBinding.viewpagerMenu.setAdapter(mMenuPagerAdapter);
 | 
	
		
			
				|  |  |          mBannerImageAdapter = new BannerImageAdapter<AppHomeBean.ItemBean>(itemBeans) {
 | 
	
	
		
			
				|  | @@ -215,8 +219,22 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void initListener() {
 | 
	
		
			
				|  |  | -        mViewBinding.viewPagerBottom.registerOnPageChangeCallback(onPageChangeCallback);
 | 
	
		
			
				|  |  | +        mViewBinding.viewPagerBottom.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public void onPageSelected(int position) {
 | 
	
		
			
				|  |  | +                switchTabStyle(position);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public void onPageScrollStateChanged(int state) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |          mViewBinding.refreshLayout.setOnRefreshListener(refreshLayout -> {
 | 
	
		
			
				|  |  |              refreshLayout.finishRefresh();
 | 
	
		
			
				|  |  |              presenter.queryCountOfUnread();
 | 
	
	
		
			
				|  | @@ -286,21 +304,39 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        mViewBinding.scrollLayout.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
 | 
	
		
			
				|  |  | -            boolean localVisibleRect = UiUtils.getLocalVisibleRect(getActivity(), banner, 10);
 | 
	
		
			
				|  |  | -            //banner可见的时候就自动循环,否则就停止,解决问题:在scrollview到最底部时候,由于banner自动到第一个时候就往上顶一段距离
 | 
	
		
			
				|  |  | -            if (localVisibleRect) {
 | 
	
		
			
				|  |  | -                if (null != banner) {
 | 
	
		
			
				|  |  | -                    banner.isAutoLoop(true);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                if (null != banner) {
 | 
	
		
			
				|  |  | -                    banner.isAutoLoop(false);
 | 
	
		
			
				|  |  | +        mViewBinding.appBarLayout.addOnOffsetChangedListener(new AppBarLayoutStateChangeListener() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public void onStateChanged(AppBarLayout appBarLayout, State state) {
 | 
	
		
			
				|  |  | +                switch (state) {
 | 
	
		
			
				|  |  | +                    case EXPANDED:    //展开
 | 
	
		
			
				|  |  | +                        Log.i("pq","展开");
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case COLLAPSED:    //折叠
 | 
	
		
			
				|  |  | +                        Log.i("pq","折叠");
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case INTERMEDIATE: //中间状态
 | 
	
		
			
				|  |  | +                        Log.i("pq","中间状态");
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void resetBannerAuto() {
 | 
	
		
			
				|  |  | +        boolean localVisibleRect = UiUtils.getLocalVisibleRect(getActivity(), banner, 10);
 | 
	
		
			
				|  |  | +        //banner可见的时候就自动循环,否则就停止,解决问题:在scrollview到最底部时候,由于banner自动到第一个时候就往上顶一段距离
 | 
	
		
			
				|  |  | +        if (localVisibleRect) {
 | 
	
		
			
				|  |  | +            if (null != banner) {
 | 
	
		
			
				|  |  | +                banner.isAutoLoop(true);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            if (null != banner) {
 | 
	
		
			
				|  |  | +                banner.isAutoLoop(false);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void onResume() {
 | 
	
		
			
				|  |  |          super.onResume();
 | 
	
	
		
			
				|  | @@ -709,8 +745,5 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void onDestroy() {
 | 
	
		
			
				|  |  |          super.onDestroy();
 | 
	
		
			
				|  |  | -        if (mViewBinding != null && mViewBinding.viewPagerBottom != null) {
 | 
	
		
			
				|  |  | -            mViewBinding.viewPagerBottom.registerOnPageChangeCallback(onPageChangeCallback);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |