Przeglądaj źródła

补充主页作业票数量显示

Frankensteinly 1 rok temu
rodzic
commit
38eeca82d8

+ 4 - 0
app/src/main/java/com/grkj/iscs/activity/HomeActivity.kt

@@ -30,6 +30,10 @@ class HomeActivity : BaseMvpActivity<IHomeView, HomePresenter, ActivityHomeBindi
             // TODO 退出登录,清除token
             finish()
         }
+
+        presenter?.getTicketCount {
+            mBinding?.tvCount?.text = it.toString()
+        }
     }
 
     override fun initPresenter(): HomePresenter {

+ 13 - 1
app/src/main/java/com/grkj/iscs/presenter/HomePresenter.kt

@@ -2,5 +2,17 @@ package com.grkj.iscs.presenter
 
 import com.grkj.iscs.base.BasePresenter
 import com.grkj.iscs.iview.IHomeView
+import com.grkj.iscs.model.vo.TicketPageRespVO
+import com.grkj.iscs.util.Executor
+import com.grkj.iscs.util.NetApi
 
-class HomePresenter : BasePresenter<IHomeView>() {}
+class HomePresenter : BasePresenter<IHomeView>() {
+
+    fun getTicketCount(callBack: (Int?) -> Unit) {
+        NetApi.getTicketPage(0, 10) {
+            Executor.runOnMain {
+                callBack.invoke(it?.total)
+            }
+        }
+    }
+}

+ 3 - 1
app/src/main/res/layout/activity_home.xml

@@ -77,7 +77,9 @@
                 style="@style/CommonTextView"
                 android:text="@string/current_sop_number" />
 
-            <TextView style="@style/CommonTextView" />
+            <TextView
+                android:id="@+id/tv_count"
+                style="@style/CommonTextView" />
         </LinearLayout>
 
         <androidx.constraintlayout.widget.Barrier