Skip to content

Instantly share code, notes, and snippets.

@mcmatan
Last active August 19, 2018 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmatan/3453aabc67d41ab0ddae25098278381c to your computer and use it in GitHub Desktop.
Save mcmatan/3453aabc67d41ab0ddae25098278381c to your computer and use it in GitHub Desktop.
class DataBase @Inject constructor() {
private val realmLock = RealmLock()
//Backround thread transaction
override fun saveLanguage(jsonArray: JSONArray) {
this.realmLock.transaction {
it.createAllFromJson(Language::class.java, jsonArray)
}
}
//UI thread transaction
private fun getFeedItem(id: String): HomeFeedItem? {
return realmLock.getRealm()
.where<HomeFeedItem>().equalTo("_id", id).findFirst()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment