Browse Source

1.添加获取首页轮播图接口

王鹏鹏 2 years ago
parent
commit
5358eb2585

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -7,6 +7,7 @@
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 
     <application
         android:name=".MyApplication"

+ 12 - 11
baselib/src/main/java/com/yingyangfly/baselib/dialog/BindingPhoneDialog.kt

@@ -11,6 +11,7 @@ import android.view.View
 import android.view.ViewGroup
 import androidx.appcompat.widget.AppCompatButton
 import androidx.appcompat.widget.AppCompatEditText
+import androidx.appcompat.widget.AppCompatImageView
 import androidx.fragment.app.DialogFragment
 import com.gyf.immersionbar.BarHide
 import com.gyf.immersionbar.ktx.immersionBar
@@ -30,6 +31,7 @@ import io.reactivex.schedulers.Schedulers
  */
 class BindingPhoneDialog : DialogFragment() {
 
+    private var imageClose: AppCompatImageView? = null
     private var editPhone: AppCompatEditText? = null
     private var editCode: AppCompatEditText? = null
     private var btnCode: AppCompatButton? = null
@@ -48,16 +50,13 @@ class BindingPhoneDialog : DialogFragment() {
     override fun onStart() {
         super.onStart()
         dialog?.window?.setLayout(
-            ViewGroup.LayoutParams.MATCH_PARENT,
-            ViewGroup.LayoutParams.MATCH_PARENT
+            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
         )
         dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
     }
 
     override fun onCreateView(
-        inflater: LayoutInflater,
-        container: ViewGroup?,
-        savedInstanceState: Bundle?
+        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
     ): View? {
         immersionBar {
             hideBar(BarHide.FLAG_HIDE_BAR)
@@ -74,6 +73,7 @@ class BindingPhoneDialog : DialogFragment() {
     }
 
     private fun findId(rootView: View) {
+        imageClose = rootView.findViewById(R.id.imageClose)
         editPhone = rootView.findViewById(R.id.editPhone)
         editCode = rootView.findViewById(R.id.editCode)
         btnCode = rootView.findViewById(R.id.btnCode)
@@ -103,6 +103,10 @@ class BindingPhoneDialog : DialogFragment() {
                 }
             }
         }
+
+        imageClose?.click {
+            dismiss()
+        }
     }
 
     /**
@@ -124,10 +128,8 @@ class BindingPhoneDialog : DialogFragment() {
      * 发送验证码
      */
     private fun sendCode() {
-        BaselibServiceFactory.getService()
-            .getCheckCode(editPhone?.text.toString().trim())
-            .subscribeOn(Schedulers.io())
-            .compose(MyRxScheduler.ioMain(mContent!!, true))
+        BaselibServiceFactory.getService().getCheckCode(editPhone?.text.toString().trim())
+            .subscribeOn(Schedulers.io()).compose(MyRxScheduler.ioMain(mContent!!, true))
             .subscribe(object : BaseObserver<Any>() {
                 override fun onSuccess(t: Any?) {
                     timer()
@@ -145,8 +147,7 @@ class BindingPhoneDialog : DialogFragment() {
     private fun login() {
         BaselibServiceFactory.getService()
             .largeLoginMsg(editPhone?.text.toString().trim(), editCode?.text.toString().trim())
-            .subscribeOn(Schedulers.io())
-            .compose(MyRxScheduler.ioMain(mContent!!, true))
+            .subscribeOn(Schedulers.io()).compose(MyRxScheduler.ioMain(mContent!!, true))
             .subscribe(object : BaseObserver<String>() {
                 override fun onSuccess(t: String?) {
                     if (TextUtils.isEmpty(t).not()) {

+ 1 - 1
baselib/src/main/java/com/yingyangfly/baselib/utils/GlideImgUtil.java

@@ -83,7 +83,7 @@ public class GlideImgUtil {
         Glide.with(context).load(imgUrl).apply(options).into(img);
     }
 
-    public static void loadImgNoPlaceHolder(Context context, String imgUrl, ImageView img) {
+    public static void loadImgNoPlaceHolder(Context context, int imgUrl, ImageView img) {
         RequestOptions options = new RequestOptions()
                 .diskCacheStrategy(DiskCacheStrategy.ALL);
         Glide.with(context).load(imgUrl).apply(options).into(img);

+ 12 - 3
baselib/src/main/res/layout/dialog_binding_phone.xml

@@ -5,6 +5,7 @@
     android:layout_height="match_parent">
 
     <com.google.android.material.card.MaterialCardView
+        android:id="@+id/dialogLayout"
         android:layout_width="@dimen/divider_670px"
         android:layout_height="@dimen/divider_524px"
         android:theme="@style/Theme.MaterialComponents.NoActionBar"
@@ -113,10 +114,18 @@
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toBottomOf="@+id/codeLayout" />
-
-
         </androidx.constraintlayout.widget.ConstraintLayout>
-
     </com.google.android.material.card.MaterialCardView>
 
+    <androidx.appcompat.widget.AppCompatImageView
+        android:id="@+id/imageClose"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="end|top"
+        android:layout_marginStart="@dimen/divider_20px"
+        android:layout_marginBottom="@dimen/divider_20px"
+        android:background="@mipmap/icon_close_dialog"
+        app:layout_constraintBottom_toTopOf="@+id/dialogLayout"
+        app:layout_constraintStart_toEndOf="@+id/dialogLayout" />
+
 </androidx.constraintlayout.widget.ConstraintLayout>

BIN
baselib/src/main/res/mipmap-xxhdpi/icon_close_dialog.png


BIN
baselib/src/main/res/mipmap-xxhdpi/icon_delect_image.png


+ 1 - 2
evaluation/src/main/java/com/yingyangfly/evaluation/entity/SlideShowListBean.kt

@@ -4,8 +4,7 @@ package com.yingyangfly.evaluation.entity
  * 首页轮播图
  */
 data class SlideShowListBean(
-    val location: String,
-    val slideshows: List<SlideshowBean>
+    val location: String, val logo: String, val slideshows: List<SlideshowBean>
 )
 
 data class SlideshowBean(

+ 40 - 13
evaluation/src/main/java/com/yingyangfly/evaluation/hospital/HospitalActivity.kt

@@ -18,6 +18,7 @@ import com.yingyangfly.baselib.ext.toast
 import com.yingyangfly.baselib.mvvm.BaseTvMVVMActivity
 import com.yingyangfly.baselib.player.VoicePlayer
 import com.yingyangfly.baselib.router.RouterUrlCommon
+import com.yingyangfly.baselib.utils.GlideImgUtil
 import com.yingyangfly.baselib.utils.JumpUtil
 import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
@@ -27,6 +28,7 @@ import com.yingyangfly.evaluation.databinding.ActivityHospitalBinding
 import com.yingyangfly.evaluation.entity.SlideshowBean
 import com.youth.banner.indicator.RectangleIndicator
 
+
 /**
  * 医院电视端首页
  */
@@ -74,6 +76,14 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
 
     override fun initData() {
         initLiveData()
+        PermissionList.readPhoneState.check(this) {
+            binding.tvSnCode.text = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+                "终端号:" + Build.getSerial()
+            } else {
+                "终端号:" + Build.SERIAL
+            }
+            getSlideShowList()
+        }
     }
 
     private fun initLiveData() {
@@ -157,19 +167,27 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
                     }
 
                     R.id.searchLayout -> {
-                        JumpUtil.jumpActivity(RouterUrlCommon.evaluationHistory)
+                        if (loginJudge()) {
+                            JumpUtil.jumpActivity(RouterUrlCommon.evaluationHistory)
+                        }
                     }
 
                     R.id.otherEvaluationsLayout -> {
-                        JumpUtil.jumpActivity(RouterUrlCommon.otherEvaluation)
+                        if (loginJudge()) {
+                            JumpUtil.jumpActivity(RouterUrlCommon.otherEvaluation)
+                        }
                     }
 
                     R.id.mocaLayout -> {
-                        getReviewTaskList("MOCA", "0")
+                        if (loginJudge()) {
+                            getReviewTaskList("MOCA", "0")
+                        }
                     }
 
                     R.id.mmseLayout -> {
-                        getReviewTaskList("MMSE", "0")
+                        if (loginJudge()) {
+                            getReviewTaskList("MMSE", "0")
+                        }
                     }
                 }
             }
@@ -188,19 +206,10 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
         if (TextUtils.isEmpty(User.getToken())) {
             binding.imageLoginOut.show(false)
             binding.tvLoginOut.show(false)
-            showBindingPhoneDialog()
         } else {
             binding.imageLoginOut.show(true)
             binding.tvLoginOut.show(true)
         }
-        PermissionList.readPhoneState.check(this) {
-            binding.tvSnCode.text = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
-                "终端号:" + Build.getSerial()
-            } else {
-                "终端号:" + Build.SERIAL
-            }
-        }
-        getSlideShowList()
     }
 
     /**
@@ -218,6 +227,13 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
                     binding.guide.setLoopTime(data.speed.toLong())
                     imageList.addAll(it.slideshows)
                 }
+                if (TextUtils.isEmpty(it.logo)) {
+                    GlideImgUtil.loadImg(mContext, it.logo, binding.hospitalImage)
+                } else {
+                    GlideImgUtil.loadImgNoPlaceHolder(
+                        mContext, R.mipmap.icon_hospital_logo, binding.hospitalImage
+                    )
+                }
                 binding.tvLocation.text = "终端位置:" + if (TextUtils.isEmpty(it.location)) {
                     ""
                 } else {
@@ -341,4 +357,15 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
             })
         }
     }
+
+    /**
+     * 登陆状态判断
+     */
+    private fun loginJudge(): Boolean {
+        if (TextUtils.isEmpty(User.getToken())) {
+            showBindingPhoneDialog()
+            return false
+        }
+        return true
+    }
 }

+ 1 - 1
evaluation/src/main/java/com/yingyangfly/evaluation/net/EvaluationApiService.kt

@@ -81,7 +81,7 @@ interface EvaluationApiService {
     /**
      * 查询轮播图列表
      */
-    @POST("slide-show/list")
+    @POST("home/index")
     suspend fun getSlideShowList(
         @Query("equipmentType") equipmentType: String, @Query("sn") sn: String
     ): BaseResp<SlideShowListBean>

+ 0 - 1
evaluation/src/main/res/layout/activity_hospital.xml

@@ -15,7 +15,6 @@
             android:layout_height="@dimen/divider_80px"
             android:layout_marginStart="@dimen/divider_47px"
             android:layout_marginTop="@dimen/divider_35px"
-            android:background="@mipmap/icon_hospital_logo"
             android:scaleType="centerInside"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent" />