浏览代码

解决竖屏门口机多个床位无法自动滚动问题

weizhengliang 5 月之前
父节点
当前提交
fe358cf96e

+ 13 - 6
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/adapter/NewFrameRoomAdapter.kt

@@ -1,6 +1,7 @@
 package com.wdkl.app.ncs.callingdoor.adapter
 package com.wdkl.app.ncs.callingdoor.adapter
 
 
 import android.content.Context
 import android.content.Context
+import android.content.res.Configuration
 import android.graphics.drawable.Drawable
 import android.graphics.drawable.Drawable
 
 
 import android.text.TextUtils
 import android.text.TextUtils
@@ -29,6 +30,7 @@ class NewFrameRoomAdapter : RecyclerView.Adapter<NewFrameRoomAdapter.BedViewHold
     private var context: Context
     private var context: Context
     private var data: ArrayList<FrameBedVO>
     private var data: ArrayList<FrameBedVO>
     private var configList = ArrayList<NurseConfigDto>()
     private var configList = ArrayList<NurseConfigDto>()
+    private var countSize = 3
 
 
     constructor(context: Context, data: ArrayList<FrameBedVO>) {
     constructor(context: Context, data: ArrayList<FrameBedVO>) {
         this.context = context
         this.context = context
@@ -42,7 +44,7 @@ class NewFrameRoomAdapter : RecyclerView.Adapter<NewFrameRoomAdapter.BedViewHold
 
 
     override fun onBindViewHolder(holder: BedViewHolder, position: Int) {
     override fun onBindViewHolder(holder: BedViewHolder, position: Int) {
         try {
         try {
-            initDefaultNursingConfigs()
+            //initDefaultNursingConfigs()
             val pos = position % data.size
             val pos = position % data.size
             showBedInfo(holder, data.get(pos))
             showBedInfo(holder, data.get(pos))
 
 
@@ -52,7 +54,12 @@ class NewFrameRoomAdapter : RecyclerView.Adapter<NewFrameRoomAdapter.BedViewHold
     }
     }
 
 
     override fun getItemCount(): Int {
     override fun getItemCount(): Int {
-        if (data.size <= 3) {
+        val orientation = context.resources.configuration.orientation
+        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+            countSize = 2
+        }
+
+        if (data.size <= countSize) {
             return data.size
             return data.size
         } else {
         } else {
             return Int.MAX_VALUE
             return Int.MAX_VALUE
@@ -66,14 +73,14 @@ class NewFrameRoomAdapter : RecyclerView.Adapter<NewFrameRoomAdapter.BedViewHold
 
 
     private fun initDefaultNursingConfigs() {
     private fun initDefaultNursingConfigs() {
         //初始化默认护理项
         //初始化默认护理项
-        configList.clear()
+        /*configList.clear()
         for (index in 1..5) {
         for (index in 1..5) {
             val item = NurseConfigDto()
             val item = NurseConfigDto()
             item.nurseConfigName = StringUtil.getResString(R.string.default_nurse_config_name)
             item.nurseConfigName = StringUtil.getResString(R.string.default_nurse_config_name)
             item.nurseOptionName = StringUtil.getResString(R.string.str_empty)
             item.nurseOptionName = StringUtil.getResString(R.string.str_empty)
             item.nurseColorRbg = "D7D7D7"
             item.nurseColorRbg = "D7D7D7"
             configList.add(item)
             configList.add(item)
-        }
+        }*/
     }
     }
 
 
     private fun showBedInfo(holder: BedViewHolder, bedVO: FrameBedVO) {
     private fun showBedInfo(holder: BedViewHolder, bedVO: FrameBedVO) {
@@ -152,7 +159,7 @@ class NewFrameRoomAdapter : RecyclerView.Adapter<NewFrameRoomAdapter.BedViewHold
         var bed_nurse_name : TextView
         var bed_nurse_name : TextView
         var bed_medic_info : TextView
         var bed_medic_info : TextView
         var bed_nurse_info : TextView
         var bed_nurse_info : TextView
-        var ll_one : HorizantalAutoBrLayout
+        //var ll_one : HorizantalAutoBrLayout
 
 
 
 
         constructor(itemView: View): super(itemView) {
         constructor(itemView: View): super(itemView) {
@@ -164,7 +171,7 @@ class NewFrameRoomAdapter : RecyclerView.Adapter<NewFrameRoomAdapter.BedViewHold
             bed_nurse_name = itemView.findViewById(R.id.bed_nurse_name)
             bed_nurse_name = itemView.findViewById(R.id.bed_nurse_name)
             bed_medic_info = itemView.findViewById(R.id.bed_medic_info)
             bed_medic_info = itemView.findViewById(R.id.bed_medic_info)
             bed_nurse_info = itemView.findViewById(R.id.bed_nurse_info)
             bed_nurse_info = itemView.findViewById(R.id.bed_nurse_info)
-            ll_one = itemView.findViewById(R.id.ll_one)
+            //ll_one = itemView.findViewById(R.id.ll_one)
         }
         }
     }
     }
 }
 }

+ 10 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/MainFragment.kt

@@ -4,6 +4,7 @@ import android.content.res.Configuration
 import android.graphics.Color
 import android.graphics.Color
 import android.os.Build
 import android.os.Build
 import android.text.TextUtils
 import android.text.TextUtils
+import android.util.Log
 import android.view.Gravity
 import android.view.Gravity
 import android.widget.TextView
 import android.widget.TextView
 import androidx.recyclerview.widget.DefaultItemAnimator
 import androidx.recyclerview.widget.DefaultItemAnimator
@@ -42,6 +43,8 @@ class MainFragment: BaseFragment<MainFragmentPresenter, MainViewLayoutBinding>()
     private var bedList = ArrayList<FrameBedVO>()
     private var bedList = ArrayList<FrameBedVO>()
     private var bedCalls = ArrayList<CallingItem>()
     private var bedCalls = ArrayList<CallingItem>()
 
 
+    private var scrollSize = 3
+
     override fun getLayId(): Int {
     override fun getLayId(): Int {
         return R.layout.main_view_layout
         return R.layout.main_view_layout
     }
     }
@@ -99,7 +102,13 @@ class MainFragment: BaseFragment<MainFragmentPresenter, MainViewLayoutBinding>()
             roomAdpter.setData(bedList)
             roomAdpter.setData(bedList)
             Utils.setInBedVos(bedList)
             Utils.setInBedVos(bedList)
             rv_bed_view.itemAnimator = DefaultItemAnimator()
             rv_bed_view.itemAnimator = DefaultItemAnimator()
-            if (bedList.size > 3) {
+
+            val orientation = resources.configuration.orientation
+            if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+                scrollSize = 2
+            }
+
+            if (bedList.size > scrollSize) {
                 //自动滚动显示
                 //自动滚动显示
                 rv_bed_view.start()
                 rv_bed_view.start()
             } else {
             } else {

+ 3 - 6
callingdoor/src/main/res/layout-land/item_bed.xml

@@ -53,7 +53,7 @@
             android:textSize="45sp"
             android:textSize="45sp"
             android:textStyle="bold" />
             android:textStyle="bold" />
 
 
-        <com.wdkl.ncs.android.lib.widget.MarqueeTextView
+        <TextView
             android:id="@+id/tv_bed_name"
             android:id="@+id/tv_bed_name"
             android:layout_width="wrap_content"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
@@ -61,9 +61,6 @@
             android:layout_marginLeft="@dimen/d8"
             android:layout_marginLeft="@dimen/d8"
             android:layout_below="@+id/tv_bed_name_title"
             android:layout_below="@+id/tv_bed_name_title"
             android:ellipsize="marquee"
             android:ellipsize="marquee"
-            android:focusable="true"
-            android:focusableInTouchMode="true"
-            android:marqueeRepeatLimit="-1"
             android:singleLine="true"
             android:singleLine="true"
             android:text="张小斐"
             android:text="张小斐"
             android:textColor="@color/text_room_color"
             android:textColor="@color/text_room_color"
@@ -71,7 +68,7 @@
 
 
     </RelativeLayout>
     </RelativeLayout>
 
 
-    <RelativeLayout
+    <!--<RelativeLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="@dimen/d180"
         android:layout_height="@dimen/d180"
         android:layout_marginTop="@dimen/d20"
         android:layout_marginTop="@dimen/d20"
@@ -106,7 +103,7 @@
             android:layout_marginRight="@dimen/d30"
             android:layout_marginRight="@dimen/d30"
             android:padding="10dp" />
             android:padding="10dp" />
 
 
-    </RelativeLayout>
+    </RelativeLayout>-->
 
 
     <LinearLayout
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"

+ 6 - 11
callingdoor/src/main/res/layout/item_bed.xml

@@ -1,13 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="@dimen/d500"
-    android:layout_height="@dimen/d330"
-    android:layout_marginRight="@dimen/d15"
+    android:layout_width="match_parent"
+    android:layout_height="344dp"
     android:layout_marginBottom="@dimen/d10"
     android:layout_marginBottom="@dimen/d10"
     android:background="@drawable/shape_bed_bg"
     android:background="@drawable/shape_bed_bg"
     android:orientation="vertical"
     android:orientation="vertical"
-    android:padding="@dimen/d12"
-    android:paddingLeft="4dp">
+    android:padding="@dimen/d10">
 
 
     <RelativeLayout
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
@@ -27,7 +25,7 @@
             android:textSize="60sp"
             android:textSize="60sp"
             android:textStyle="bold" />
             android:textStyle="bold" />
 
 
-        <com.wdkl.ncs.android.lib.widget.MarqueeTextView
+        <TextView
             android:id="@+id/tv_bed_name"
             android:id="@+id/tv_bed_name"
             android:layout_width="wrap_content"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
@@ -35,9 +33,6 @@
             android:layout_marginTop="@dimen/d20"
             android:layout_marginTop="@dimen/d20"
             android:layout_toRightOf="@+id/tv_bed_name_title"
             android:layout_toRightOf="@+id/tv_bed_name_title"
             android:ellipsize="marquee"
             android:ellipsize="marquee"
-            android:focusable="true"
-            android:focusableInTouchMode="true"
-            android:marqueeRepeatLimit="-1"
             android:singleLine="true"
             android:singleLine="true"
             android:text="张小斐"
             android:text="张小斐"
             android:textColor="@color/text_room_color"
             android:textColor="@color/text_room_color"
@@ -82,7 +77,7 @@
         </LinearLayout>
         </LinearLayout>
     </RelativeLayout>
     </RelativeLayout>
 
 
-    <RelativeLayout
+    <!--<RelativeLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="@dimen/d180"
         android:layout_height="@dimen/d180"
         android:layout_marginTop="@dimen/d20"
         android:layout_marginTop="@dimen/d20"
@@ -117,7 +112,7 @@
             android:layout_marginRight="@dimen/d30"
             android:layout_marginRight="@dimen/d30"
             android:padding="10dp" />
             android:padding="10dp" />
 
 
-    </RelativeLayout>
+    </RelativeLayout>-->
 
 
     <LinearLayout
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"

+ 3 - 3
callingdoor/src/main/res/layout/main_view_layout.xml

@@ -151,10 +151,10 @@
             android:id="@+id/rv_bed_view"
             android:id="@+id/rv_bed_view"
             android:layout_width="match_parent"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_height="match_parent"
-            android:layout_marginLeft="@dimen/d15"
+            android:layout_marginLeft="@dimen/d10"
+            android:layout_marginRight="@dimen/d10"
             android:layout_marginTop="@dimen/d15"
             android:layout_marginTop="@dimen/d15"
-            android:overScrollMode="never"
-            android:paddingRight="@dimen/d10" />
+            android:overScrollMode="never" />
 
 
     </LinearLayout>
     </LinearLayout>
 </layout>
 </layout>