viewModel.getItems().observe(this, Observer { collections ->
galleryRecycler.visibility = View.VISIBLE
progressBarGallery.visibility = View.GONE
galleryAdapter.setItems(collections.mapToGalleryItem())
})
private const val databaseName = "knote.db"
@Database(
entities = [Note::class],
version = 4,
exportSchema = false
)
abstract class InnerDb : RoomDatabase() {
abstract fun createNoteDao(): NoteDao
companion object {
fun createInstance(context: Context): InnerDb {
return Room.databaseBuilder(context, InnerDb::class.java, databaseName)
.allowMainThreadQueries()
.fallbackToDestructiveMigration()
.build()
}
}
}