comparison android/DWindows.kt @ 2709:3cb5aa73dace

Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 22 Nov 2021 02:18:08 +0000
parents 3a7dcc0ae08b
children 6594bb323ab5
comparison
equal deleted inserted replaced
2708:3a7dcc0ae08b 2709:3cb5aa73dace
654 rowtitle.removeAt(i) 654 rowtitle.removeAt(i)
655 } 655 }
656 } 656 }
657 } 657 }
658 658
659 fun positionByTitle(title: String?): Int
660 {
661 for(i in 0 until rowtitle.size) {
662 if(rowtitle[i] != null && rowtitle[i] == title) {
663 return i
664 }
665 }
666 return -1
667 }
668
669 fun positionByData(rdata: Long): Int
670 {
671 for(i in 0 until rowdata.size) {
672 if (rowdata[i] == rdata) {
673 return i
674 }
675 }
676 return -1
677 }
678
659 fun addRows(count: Int): Long 679 fun addRows(count: Int): Long
660 { 680 {
661 val startRow: Long = numberOfRows().toLong() 681 val startRow: Long = numberOfRows().toLong()
662 682
663 for(i in 0 until count) 683 for(i in 0 until count)
3241 { 3261 {
3242 waitOnUiThread { 3262 waitOnUiThread {
3243 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter 3263 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3244 3264
3245 adapter.model.clear() 3265 adapter.model.clear()
3266 }
3267 }
3268
3269 fun containerScroll(cont: ListView, direction: Int, rows: Int)
3270 {
3271 waitOnUiThread {
3272 // DW_SCROLL_UP 0
3273 if(direction == 0) {
3274 cont.smoothScrollByOffset(-rows)
3275 // DW_SCROLL_DOWN 1
3276 } else if(direction == 1) {
3277 cont.smoothScrollByOffset(rows)
3278 // DW_SCROLL_TOP 2
3279 } else if(direction == 2) {
3280 cont.setSelection(0)
3281 cont.smoothScrollToPosition(0)
3282 // DW_SCROLL_BOTTOM 3
3283 } else if(direction == 3) {
3284 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3285 val pos = adapter.model.rowdata.size
3286
3287 if(pos > 0) {
3288 cont.setSelection(pos - 1)
3289 cont.smoothScrollToPosition(pos - 1)
3290 }
3291 }
3292 }
3293 }
3294
3295 fun containerCursor(cont: ListView, title: String?)
3296 {
3297 waitOnUiThread {
3298 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3299 val pos = adapter.model.positionByTitle(title)
3300
3301 if(pos > -1) {
3302 cont.setSelection(pos)
3303 cont.smoothScrollToPosition(pos)
3304 }
3305
3306 }
3307 }
3308
3309 fun containerCursorByData(cont: ListView, rdata: Long)
3310 {
3311 waitOnUiThread {
3312 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter
3313 val pos = adapter.model.positionByData(rdata)
3314
3315 if(pos > -1) {
3316 cont.setSelection(pos)
3317 cont.smoothScrollToPosition(pos)
3318 }
3319
3246 } 3320 }
3247 } 3321 }
3248 3322
3249 fun listBoxNew(cid: Int, multi: Int): DWListBox? 3323 fun listBoxNew(cid: Int, multi: Int): DWListBox?
3250 { 3324 {