comparison android/DWindows.kt @ 2805:ebe139dc16dd

Android: Interface Builder passes index 65535 to make sure we are packing to the end of a box, but that caused an out of bounds error while previewing on Android. So check if we are out of bounds and pass -1 instead.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 19 Jul 2022 16:57:39 +0000
parents 708bcef0ce6b
children d7b6e19e44d2
comparison
equal deleted inserted replaced
2804:deefe6f5d716 2805:ebe139dc16dd
3559 // Finally add the padding 3559 // Finally add the padding
3560 if (pad > 0) { 3560 if (pad > 0) {
3561 params.setMargins(pad, pad, pad, pad) 3561 params.setMargins(pad, pad, pad, pad)
3562 } 3562 }
3563 item.layoutParams = params 3563 item.layoutParams = params
3564 box.addView(item, index) 3564 // If we are out of bounds, pass -1 to add to the end
3565 if(index >= box.childCount) {
3566 box.addView(item, -1)
3567 } else {
3568 box.addView(item, index)
3569 }
3565 boxUpdate(box) 3570 boxUpdate(box)
3566 } 3571 }
3567 } 3572 }
3568 } 3573 }
3569 3574