Mercurial > dwindows
comparison android/DWindows.kt @ 2527:eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
To avoid any possible exceptions.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 10 May 2021 02:24:52 +0000 |
parents | d3f09b3f3703 |
children | 03f6870bcfcc |
comparison
equal
deleted
inserted
replaced
2526:d3f09b3f3703 | 2527:eec926265888 |
---|---|
109 | 109 |
110 if (event.action == MotionEvent.ACTION_UP) { | 110 if (event.action == MotionEvent.ACTION_UP) { |
111 if (event.x >= v.width - (v as EditText) | 111 if (event.x >= v.width - (v as EditText) |
112 .compoundDrawables[DRAWABLE_RIGHT].bounds.width() | 112 .compoundDrawables[DRAWABLE_RIGHT].bounds.width() |
113 ) { | 113 ) { |
114 val newvalue = this.text.toString().toLong() | 114 val newvalue = this.text.toString().toLongOrNull() |
115 | 115 |
116 if(newvalue != null) { | 116 if(newvalue != null) { |
117 value = newvalue + 1 | 117 value = newvalue + 1 |
118 } else { | 118 } else { |
119 value += 1 | 119 value += 1 |
128 eventHandlerInt(14, value.toInt(), 0, 0, 0) | 128 eventHandlerInt(14, value.toInt(), 0, 0, 0) |
129 return true | 129 return true |
130 } else if (event.x <= (v as EditText) | 130 } else if (event.x <= (v as EditText) |
131 .compoundDrawables[DRAWABLE_LEFT].bounds.width() | 131 .compoundDrawables[DRAWABLE_LEFT].bounds.width() |
132 ) { | 132 ) { |
133 val newvalue = this.text.toString().toLong() | 133 val newvalue = this.text.toString().toLongOrNull() |
134 | 134 |
135 if(newvalue != null) { | 135 if(newvalue != null) { |
136 value = newvalue - 1 | 136 value = newvalue - 1 |
137 } else { | 137 } else { |
138 value -= 1 | 138 value -= 1 |
263 private var fileListener: FileSelectedListener? = null | 263 private var fileListener: FileSelectedListener? = null |
264 fun showDialog() { | 264 fun showDialog() { |
265 dialog.show() | 265 dialog.show() |
266 } | 266 } |
267 | 267 |
268 /** | 268 /* |
269 * Sort, filter and display the files for the given path. | 269 * Sort, filter and display the files for the given path. |
270 */ | 270 */ |
271 private fun refresh(path: File?) { | 271 private fun refresh(path: File?) { |
272 currentPath = path | 272 currentPath = path |
273 if (path != null) { | 273 if (path != null) { |