Преглед изворни кода

老师主页 个人风采空状态处理,跳转逻辑处理

邓琴文 пре 3 година
родитељ
комит
74a486362f

+ 34 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/homepage/MineStyleFragment.java

@@ -3,6 +3,8 @@ package com.cooleshow.teacher.ui.homepage;
 import android.text.TextUtils;
 import android.view.View;
 
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
 import com.cooleshow.base.utils.SizeUtils;
 import com.cooleshow.teacher.R;
@@ -13,6 +15,7 @@ import com.cooleshow.teacher.contract.MineStyleContract;
 import com.cooleshow.teacher.databinding.FragmentMineStyleLayoutBinding;
 import com.cooleshow.teacher.presenter.homePage.MineStylePresenter;
 import com.cooleshow.teacher.widgets.MineStyleVideoListItemDecoration;
+import com.cooleshow.teacher.widgets.StyleEmptyView;
 
 import androidx.recyclerview.widget.GridLayoutManager;
 import androidx.recyclerview.widget.LinearLayoutManager;
@@ -34,15 +37,38 @@ public class MineStyleFragment extends BaseMVPFragment<FragmentMineStyleLayoutBi
         mViewBinding.recyclerView.setLayoutManager(gridLayoutManager);
         mViewBinding.recyclerView.addItemDecoration(itemDecoration);
         mViewBinding.recyclerView.setAdapter(mStyleVideoListAdapter);
+        StyleEmptyView styleEmptyView = StyleEmptyView.getInstance(getActivity()).setEmptyText(getString(R.string.style_video_empty_text))
+                .setOpeBtn(getString(R.string.goto_upload))
+                .setEmptyIcon(R.mipmap.teacher_style_empty_icon)
+                .setOpeBtnClickListener(v -> {
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_STYLE_PAGE)
+                            .navigation();
+                });
+        mStyleVideoListAdapter.setEmptyView(styleEmptyView);
+
         mFansGroupListAdapter = new MineStyleFansGroupListAdapter(R.layout.item_mine_style_fans_group_layout);
         mViewBinding.recyclerViewFans.setLayoutManager(new LinearLayoutManager(getContext()));
         mViewBinding.recyclerViewFans.setAdapter(mFansGroupListAdapter);
         mViewBinding.recyclerView.setNestedScrollingEnabled(false);
         mViewBinding.recyclerViewFans.setNestedScrollingEnabled(false);
+        StyleEmptyView fansEmptyView = StyleEmptyView.getInstance(getActivity())
+                .setEmptyIcon(R.mipmap.teacher_fans_empty_icon)
+                .setEmptyText(getString(R.string.fans_empty_text))
+                .setOpeBtn(getString(R.string.goto_create))
+                .setOpeBtnClickListener(v -> {
+                    ARouter.getInstance().build(RouterPath.ChatCenter.CHAT_CREATE_GROUP)
+                            .navigation();
+                });
+        mFansGroupListAdapter.setEmptyView(fansEmptyView);
     }
 
     @Override
     protected void initData() {
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
         presenter.getTeacherSelfStyle();
     }
 
@@ -66,8 +92,15 @@ public class MineStyleFragment extends BaseMVPFragment<FragmentMineStyleLayoutBi
         }
         //个人介绍
         if (TextUtils.isEmpty(styleInfoBean.introduction)) {
-
+            mViewBinding.tvSelfIntroduction.setVisibility(View.GONE);
+            mViewBinding.selfIntroductionEmpty.setVisibility(View.VISIBLE);
+            mViewBinding.selfIntroductionEmpty.setOpeBtnClickListener(v -> {
+                ARouter.getInstance().build(RouterPath.MineCenter.MINE_STYLE_PAGE)
+                        .navigation();
+            });
         } else {
+            mViewBinding.tvSelfIntroduction.setVisibility(View.VISIBLE);
+            mViewBinding.selfIntroductionEmpty.setVisibility(View.GONE);
             mViewBinding.tvSelfIntroduction.setText(styleInfoBean.introduction);
         }
         //视频信息

+ 85 - 0
teacher/src/main/java/com/cooleshow/teacher/widgets/StyleEmptyView.java

@@ -0,0 +1,85 @@
+package com.cooleshow.teacher.widgets;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.cooleshow.teacher.R;
+
+import cz.msebera.android.httpclient.client.protocol.ClientContextConfigurer;
+
+/**
+ * @author dengqw
+ * @time 2022/6/26 16:55
+ * @describe:
+ **/
+public class StyleEmptyView extends FrameLayout {
+
+    private ImageView mEmptyIcon;
+    private TextView mEmptyText;
+    private TextView mOpeBtn;
+    private int mEmptyIconRes;
+    private String mEmptyTextString;
+    private String mOpeBtnTextString;
+
+    public StyleEmptyView(@NonNull Context context) {
+        this(context, null, -1);
+    }
+
+    public StyleEmptyView(@NonNull Context context, @Nullable AttributeSet attrs) {
+        this(context, attrs, -1);
+    }
+
+    public StyleEmptyView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.teacher_main_style);
+        mEmptyIconRes = array.getResourceId(R.styleable.teacher_main_style_empty_icon, 0);
+        mEmptyTextString = array.getString(R.styleable.teacher_main_style_empty_text);
+        mOpeBtnTextString = array.getString(R.styleable.teacher_main_style_ope_btn);
+        array.recycle();
+        initView();
+    }
+
+    private void initView() {
+        View view = View.inflate(getContext(), R.layout.teacher_empty_view, this);
+        mEmptyIcon = view.findViewById(R.id.empty_icon);
+        mEmptyText = view.findViewById(R.id.empty_text);
+        mOpeBtn = view.findViewById(R.id.ope_btn);
+
+        mEmptyIcon.setImageResource(mEmptyIconRes);
+        mEmptyText.setText(mEmptyTextString);
+        mOpeBtn.setText(mOpeBtnTextString);
+    }
+
+    public static StyleEmptyView getInstance(Context context) {
+        StyleEmptyView emptyView = new StyleEmptyView(context);
+        return emptyView;
+    }
+
+    public StyleEmptyView setEmptyIcon(int resId) {
+        mEmptyIcon.setImageResource(resId);
+        return this;
+    }
+
+    public StyleEmptyView setEmptyText(String text) {
+        mEmptyText.setText(text);
+        return this;
+    }
+
+    public StyleEmptyView setOpeBtn(String text) {
+        mOpeBtn.setText(text);
+        return this;
+    }
+
+    public StyleEmptyView setOpeBtnClickListener(OnClickListener listener) {
+        mOpeBtn.setOnClickListener(listener);
+        return this;
+    }
+}

+ 0 - 27
teacher/src/main/java/com/cooleshow/teacher/widgets/TeacherEmptyView.java

@@ -1,27 +0,0 @@
-package com.cooleshow.teacher.widgets;
-
-import android.content.Context;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import androidx.annotation.NonNull;
-
-import com.cooleshow.teacher.R;
-
-/**
- * @author dengqw
- * @time 2022/6/26 16:55
- * @describe:
- **/
-public class TeacherEmptyView extends FrameLayout {
-
-    public TeacherEmptyView(@NonNull Context context) {
-        super(context);
-        initView();
-    }
-
-    private void initView() {
-        View view = View.inflate(getContext(), R.layout.teacher_empty_view,this);
-//        view.findViewById()
-    }
-}

+ 0 - 0
teacher/src/main/res/drawable-v23/bg_splash.xml → teacher/src/main/res/drawable/bg_splash.xml


+ 40 - 21
teacher/src/main/res/layout/fragment_mine_style_layout.xml

@@ -2,25 +2,25 @@
 <androidx.core.widget.NestedScrollView 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:paddingTop="14dp"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:overScrollMode="never"
+    android:paddingTop="14dp"
     android:scrollbars="none">
 
     <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingBottom="14dp"
         android:paddingStart="14dp"
-        android:paddingEnd="14dp">
+        android:paddingEnd="14dp"
+        android:paddingBottom="14dp">
 
         <View
             android:id="@+id/view_top_bg"
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:background="@drawable/bg_white_10dp"
-            app:layout_constraintBottom_toBottomOf="@+id/tv_self_introduction"
+            app:layout_constraintBottom_toBottomOf="@+id/introduction_view"
             app:layout_constraintLeft_toLeftOf="parent"
             app:layout_constraintRight_toRightOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
@@ -48,21 +48,41 @@
             app:layout_constraintLeft_toRightOf="@+id/iv_self_introduction"
             app:layout_constraintTop_toTopOf="@+id/iv_self_introduction" />
 
-        <TextView
-            android:id="@+id/tv_self_introduction"
-            android:layout_width="0dp"
+        <LinearLayout
+            android:id="@+id/introduction_view"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="12dp"
-            android:paddingTop="20dp"
-            android:paddingEnd="12dp"
-            android:paddingBottom="20dp"
-            android:textColor="@color/color_666666"
-            android:textSize="@dimen/sp_13"
-            app:layout_constraintLeft_toLeftOf="@+id/view_top_bg"
-            app:layout_constraintRight_toRightOf="@+id/view_top_bg"
-            app:layout_constraintTop_toBottomOf="@+id/iv_self_introduction"
-            tools:text="毕业于中央音乐学员长笛专业,师从央音长笛系曾获2016年锦绣杯长笛大赛冠军自2018年起研究长笛启蒙、考级到专业考试教育总结出一套适合各个阶段需要的教学方式" />
-
+            android:orientation="vertical"
+            app:layout_constraintTop_toBottomOf="@+id/iv_self_introduction">
+
+            <TextView
+                android:id="@+id/tv_self_introduction"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:paddingStart="12dp"
+                android:paddingTop="20dp"
+                android:paddingEnd="12dp"
+                android:paddingBottom="20dp"
+                android:textColor="@color/color_666666"
+                android:textSize="@dimen/sp_13"
+                android:visibility="gone"
+                app:layout_constraintLeft_toLeftOf="@+id/view_top_bg"
+                app:layout_constraintRight_toRightOf="@+id/view_top_bg"
+                app:layout_constraintTop_toBottomOf="@+id/iv_self_introduction"
+                tools:text="毕业于中央音乐学员长笛专业,师从央音长笛系曾获2016年锦绣杯长笛大赛冠军自2018年起研究长笛启蒙、考级到专业考试教育总结出一套适合各个阶段需要的教学方式" />
+
+            <com.cooleshow.teacher.widgets.StyleEmptyView
+                android:id="@+id/self_introduction_empty"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:paddingBottom="@dimen/dp_11"
+                android:visibility="gone"
+                app:empty_icon="@mipmap/teacher_introduce_empty_icon"
+                app:empty_text="@string/introduction_empty_text"
+                app:layout_constraintTop_toBottomOf="@+id/iv_self_introduction"
+                app:ope_btn="@string/goto_write"
+                tools:visibility="visible" />
+        </LinearLayout>
 
         <View
             android:id="@+id/view_video_bg"
@@ -99,12 +119,12 @@
             app:layout_constraintTop_toTopOf="@+id/iv_teacher_style" />
 
         <androidx.recyclerview.widget.RecyclerView
-            android:layout_marginStart="11dp"
-            android:layout_marginEnd="11dp"
             android:id="@+id/recyclerView"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
+            android:layout_marginStart="11dp"
             android:layout_marginTop="6dp"
+            android:layout_marginEnd="11dp"
             android:overScrollMode="never"
             android:scrollbars="none"
             app:layout_constraintLeft_toLeftOf="@+id/view_video_bg"
@@ -119,7 +139,6 @@
             app:layout_constraintLeft_toLeftOf="@+id/recyclerView"
             app:layout_constraintTop_toBottomOf="@+id/recyclerView" />
 
-
         <View
             android:id="@+id/view_fans_group_bg"
             android:layout_width="match_parent"

+ 26 - 10
teacher/src/main/res/layout/teacher_empty_view.xml

@@ -1,21 +1,37 @@
 <?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content">
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingBottom="@dimen/dp_10"
+    android:paddingTop="@dimen/dp_7"
+    android:gravity="center"
+    android:orientation="vertical">
 
     <ImageView
         android:id="@+id/empty_icon"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
+        android:src="@mipmap/teacher_fans_empty_icon" />
 
     <TextView
+        android:id="@+id/empty_text"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/empty_icon" />
-</androidx.constraintlayout.widget.ConstraintLayout>
+        android:layout_marginTop="@dimen/dp_1"
+        android:textColor="@color/color_999999"
+        android:textSize="@dimen/sp_13"
+        tools:text="暂无粉丝群" />
+
+    <TextView
+        android:id="@+id/ope_btn"
+        android:layout_width="@dimen/dp_77"
+        android:layout_height="@dimen/dp_30"
+        android:layout_marginTop="@dimen/dp_10"
+        android:background="@drawable/bg_i_konw_btn"
+        android:gravity="center"
+        android:textColor="@color/color_2dc7aa"
+        android:textSize="@dimen/sp_14"
+        tools:text="去创建" />
+</androidx.appcompat.widget.LinearLayoutCompat>

BIN
teacher/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
teacher/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
teacher/src/main/res/mipmap-xhdpi/teacher_fans_empty_icon.png


BIN
teacher/src/main/res/mipmap-xhdpi/teacher_introduce_empty_icon.png


BIN
teacher/src/main/res/mipmap-xhdpi/teacher_style_empty_icon.png


BIN
teacher/src/main/res/mipmap-xxhdpi/teacher_fans_empty_icon.png


BIN
teacher/src/main/res/mipmap-xxhdpi/teacher_introduce_empty_icon.png


BIN
teacher/src/main/res/mipmap-xxhdpi/teacher_style_empty_icon.png


BIN
teacher/src/main/res/mipmap-xxxhdpi/teacher_fans_empty_icon.png


BIN
teacher/src/main/res/mipmap-xxxhdpi/teacher_introduce_empty_icon.png


BIN
teacher/src/main/res/mipmap-xxxhdpi/teacher_style_empty_icon.png


+ 6 - 0
teacher/src/main/res/values/strings.xml

@@ -39,4 +39,10 @@
     <string name="finish_live_tip_str">结束直播后,不可再次开启</string>
     <string name="net_error_tip">网络已断开</string>
     <string name="live_delay_text">%1$dms</string>
+    <string name="introduction_empty_text">暂无介绍内容~</string>
+    <string name="goto_write">去填写</string>
+    <string name="style_video_empty_text">暂无风采视频~</string>
+    <string name="fans_empty_text">暂无粉丝群~</string>
+    <string name="goto_upload">去上传</string>
+    <string name="goto_create">去创建</string>
 </resources>

+ 10 - 0
teacher/src/main/res/values/styles.xml

@@ -18,6 +18,7 @@
     <style name="HomeRatingBar" parent="@android:style/Widget.RatingBar">
         <item name="android:progressDrawable">@drawable/home_rating_bar</item>
     </style>
+
     <style name="tab_layout_style" parent="TextAppearance.Design.Tab">
         <item name="textAllCaps">false</item>
         <item name="android:textSize">@dimen/sp_14</item>
@@ -29,6 +30,7 @@
         <item name="android:windowIsFloating">true</item>
         <item name="android:windowAnimationStyle">@style/DialogAnimStyle</item>
     </style>
+
     <style name="DialogAnimStyle" parent="@android:style/Animation.Activity">
         <item name="android:windowEnterAnimation">@anim/modal_in</item>
         <item name="android:windowExitAnimation">@anim/modal_out</item>
@@ -37,6 +39,7 @@
         <item name="android:activityCloseEnterAnimation">@anim/modal_in</item>
         <item name="android:activityCloseExitAnimation">@anim/modal_out</item>
     </style>
+
     <style name="NavPage">
         <item name="android:layout_width">fill_parent</item>
         <item name="android:layout_height">fill_parent</item>
@@ -45,6 +48,7 @@
         <!-- <item name="android:background">@drawable/nav_page</item> -->
         <item name="android:background">#FFE1E8EB</item>
     </style>
+
     <style name="MyBottomDialogStyle" parent="@android:style/Theme.Holo.Dialog">
         <!-- 是否有边框 -->
         <item name="android:windowFrame">@null</item>
@@ -77,4 +81,10 @@
         <!-- 还可以加入一些弹出和退出的动画 (lan)-->
         <item name="android:windowAnimationStyle">@style/BottomAnimation</item>
     </style>
+
+    <declare-styleable name="teacher_main_style">
+        <attr name="empty_icon" format="reference" />
+        <attr name="empty_text" format="string" />
+        <attr name="ope_btn" format="string" />
+    </declare-styleable>
 </resources>