|
@@ -5,6 +5,7 @@ import android.animation.ValueAnimator;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
@@ -74,6 +75,7 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
import androidx.core.widget.NestedScrollView;
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
@@ -109,6 +111,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
|
|
|
private HotNewsFragment mHotNewsFragment;
|
|
|
private ValueAnimator bottomTabValueAnimator;
|
|
|
private boolean isCollapsed = false;//控制底部tab
|
|
|
+ private int indicatorWidth = 0;//金刚位indicator宽度
|
|
|
|
|
|
private ViewPager2.OnPageChangeCallback onPageChangeCallback = new ViewPager2.OnPageChangeCallback() {
|
|
|
@Override
|
|
@@ -132,6 +135,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
|
|
|
protected void initView(View rootView) {
|
|
|
Utils.setHeadView(mViewBinding.viewStatusBar, requireContext(), SizeUtils.dp2px(3.5f));
|
|
|
banner = mViewBinding.banner;
|
|
|
+ indicatorWidth = SizeUtils.dp2px(18);
|
|
|
refreshLayout = mViewBinding.refreshLayout;
|
|
|
mViewBinding.bgAnnouncement.setOnClickListener(this);
|
|
|
mViewBinding.bgAnnouncement2.setOnClickListener(this);
|
|
@@ -330,17 +334,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
|
|
|
mViewBinding.viewpagerMenu.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
|
@Override
|
|
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
|
- position = position % fragments.size();// 需要对position的值进行重新赋值,否则会造成数组越界
|
|
|
- // 更新小圆点的显示
|
|
|
-// for (int i = 0; i < fragments.size(); i++) {
|
|
|
-// ImageView iv = (ImageView) llIndicator.getChildAt(i);
|
|
|
-// // 当前滑到的是那一页就让第几个小圆点处于选中状态
|
|
|
-// if (position == i) {
|
|
|
-// iv.setImageResource(R.drawable.bg_2dc7aa_indicator);
|
|
|
-// } else {
|
|
|
-// iv.setImageResource(R.drawable.bg_f2f2f2_indicator);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ mViewBinding.indicatorMainLine.setTranslationX(indicatorWidth * (position + positionOffset));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -503,13 +497,25 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
|
|
|
}
|
|
|
if (fragments.size() == 0) {
|
|
|
mViewBinding.viewpagerMenu.setVisibility(View.GONE);
|
|
|
+ mViewBinding.rlIndicator.setVisibility(View.GONE);
|
|
|
return;
|
|
|
+ }else{
|
|
|
+ mViewBinding.viewpagerMenu.setVisibility(View.VISIBLE);
|
|
|
+ mViewBinding.rlIndicator.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
+ initIndicator();
|
|
|
mMenuPagerAdapter.setFragments(fragments);
|
|
|
mViewBinding.viewpagerMenu.setVisibility(View.VISIBLE);
|
|
|
mMenuPagerAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
+ private void initIndicator() {
|
|
|
+ ViewGroup.LayoutParams params = mViewBinding.rlIndicator.getLayoutParams();
|
|
|
+ params.width = fragments.size() * indicatorWidth;
|
|
|
+ mViewBinding.rlIndicator.setLayoutParams(params);
|
|
|
+ mViewBinding.indicatorMainLine.setTranslationX(0);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void hotAlbumListSuccess(HotAlbumBean homeHotAlbumListBean) {
|
|
|
if (isDetached() || homeHotAlbumListBean == null) {
|