Forráskód Böngészése

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

王鹏鹏 1 éve
szülő
commit
b2073c6fb7

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

@@ -53,10 +53,8 @@ public class GlideImgUtil {
         Glide.with(context).load(imgUrl).apply(options).into(img);
     }
 
-    public static void loadImgHeadCircle(Context context, String imgUrl, ImageView img, int dPlaceHolder, int dError) {
+    public static void loadImgHeadCircle(Context context, String imgUrl, ImageView img) {
         RequestOptions options = new RequestOptions()
-                .placeholder(dPlaceHolder)
-                .error(dError)
                 .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                 .diskCacheStrategy(DiskCacheStrategy.NONE);
 

+ 2 - 2
config.gradle

@@ -13,8 +13,8 @@ ext {
             applicationId    : "com.yingyangfly",
             minSdkVersion    : 19,
             targetSdkVersion : 30,
-            versionCode      : 4,
-            versionName      : "1.0.0",
+            versionCode      : 1,
+            versionName      : "1.0.0.1",
     ]
     //androidx配置
     androidx = [

+ 6 - 3
evaluation/src/main/java/com/yingyangfly/evaluation/entity/SlideShowListBean.kt

@@ -4,10 +4,13 @@ package com.yingyangfly.evaluation.entity
  * 首页轮播图
  */
 data class SlideShowListBean(
-    val location: String, val logo: String, val slideshows: List<SlideshowBean>
+    val orgName: String,
+    val location: String,
+    val logo: String,
+    val slideshow: Slideshow
 )
 
-data class SlideshowBean(
+data class Slideshow(
     val createBy: String,
     val createTime: String,
     val equipmentType: String,
@@ -16,7 +19,7 @@ data class SlideshowBean(
     val location: String,
     val orgCode: String,
     val orgName: String,
-    val speed: Int,
+    val speed: Long,
     val status: String,
     val targetLinkUrl: String,
     val updateBy: String,

+ 5 - 6
evaluation/src/main/java/com/yingyangfly/evaluation/hospital/GuidePageAdapter.java

@@ -12,7 +12,6 @@ import androidx.recyclerview.widget.RecyclerView;
 import com.yingyangfly.baselib.utils.GlideImgUtil;
 import com.yingyangfly.baselib.utils.ViewTool;
 import com.yingyangfly.evaluation.R;
-import com.yingyangfly.evaluation.entity.SlideshowBean;
 import com.youth.banner.adapter.BannerAdapter;
 
 import java.util.List;
@@ -23,16 +22,16 @@ import java.util.List;
  * @copyright (C) 2019-2022, XiaoLiu All Rights Reserved
  * @description 轮播图适配器
  */
-public class GuidePageAdapter extends BannerAdapter<SlideshowBean, GuidePageAdapter.HomeBannerHolder> {
+public class GuidePageAdapter extends BannerAdapter<String, GuidePageAdapter.HomeBannerHolder> {
 
     private Context mContext;
 
-    public GuidePageAdapter(List<SlideshowBean> datas, Context mContext) {
+    public GuidePageAdapter(List<String> datas, Context mContext) {
         this(datas);
         this.mContext = mContext;
     }
 
-    public GuidePageAdapter(List<SlideshowBean> datas) {
+    public GuidePageAdapter(List<String> datas) {
         super(datas);
     }
 
@@ -44,8 +43,8 @@ public class GuidePageAdapter extends BannerAdapter<SlideshowBean, GuidePageAdap
     }
 
     @Override
-    public void onBindView(HomeBannerHolder holder, SlideshowBean data, int position, int size) {
-        GlideImgUtil.loadImg(mContext, data.getImgUrl(), holder.img);
+    public void onBindView(HomeBannerHolder holder, String data, int position, int size) {
+        GlideImgUtil.loadImg(mContext, data, holder.img);
     }
 
     public class HomeBannerHolder extends RecyclerView.ViewHolder {

+ 33 - 24
evaluation/src/main/java/com/yingyangfly/evaluation/hospital/HospitalActivity.kt

@@ -25,7 +25,6 @@ import com.yingyangfly.baselib.utils.RxBusCodes
 import com.yingyangfly.baselib.utils.User
 import com.yingyangfly.evaluation.R
 import com.yingyangfly.evaluation.databinding.ActivityHospitalBinding
-import com.yingyangfly.evaluation.entity.SlideshowBean
 import com.youth.banner.indicator.RectangleIndicator
 
 
@@ -37,8 +36,9 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
     View.OnTouchListener {
 
     private lateinit var adapterGuide: GuidePageAdapter
-    private var imageList = mutableListOf<SlideshowBean>()
+    private var imageList = mutableListOf<String>()
 
+    private var snCode = ""
     private var reviewTaskId = ""
     private var taskId = ""
 
@@ -76,14 +76,6 @@ 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() {
@@ -112,10 +104,8 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
             val voicePlayerDao = db?.getVoicePlayerDao()
             if (voicePlayerDao != null) {
                 val voicePlayerBean = voicePlayerDao.getVoicePlayerBean(desn)
-                if (voicePlayerBean != null) {
-                    if (voicePlayer != null) {
-                        voicePlayer?.play(voicePlayerBean.url) {}
-                    }
+                if (voicePlayerBean != null && voicePlayer != null) {
+                    voicePlayer?.play(voicePlayerBean.url) {}
                 } else {
                     getVoiceUrl(desn)
                 }
@@ -201,6 +191,7 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
         return true
     }
 
+    @SuppressLint("SetTextI18n")
     override fun onResume() {
         super.onResume()
         if (TextUtils.isEmpty(User.getToken())) {
@@ -210,6 +201,17 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
             binding.imageLoginOut.show(true)
             binding.tvLoginOut.show(true)
         }
+        PermissionList.readPhoneState.check(this) {
+            snCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+                Build.getSerial()
+            } else {
+                Build.SERIAL
+            }
+            binding.tvSnCode.text = "终端号:$snCode"
+            if (TextUtils.isEmpty(snCode).not()) {
+                getSlideShowList()
+            }
+        }
     }
 
     /**
@@ -217,22 +219,29 @@ class HospitalActivity : BaseTvMVVMActivity<ActivityHospitalBinding, HospitalVie
      */
     @SuppressLint("NotifyDataSetChanged", "SetTextI18n")
     private fun getSlideShowList() {
-        viewModel.getSlideShowList(Build.SERIAL, fail = {
+        viewModel.getSlideShowList(snCode, fail = {
             it.toast()
         }, success = {
             imageList.clear()
             if (it != null) {
-                if (it.slideshows.isNullOrEmpty().not()) {
-                    val data = it.slideshows[0]
-                    binding.guide.setLoopTime(data.speed.toLong())
-                    imageList.addAll(it.slideshows)
+                if (it.slideshow != null) {
+                    it.slideshow.let {
+                        binding.guide.setLoopTime(it.speed * 1000)
+                        if (it.imgUrl.contains(",")) {
+                            val data = it.imgUrl.split(",")
+                            imageList.addAll(data)
+                        } else {
+                            imageList.add(it.imgUrl)
+                        }
+                    }
+                }
+                if (TextUtils.isEmpty(it.logo).not()) {
+                    GlideImgUtil.loadImgHeadCircle(mContext, it.logo, binding.hospitalImage)
                 }
-                if (TextUtils.isEmpty(it.logo)) {
-                    GlideImgUtil.loadImg(mContext, it.logo, binding.hospitalImage)
+                binding.tvOrgName.text = if (TextUtils.isEmpty(it.orgName)) {
+                    ""
                 } else {
-                    GlideImgUtil.loadImgNoPlaceHolder(
-                        mContext, R.mipmap.icon_hospital_logo, binding.hospitalImage
-                    )
+                    it.orgName
                 }
                 binding.tvLocation.text = "终端位置:" + if (TextUtils.isEmpty(it.location)) {
                     ""

+ 8 - 7
evaluation/src/main/res/layout/activity_hospital.xml

@@ -20,10 +20,11 @@
             app:layout_constraintTop_toTopOf="parent" />
 
         <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvOrgName"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginStart="@dimen/divider_23px"
-            android:layout_marginTop="@dimen/divider_58px"
+            android:layout_marginTop="@dimen/divider_75px"
             android:text="@string/hospital_name"
             android:textColor="@android:color/white"
             android:textSize="@dimen/divider_28px"
@@ -122,8 +123,8 @@
             app:layout_constraintTop_toBottomOf="@+id/searchLayout">
 
             <androidx.appcompat.widget.AppCompatImageView
-                android:layout_width="@dimen/divider_133px"
-                android:layout_height="@dimen/divider_133px"
+                android:layout_width="@dimen/divider_80px"
+                android:layout_height="@dimen/divider_80px"
                 android:layout_marginTop="@dimen/divider_36px"
                 android:background="@mipmap/icon_other_evaluations"
                 android:scaleType="centerInside" />
@@ -154,8 +155,8 @@
             app:layout_constraintTop_toBottomOf="@+id/searchLayout">
 
             <androidx.appcompat.widget.AppCompatImageView
-                android:layout_width="@dimen/divider_81px"
-                android:layout_height="@dimen/divider_81px"
+                android:layout_width="@dimen/divider_52px"
+                android:layout_height="@dimen/divider_52px"
                 android:background="@mipmap/icon_moca"
                 android:scaleType="centerInside" />
 
@@ -185,8 +186,8 @@
             app:layout_constraintTop_toBottomOf="@+id/mocaLayout">
 
             <androidx.appcompat.widget.AppCompatImageView
-                android:layout_width="@dimen/divider_81px"
-                android:layout_height="@dimen/divider_81px"
+                android:layout_width="@dimen/divider_52px"
+                android:layout_height="@dimen/divider_52px"
                 android:background="@mipmap/icon_mmse"
                 android:scaleType="centerInside" />
 

+ 1 - 1
evaluation/src/main/res/layout/item_guide.xml

@@ -17,7 +17,7 @@
             android:id="@+id/guideImage"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:scaleType="centerCrop" />
+            android:scaleType="fitXY" />
 
     </com.google.android.material.card.MaterialCardView>
 

+ 1 - 1
evaluation/src/main/res/values/strings.xml

@@ -67,7 +67,7 @@
     <string name="hospital_name" tools:ignore="ResourceName">首都医科大学宣武医院</string>
     <string name="exit_binding" tools:ignore="ResourceName">退出绑定</string>
     <string name="report_query" tools:ignore="ResourceName">报告查询</string>
-    <string name="other_evaluations" tools:ignore="ResourceName">其他测评</string>
+    <string name="other_evaluations" tools:ignore="ResourceName">智能测评</string>
     <string name="evaluation" tools:ignore="ResourceName">测评</string>
     <string name="continues" tools:ignore="ResourceName">继续</string>
     <string name="previous_question" tools:ignore="ResourceName">上一题</string>