added .forEach() extension to cursor

This commit is contained in:
Moez Bhatti
2017-08-13 22:27:24 -04:00
parent 524310d3b7
commit b74dbcc5a7
2 changed files with 29 additions and 11 deletions
@@ -0,0 +1,14 @@
package com.moez.QKSMS.util
import android.database.Cursor
fun Cursor.forEach(closeOnComplete: Boolean = true, method: (Cursor) -> Unit = {}) {
moveToPosition(-1)
while (moveToNext()) {
method.invoke(this)
}
if (closeOnComplete) {
close()
}
}