comparison android/DWindows.kt @ 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
comparison
equal deleted inserted replaced
2845:64c528d38fb8 2846:e6edeb2b63bc
2282 private var colorSelection = Color.DKGRAY 2282 private var colorSelection = Color.DKGRAY
2283 var position: Int = -1 2283 var position: Int = -1
2284 var imageview: ImageView = ImageView(context) 2284 var imageview: ImageView = ImageView(context)
2285 var text: TextView = TextView(context) 2285 var text: TextView = TextView(context)
2286 var stack: LinearLayout = LinearLayout(context) 2286 var stack: LinearLayout = LinearLayout(context)
2287 var parent: ListView? = null
2287 2288
2288 fun setup(context: Context?) { 2289 fun setup(context: Context?) {
2289 val wrap = RelativeLayout.LayoutParams.WRAP_CONTENT 2290 val wrap = RelativeLayout.LayoutParams.WRAP_CONTENT
2290 val match = RelativeLayout.LayoutParams.MATCH_PARENT 2291 val match = RelativeLayout.LayoutParams.MATCH_PARENT
2291 var lp = RelativeLayout.LayoutParams(wrap, wrap) 2292 var lp = RelativeLayout.LayoutParams(wrap, wrap)
2322 if(mChecked) { 2323 if(mChecked) {
2323 this.setBackgroundColor(colorSelection) 2324 this.setBackgroundColor(colorSelection)
2324 } else { 2325 } else {
2325 this.setBackgroundColor(Color.TRANSPARENT) 2326 this.setBackgroundColor(Color.TRANSPARENT)
2326 } 2327 }
2327 if(this.parent is ListView && position != -1) { 2328 if(parent is ListView && position != -1) {
2328 val cont = this.parent as ListView 2329 val cont = this.parent as ListView
2329 val adapter = cont.adapter as DWContainerAdapter 2330 val adapter = cont.adapter as DWContainerAdapter
2330 2331
2331 adapter.model.changeRowSelected(position, mChecked) 2332 adapter.model.changeRowSelected(position, mChecked)
2332 } 2333 }
2333 } 2334 }
2334 2335
2335 override fun setChecked(b: Boolean) { 2336 override fun setChecked(b: Boolean) {
2336 mChecked = b 2337 if(b != mChecked) {
2337 updateBackground() 2338 mChecked = b
2339 updateBackground()
2340 }
2338 } 2341 }
2339 2342
2340 override fun isChecked(): Boolean { 2343 override fun isChecked(): Boolean {
2341 return mChecked 2344 return mChecked
2342 } 2345 }
2394 2397
2395 // If the view passed in is null we need to create the layout 2398 // If the view passed in is null we need to create the layout
2396 if(rowView == null) { 2399 if(rowView == null) {
2397 rowView = DWContainerRow(context) 2400 rowView = DWContainerRow(context)
2398 2401
2399 // Save the position for later use 2402 // Save variables for later use
2400 rowView.position = position 2403 rowView.position = position
2404 rowView.parent = parent as ListView
2401 2405
2402 // Handle DW_CONTAINER_MODE_MULTI by setting the orientation vertical 2406 // Handle DW_CONTAINER_MODE_MULTI by setting the orientation vertical
2403 if(contMode == 2) { 2407 if(contMode == 2) {
2404 rowView.stack.orientation = LinearLayout.VERTICAL 2408 rowView.stack.orientation = LinearLayout.VERTICAL
2405 rowView.stack.gravity = Gravity.LEFT 2409 rowView.stack.gravity = Gravity.LEFT
2463 } 2467 }
2464 rowView.stack.addView(textview) 2468 rowView.stack.addView(textview)
2465 } 2469 }
2466 } 2470 }
2467 } else { 2471 } else {
2468 // Need to save the position to set the check state 2472 // Update the position and parent
2469 rowView.position = position 2473 rowView.position = position
2474 rowView.parent = parent as ListView
2470 2475
2471 // Refresh the selected state from the model 2476 // Refresh the selected state from the model
2472 rowView.isChecked = model.getRowSelected(position) 2477 rowView.isChecked = model.getRowSelected(position)
2473 2478
2474 // Otherwise we just need to update the existing layout 2479 // Otherwise we just need to update the existing layout
5414 5419
5415 adapter.lastClick = 0L 5420 adapter.lastClick = 0L
5416 adapter.lastClickRow = -1 5421 adapter.lastClickRow = -1
5417 adapter.selectedItem = -1 5422 adapter.selectedItem = -1
5418 adapter.model.clear() 5423 adapter.model.clear()
5424
5425 windowSetData(cont, "_dw_rowstart", 0L)
5419 } 5426 }
5420 } 5427 }
5421 5428
5422 fun containerScroll(cont: ListView, direction: Int, rows: Int) 5429 fun containerScroll(cont: ListView, direction: Int, rows: Int)
5423 { 5430 {