Parcourir la source

1.优化代码

王鹏鹏 il y a 2 ans
Parent
commit
e9a67a9c72

+ 3 - 4
workbenches/src/main/java/com/yingyang/workbenches/traincontent/TrainContentFragment.kt

@@ -39,10 +39,8 @@ class TrainContentFragment :
         binding.treatmentSpinner.onSpinnerItemSelectedListener =
             OnSpinnerItemSelectedListener { parent, view, position, id ->
                 val bean = binding.treatmentSpinner.selectedItem as TreatmentBean
-                binding {
-                    rvTrainingContent.show(true)
-                    emptyLayout.show(false)
-                }
+                adapter.showEmptyView = false
+                adapter.clearData()
                 findMyTask(bean.id)
             }
     }
@@ -91,6 +89,7 @@ class TrainContentFragment :
             if (it.isNullOrEmpty().not()) {
                 trainContentBeanList.addAll(it!!)
             }
+            adapter.showEmptyView = trainContentBeanList.isNullOrEmpty()
             adapter.setData(trainContentBeanList)
         })
     }

+ 0 - 15
workbenches/src/main/res/layout/fragment_train_content.xml

@@ -120,21 +120,6 @@
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toBottomOf="@+id/contentTitleLayout" />
-
-        <LinearLayout
-            android:id="@+id/emptyLayout"
-            style="@style/empty_linear_layout_style"
-            android:layout_height="0dp"
-            android:visibility="gone"
-            app:layout_constraintTop_toBottomOf="@+id/contentTitleLayout"
-            tools:ignore="MissingConstraints">
-
-            <androidx.appcompat.widget.AppCompatImageView style="@style/empty_image_view_style" />
-
-            <androidx.appcompat.widget.AppCompatTextView style="@style/empty_text_view_style" />
-
-        </LinearLayout>
-
     </androidx.constraintlayout.widget.ConstraintLayout>
 
 </layout>