Mercurial > dwindows
comparison android/DWindows.kt @ 2560:3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 18 May 2021 18:41:35 +0000 |
parents | ebc6a4ff5f1f |
children | f28d7d0ca5ed |
comparison
equal
deleted
inserted
replaced
2559:b5e8a319fde6 | 2560:3da35cd91ca7 |
---|---|
465 var columns = mutableListOf<String?>() | 465 var columns = mutableListOf<String?>() |
466 var types = mutableListOf<Int>() | 466 var types = mutableListOf<Int>() |
467 var data = mutableListOf<Any?>() | 467 var data = mutableListOf<Any?>() |
468 var rowdata = mutableListOf<Long>() | 468 var rowdata = mutableListOf<Long>() |
469 var rowtitle = mutableListOf<String?>() | 469 var rowtitle = mutableListOf<String?>() |
470 var querypos: Int = -1 | |
470 | 471 |
471 fun numberOfColumns(): Int | 472 fun numberOfColumns(): Int |
472 { | 473 { |
473 return columns.size | 474 return columns.size |
474 } | 475 } |
1974 { | 1975 { |
1975 var cont: ListView? = null | 1976 var cont: ListView? = null |
1976 | 1977 |
1977 waitOnUiThread { | 1978 waitOnUiThread { |
1978 var dataArrayMap = SimpleArrayMap<String, Long>() | 1979 var dataArrayMap = SimpleArrayMap<String, Long>() |
1980 var adapter = DWContainerAdapter(this) | |
1979 | 1981 |
1980 cont = ListView(this) | 1982 cont = ListView(this) |
1981 cont!!.tag = dataArrayMap | 1983 cont!!.tag = dataArrayMap |
1982 cont!!.id = cid | 1984 cont!!.id = cid |
1983 cont!!.adapter = DWContainerAdapter(this) | 1985 cont!!.adapter = adapter |
1984 if(multi != 0) { | 1986 if(multi != 0) { |
1985 cont!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE; | 1987 cont!!.choiceMode = ListView.CHOICE_MODE_MULTIPLE; |
1986 } | 1988 } |
1989 cont!!.setOnItemClickListener { parent, view, position, id -> | |
1990 val title = adapter.model.getRowTitle(position) | |
1991 val data = adapter.model.getRowData(position) | |
1992 | |
1993 eventHandlerContainer(cont!!, 9, title, 0, 0, data) | |
1994 } | |
1995 cont!!.setOnItemLongClickListener { parent, view, position, id -> | |
1996 val title = adapter.model.getRowTitle(position) | |
1997 val data = adapter.model.getRowData(position) | |
1998 | |
1999 eventHandlerContainer(cont!!, 10, title, 0, 0, data) | |
2000 true | |
2001 } | |
1987 } | 2002 } |
1988 return cont | 2003 return cont |
2004 } | |
2005 | |
2006 fun containerGetTitleStart(cont: ListView, flags: Int): String? | |
2007 { | |
2008 var retval: String? = null | |
2009 | |
2010 waitOnUiThread { | |
2011 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter | |
2012 | |
2013 // Handle DW_CRA_SELECTED | |
2014 if((flags and 1) != 0) { | |
2015 val checked: SparseBooleanArray = cont.getCheckedItemPositions() | |
2016 val position = checked.keyAt(0) | |
2017 | |
2018 if(position != null) { | |
2019 adapter.model.querypos = position | |
2020 retval = adapter.model.getRowTitle(position) | |
2021 } else { | |
2022 adapter.model.querypos = -1 | |
2023 } | |
2024 } else { | |
2025 if(adapter.model.rowdata.size == 0) { | |
2026 adapter.model.querypos = -1 | |
2027 } else { | |
2028 retval = adapter.model.getRowTitle(0) | |
2029 adapter.model.querypos = 0 | |
2030 } | |
2031 } | |
2032 } | |
2033 return retval | |
2034 } | |
2035 | |
2036 fun containerGetTitleNext(cont: ListView, flags: Int): String? | |
2037 { | |
2038 var retval: String? = null | |
2039 | |
2040 waitOnUiThread { | |
2041 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter | |
2042 | |
2043 if(adapter.model.querypos != -1) { | |
2044 // Handle DW_CRA_SELECTED | |
2045 if ((flags and 1) != 0) { | |
2046 val checked: SparseBooleanArray = cont.getCheckedItemPositions() | |
2047 | |
2048 // Otherwise loop until we find our current place | |
2049 for (i in 0 until checked.size()) { | |
2050 // Item position in adapter | |
2051 val position: Int = checked.keyAt(i) | |
2052 | |
2053 if (position != null) { | |
2054 // If we are at our current point... check to see | |
2055 // if there is another one, and return it... | |
2056 // otherwise we will return -1 to indicated we are done. | |
2057 if (adapter.model.querypos == position && (i + 1) < checked.size()) { | |
2058 val newpos = checked.keyAt(i + 1) | |
2059 | |
2060 if (newpos != null) { | |
2061 adapter.model.querypos = newpos | |
2062 retval = adapter.model.getRowTitle(newpos) | |
2063 } else { | |
2064 adapter.model.querypos = -1 | |
2065 } | |
2066 } | |
2067 } else { | |
2068 adapter.model.querypos = -1 | |
2069 } | |
2070 } | |
2071 } else { | |
2072 if (adapter.model.rowtitle.size > adapter.model.querypos) { | |
2073 adapter.model.querypos += 1 | |
2074 retval = adapter.model.getRowTitle(adapter.model.querypos) | |
2075 } else { | |
2076 adapter.model.querypos = -1 | |
2077 } | |
2078 } | |
2079 } | |
2080 } | |
2081 return retval | |
2082 } | |
2083 | |
2084 fun containerGetDataStart(cont: ListView, flags: Int): Long | |
2085 { | |
2086 var retval: Long = 0 | |
2087 | |
2088 waitOnUiThread { | |
2089 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter | |
2090 | |
2091 // Handle DW_CRA_SELECTED | |
2092 if((flags and 1) != 0) { | |
2093 val checked: SparseBooleanArray = cont.getCheckedItemPositions() | |
2094 val position = checked.keyAt(0) | |
2095 | |
2096 if(position != null) { | |
2097 adapter.model.querypos = position | |
2098 retval = adapter.model.getRowData(position) | |
2099 } else { | |
2100 adapter.model.querypos = -1 | |
2101 } | |
2102 } else { | |
2103 if(adapter.model.rowdata.size == 0) { | |
2104 adapter.model.querypos = -1 | |
2105 } else { | |
2106 retval = adapter.model.getRowData(0) | |
2107 adapter.model.querypos = 0 | |
2108 } | |
2109 } | |
2110 } | |
2111 return retval | |
2112 } | |
2113 | |
2114 fun containerGetDataNext(cont: ListView, flags: Int): Long | |
2115 { | |
2116 var retval: Long = 0 | |
2117 | |
2118 waitOnUiThread { | |
2119 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter | |
2120 | |
2121 if(adapter.model.querypos != -1) { | |
2122 // Handle DW_CRA_SELECTED | |
2123 if ((flags and 1) != 0) { | |
2124 val checked: SparseBooleanArray = cont.getCheckedItemPositions() | |
2125 | |
2126 // Otherwise loop until we find our current place | |
2127 for (i in 0 until checked.size()) { | |
2128 // Item position in adapter | |
2129 val position: Int = checked.keyAt(i) | |
2130 | |
2131 if (position != null) { | |
2132 // If we are at our current point... check to see | |
2133 // if there is another one, and return it... | |
2134 // otherwise we will return -1 to indicated we are done. | |
2135 if (adapter.model.querypos == position && (i + 1) < checked.size()) { | |
2136 val newpos = checked.keyAt(i + 1) | |
2137 | |
2138 if (newpos != null) { | |
2139 adapter.model.querypos = newpos | |
2140 retval = adapter.model.getRowData(newpos) | |
2141 } else { | |
2142 adapter.model.querypos = -1 | |
2143 } | |
2144 } | |
2145 } else { | |
2146 adapter.model.querypos = -1 | |
2147 } | |
2148 } | |
2149 } else { | |
2150 if (adapter.model.rowdata.size > adapter.model.querypos) { | |
2151 adapter.model.querypos += 1 | |
2152 retval = adapter.model.getRowData(adapter.model.querypos) | |
2153 } else { | |
2154 adapter.model.querypos = -1 | |
2155 } | |
2156 } | |
2157 } | |
2158 } | |
2159 return retval | |
1989 } | 2160 } |
1990 | 2161 |
1991 fun containerAddColumn(cont: ListView, title: String, flags: Int) | 2162 fun containerAddColumn(cont: ListView, title: String, flags: Int) |
1992 { | 2163 { |
1993 waitOnUiThread { | 2164 waitOnUiThread { |
3074 ) | 3245 ) |
3075 external fun eventHandlerSimple(obj1: View, message: Int) | 3246 external fun eventHandlerSimple(obj1: View, message: Int) |
3076 external fun eventHandlerNotebook(obj1: View, message: Int, pageID: Long) | 3247 external fun eventHandlerNotebook(obj1: View, message: Int, pageID: Long) |
3077 external fun eventHandlerTimer(sigfunc: Long, data: Long): Int | 3248 external fun eventHandlerTimer(sigfunc: Long, data: Long): Int |
3078 external fun eventHandlerHTMLResult(obj1: View, message: Int, result: String, data: Long) | 3249 external fun eventHandlerHTMLResult(obj1: View, message: Int, result: String, data: Long) |
3250 external fun eventHandlerContainer(obj1: View, message: Int, title: String?, x: Int, y: Int, data: Long) | |
3079 | 3251 |
3080 companion object | 3252 companion object |
3081 { | 3253 { |
3082 // Used to load the 'dwindows' library on application startup. | 3254 // Used to load the 'dwindows' library on application startup. |
3083 init | 3255 init |