changeset 2846:e6edeb2b63bc

Android: Fix container problems after a clear().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 18 Oct 2022 02:38:51 +0000
parents 64c528d38fb8
children ca3cc0e1c563
files android/DWindows.kt
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Mon Sep 26 08:35:26 2022 +0000
+++ b/android/DWindows.kt	Tue Oct 18 02:38:51 2022 +0000
@@ -2284,6 +2284,7 @@
     var imageview: ImageView = ImageView(context)
     var text: TextView = TextView(context)
     var stack: LinearLayout = LinearLayout(context)
+    var parent: ListView? = null
 
     fun setup(context: Context?) {
         val wrap = RelativeLayout.LayoutParams.WRAP_CONTENT
@@ -2324,7 +2325,7 @@
         } else {
             this.setBackgroundColor(Color.TRANSPARENT)
         }
-        if(this.parent is ListView && position != -1) {
+        if(parent is ListView && position != -1) {
             val cont = this.parent as ListView
             val adapter = cont.adapter as DWContainerAdapter
 
@@ -2333,8 +2334,10 @@
     }
 
     override fun setChecked(b: Boolean) {
-        mChecked = b
-        updateBackground()
+        if(b != mChecked) {
+            mChecked = b
+            updateBackground()
+        }
     }
 
     override fun isChecked(): Boolean {
@@ -2396,8 +2399,9 @@
         if(rowView == null) {
             rowView = DWContainerRow(context)
 
-            // Save the position for later use
+            // Save variables for later use
             rowView.position = position
+            rowView.parent = parent as ListView
 
             // Handle DW_CONTAINER_MODE_MULTI by setting the orientation vertical
             if(contMode == 2) {
@@ -2465,8 +2469,9 @@
                 }
             }
         } else {
-            // Need to save the position to set the check state
+            // Update the position and parent
             rowView.position = position
+            rowView.parent = parent as ListView
 
             // Refresh the selected state from the model
             rowView.isChecked = model.getRowSelected(position)
@@ -5416,6 +5421,8 @@
             adapter.lastClickRow = -1
             adapter.selectedItem = -1
             adapter.model.clear()
+
+            windowSetData(cont, "_dw_rowstart", 0L)
         }
     }