Browse Source

修改学生端首页pad适配效果

Pq 1 year ago
parent
commit
59e0d490e7

+ 7 - 0
student/src/main/java/com/cooleshow/student/constants/CommonConfig.java

@@ -1,6 +1,9 @@
 package com.cooleshow.student.constants;
 
+import android.content.Context;
+
 import com.cooleshow.base.utils.SPUtils;
+import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
 import com.cooleshow.usercenter.helper.UserHelper;
 
 /**
@@ -13,4 +16,8 @@ public class CommonConfig {
     public static boolean getTodayShowAwardIsCompleted() {
         return UserHelper.getShowAwardDialogTipIsCompleted();
     }
+
+    public static int getHomeMenuCount(Context context){
+        return QMUIDeviceHelper.isTablet(context) ? 7 : 5;
+    }
 }

+ 4 - 1
student/src/main/java/com/cooleshow/student/ui/main/HomeMenuFragment.java

@@ -14,9 +14,11 @@ import com.chad.library.adapter.base.listener.OnItemClickListener;
 import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
+import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
 import com.cooleshow.metronome.MetronomeActivity;
 import com.cooleshow.student.adapter.HomeMenuItemAdapter;
 import com.cooleshow.student.bean.AppHomeBean;
+import com.cooleshow.student.constants.CommonConfig;
 import com.cooleshow.student.databinding.FragmentHomeMenuBinding;
 import com.cooleshow.student.presenter.main.HomeMenuPresenter;
 
@@ -60,7 +62,8 @@ public class HomeMenuFragment extends BaseMVPFragment<FragmentHomeMenuBinding, H
     protected void initView(View rootView) {
         itemBeanList = (List<AppHomeBean.ItemBean>) getArguments().getSerializable("itemBeanList");
         RecyclerView rvMenu = mViewBinding.rvMenu;
-        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 5);
+        int count = CommonConfig.getHomeMenuCount(getContext());
+        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), count);
         rvMenu.setLayoutManager(gridLayoutManager);
         HomeMenuItemAdapter addPhotoListAdapter = new HomeMenuItemAdapter(itemBeanList);
         rvMenu.setAdapter(addPhotoListAdapter);

+ 6 - 3
student/src/main/java/com/cooleshow/student/ui/main/NewHomeFragment.java

@@ -25,6 +25,7 @@ import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.base.utils.TimeUtils;
 import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.Utils;
+import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
 import com.cooleshow.base.utils.helper.WebStartHelper;
 import com.cooleshow.base.widgets.CommonItemDecoration;
 import com.cooleshow.base.widgets.dialog.AwardTipDialog;
@@ -97,6 +98,7 @@ import static com.cooleshow.student.constants.CourseConstants.PIANO_ROOM_COURSE;
 public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBinding, HomePresenter> implements HomeContract.HomeView, View.OnClickListener, TalentStyleFragment.OnEventListener, HotNewsFragment.OnEventListener {
     public static final int MAX_HOT_MUSIC_LIST_PAGE = 4;//热门曲目一页最大条数
     public static final int MAX_GOOD_MUSIC_LIST_PAGE = 3;//精品曲目一页最大条数
+    public static int MAX_NUM_FOR_TOP_MENU = 5;//金刚位一页个数
     private Banner banner;
     private SmartRefreshLayout refreshLayout;
     private ArrayList<AppHomeBean.ItemBean> itemBeans = new ArrayList<>();
@@ -234,6 +236,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         mViewBinding.viewPagerBottom.setOffscreenPageLimit(bottomFragments.size());
         mViewBinding.viewPagerBottom.setAdapter(homeBottomPageAdapter);
 
+        MAX_NUM_FOR_TOP_MENU = CommonConfig.getHomeMenuCount(getContext());
         mMenuPagerAdapter = new HomeMenuPagerAdapter(getChildFragmentManager(), fragments);
         mViewBinding.viewpagerMenu.setAdapter(mMenuPagerAdapter);
         mBannerImageAdapter = new BannerImageAdapter<AppHomeBean.ItemBean>(itemBeans) {
@@ -499,13 +502,13 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         }
         if (menuList != null && menuList.size() != 0) {
             fragments.clear();
-            int count = menuList.size() / 5;
-            if (menuList.size() % 5 > 0) {
+            int count = menuList.size() / MAX_NUM_FOR_TOP_MENU;
+            if (menuList.size() % MAX_NUM_FOR_TOP_MENU > 0) {
                 count++;
             }
             for (int i = 0; i < count; i++) {
                 List<AppHomeBean.ItemBean> dataList = new ArrayList<>();
-                for (int j = i * 5; j < menuList.size() && j < (i + 1) * 5; j++) {
+                for (int j = i * MAX_NUM_FOR_TOP_MENU; j < menuList.size() && j < (i + 1) * MAX_NUM_FOR_TOP_MENU; j++) {
                     dataList.add(menuList.get(j));
                 }
                 fragments.add(HomeMenuFragment.newInstance(dataList));

+ 4 - 2
student/src/main/java/com/cooleshow/student/ui/main/TalentStyleFragment.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.BaseFragment;
+import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
 import com.cooleshow.base.widgets.EmptyViewLayout;
 import com.cooleshow.student.R;
 import com.cooleshow.student.adapter.HomeTalentStyleAdapter;
@@ -46,7 +47,8 @@ public class TalentStyleFragment extends BaseFragment<FragmentHomeTalentLayoutBi
 
     @Override
     protected void initData() {
-        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
+        int count = QMUIDeviceHelper.isTablet(getContext()) ? 3 : 2;
+        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(count, StaggeredGridLayoutManager.VERTICAL);
         recyclerView.setLayoutManager(staggeredGridLayoutManager);
         mTalentStyleAdapter = new HomeTalentStyleAdapter();
         EmptyViewLayout emptyViewLayout = new EmptyViewLayout(getContext());
@@ -60,7 +62,7 @@ public class TalentStyleFragment extends BaseFragment<FragmentHomeTalentLayoutBi
                     HomeStyleBean.RowsBean item = mTalentStyleAdapter.getData().get(position);
                     if (TextUtils.equals(item.liveStatus, Constants.ON_LIVING_TAG)) {
                         ARouter.getInstance().build(RouterPath.LiveCenter.ACTIVITY_TT_LIVE_ROOM)
-                                .withString("roomid_key",item.roomUid)
+                                .withString("roomid_key", item.roomUid)
                                 .navigation();
 //                        LiveRoomActivity.startLiveRoomActivity(getContext(), item.roomUid);
                     } else {

+ 1 - 1
student/src/main/res/layout/fragment_new_home_layout.xml

@@ -162,7 +162,7 @@
                         <com.youth.banner.Banner
                             android:id="@+id/banner"
                             android:layout_width="match_parent"
-                            android:layout_height="@dimen/dp_132"
+                            android:layout_height="@dimen/qb_px_132"
                             android:layout_marginLeft="@dimen/dp_14"
                             android:layout_marginTop="@dimen/dp_10"
                             android:layout_marginRight="@dimen/dp_14"

+ 1 - 1
student/src/main/res/layout/item_home_recommend_talent_layot.xml

@@ -2,7 +2,7 @@
 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="110dp"
+    android:layout_width="@dimen/qb_px_110"
     android:layout_height="wrap_content"
     android:background="@drawable/shape_10dp_white"
     android:paddingBottom="11dp">