浏览代码

增加学生端新首页UI(达人风采相关逻辑)

Pq 2 年之前
父节点
当前提交
528586d4f8

+ 1 - 0
BaseLibrary/src/main/java/com/cooleshow/base/constanst/Constants.java

@@ -22,4 +22,5 @@ public class Constants {
 
 
     public static final String MAIN_PAGE_SELECT_POTION_KEY = "select_position";
+    public static final String ON_LIVING_TAG = "1";//1是直播中, 0否
 }

+ 43 - 0
student/src/main/java/com/cooleshow/student/adapter/HomeBottomPageAdapter.java

@@ -0,0 +1,43 @@
+package com.cooleshow.student.adapter;
+
+import android.view.ViewGroup;
+
+import com.cooleshow.base.ui.fragment.BaseMVPFragment;
+
+import java.util.List;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentStatePagerAdapter;
+import androidx.viewpager2.adapter.FragmentStateAdapter;
+
+/**
+ * 创建日期:2022/5/26 17:30
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public class HomeBottomPageAdapter extends FragmentStateAdapter {
+    private List<Fragment> mFragments;
+
+    public HomeBottomPageAdapter(@NonNull Fragment fragment) {
+        super(fragment);
+    }
+
+    public void setFragments(List<Fragment> fragments) {
+        this.mFragments = fragments;
+    }
+
+
+    @NonNull
+    @Override
+    public Fragment createFragment(int position) {
+        return mFragments.get(position);
+    }
+
+    @Override
+    public int getItemCount() {
+        return mFragments != null ? mFragments.size() : 0;
+    }
+}

+ 1 - 1
student/src/main/java/com/cooleshow/student/adapter/HomeTalentStyleAdapter.java

@@ -44,7 +44,7 @@ public class HomeTalentStyleAdapter extends BaseQuickAdapter<HomeStyleBean.RowsB
         coverImagView.setLayoutParams(layoutParams);
         boolean isLiving = TextUtils.equals(data.liveing, "1");
         //封面
-        GlideUtils.INSTANCE.loadImage(getContext(), isLiving ? data.coverPic : data.cover, coverImagView, com.cooleshow.base.R.drawable.bg_video_placeholder);
+        GlideUtils.INSTANCE.loadTopRoundImage(getContext(), isLiving ? data.liveCoverImg : data.cover, coverImagView, 10, com.cooleshow.base.R.drawable.bg_video_placeholder);
         //直播标题
         TextView tv_title = holder.getView(R.id.tv_title);
         tv_title.setVisibility(isLiving ? View.VISIBLE : View.GONE);

+ 0 - 1
student/src/main/java/com/cooleshow/student/bean/HomeStyleBean.java

@@ -56,7 +56,6 @@ public class HomeStyleBean {
         public long verifyUserId;
         public String videoUrl;
         public String cover;
-        public String coverPic;
         public String liveCoverImg;
         public String liveTitle;
         public String roomUid;

+ 1 - 0
student/src/main/java/com/cooleshow/student/presenter/main/HomePresenter.java

@@ -229,6 +229,7 @@ public class HomePresenter extends BasePresenter<HomeContract.HomeView> implemen
                                                 rowsBean.liveCoverImg = tempLiveTeacherListBean.liveCoverImg;
                                                 rowsBean.liveTitle = tempLiveTeacherListBean.liveTitle;
                                                 rowsBean.roomUid = tempLiveTeacherListBean.roomUid;
+                                                rowsBean.liveing = Constants.ON_LIVING_TAG;
                                             }
                                         }
                                     }

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

@@ -17,10 +17,12 @@ import com.cooleshow.base.utils.UiUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.widgets.CommonItemDecoration;
 import com.cooleshow.student.R;
+import com.cooleshow.student.adapter.HomeBottomPageAdapter;
 import com.cooleshow.student.adapter.HomeHotAlbumAdapter;
 import com.cooleshow.student.adapter.HomeHotMusicSheetAdapter;
 import com.cooleshow.student.adapter.HomeMenuPagerAdapter;
 import com.cooleshow.student.adapter.HomeRecommendTalentAdapter;
+import com.cooleshow.student.adapter.HomeTalentStyleAdapter;
 import com.cooleshow.student.adapter.HomeVideoCourseAdapter;
 import com.cooleshow.student.adapter.NewHomeVideoCourseAdapter;
 import com.cooleshow.student.bean.AppHomeBean;
@@ -77,6 +79,7 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
     private HomeHotMusicSheetAdapter mHomeHotMusicSheetAdapter;
     private HomeRecommendTalentAdapter mRecommendTalentAdapter;
     private NewHomeVideoCourseAdapter mHomeVideoCourseAdapter;
+    private TalentStyleFragment mTalentStyleFragment;
 
     @Override
     protected FragmentNewHomeLayoutBinding getLayoutView() {
@@ -130,10 +133,10 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
         mViewBinding.recyclerviewRecommendTalent.addItemDecoration(commonItemDecoration);
         mViewBinding.recyclerviewRecommendTalent.setAdapter(mRecommendTalentAdapter);
 
-        GridLayoutManager videoCourseManager = new GridLayoutManager(getContext(),2);
+        GridLayoutManager videoCourseManager = new GridLayoutManager(getContext(), 2);
         mViewBinding.rvVideoCourse.setLayoutManager(videoCourseManager);
         mHomeVideoCourseAdapter = new NewHomeVideoCourseAdapter();
-        CommonItemDecoration videoListItemDecoration=new CommonItemDecoration(SizeUtils.dp2px(12),SizeUtils.dp2px(5),0,SizeUtils.dp2px(5),0);
+        CommonItemDecoration videoListItemDecoration = new CommonItemDecoration(SizeUtils.dp2px(12), SizeUtils.dp2px(5), 0, SizeUtils.dp2px(5), 0);
         mViewBinding.rvVideoCourse.addItemDecoration(videoListItemDecoration);
         mViewBinding.rvVideoCourse.setAdapter(mHomeVideoCourseAdapter);
 
@@ -142,6 +145,16 @@ 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();
+        Fragment fragment =new Fragment();
+        bottomFragments.add(mTalentStyleFragment);
+        bottomFragments.add(fragment);
+        homeBottomPageAdapter.setFragments(bottomFragments);
+        mViewBinding.viewPagerBottom.setAdapter(homeBottomPageAdapter);
+
+
         mMenuPagerAdapter = new HomeMenuPagerAdapter(getParentFragmentManager(), fragments);
         mViewBinding.viewpagerMenu.setAdapter(mMenuPagerAdapter);
         mBannerImageAdapter = new BannerImageAdapter<AppHomeBean.ItemBean>(itemBeans) {
@@ -422,7 +435,9 @@ public class NewHomeFragment extends BaseMVPFragment<FragmentNewHomeLayoutBindin
 
     @Override
     public void getStylePageSuccess(HomeStyleBean data) {
-
+        if (mTalentStyleFragment != null) {
+            mTalentStyleFragment.setData(data.rows);
+        }
     }
 
     @Override

+ 2 - 1
student/src/main/java/com/cooleshow/student/ui/main/TalentStyleFragment.java

@@ -8,6 +8,7 @@ import com.cooleshow.student.bean.HomeStyleBean;
 import com.cooleshow.student.databinding.FragmentHomeTalentLayoutBinding;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.recyclerview.widget.StaggeredGridLayoutManager;
@@ -37,7 +38,7 @@ public class TalentStyleFragment extends BaseFragment<FragmentHomeTalentLayoutBi
         recyclerView.setAdapter(mTalentStyleAdapter);
     }
 
-    public void setData(ArrayList<HomeStyleBean.RowsBean> data) {
+    public void setData(List<HomeStyleBean.RowsBean> data) {
         if (mTalentStyleAdapter != null) {
             mTalentStyleAdapter.setNewInstance(data);
         }

+ 2 - 0
student/src/main/res/layout/fragment_home_talent_layout.xml

@@ -4,6 +4,8 @@
     android:layout_height="match_parent">
 
     <androidx.recyclerview.widget.RecyclerView
+        android:layout_marginStart="7dp"
+        android:layout_marginEnd="7dp"
         android:id="@+id/recyclerView"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"

+ 4 - 1
student/src/main/res/layout/item_home_talent_style_layout.xml

@@ -4,6 +4,9 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:layout_marginStart="6dp"
+    android:layout_marginEnd="6dp"
+    android:layout_marginBottom="12dp"
     android:background="@drawable/bg_white_10dp"
     android:paddingBottom="14dp">
 
@@ -37,7 +40,7 @@
         android:layout_width="16dp"
         android:layout_height="16dp"
         android:layout_marginStart="11dp"
-        android:layout_marginTop="13dp"
+        android:layout_marginTop="12dp"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/tv_title" />