Created
November 10, 2016 21:25
-
-
Save jtrindade/593b5ca7651d1e2a7f77e2c45a568caa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val isInBatchMode : ThreadLocal<Boolean> = | |
object : ThreadLocal<Boolean>() { | |
override fun initialValue(): Boolean { | |
return false | |
} | |
} | |
override fun bulkInsert(uri: Uri, values: Array<out ContentValues>?): Int { | |
var successful = false | |
var db = dbHelper!!.writableDatabase | |
db.beginTransaction() | |
try { | |
isInBatchMode.set(true) | |
var res = super.bulkInsert(uri, values) | |
db.setTransactionSuccessful() | |
successful = true | |
return res | |
} finally { | |
isInBatchMode.set(false) | |
db.endTransaction() | |
if (successful) { | |
context.contentResolver.notifyChange(uri, null) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment