mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
preparing the migration to Room database
This commit is contained in:
@ -25,6 +25,7 @@ import com.simplemobiletools.commons.views.MyEditText
|
||||
import com.simplemobiletools.notes.pro.BuildConfig
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.adapters.NotesPagerAdapter
|
||||
import com.simplemobiletools.notes.pro.databases.NotesDatabase
|
||||
import com.simplemobiletools.notes.pro.dialogs.*
|
||||
import com.simplemobiletools.notes.pro.extensions.config
|
||||
import com.simplemobiletools.notes.pro.extensions.dbHelper
|
||||
@ -110,6 +111,13 @@ class MainActivity : SimpleActivity() {
|
||||
storeStateVariables()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (!isChangingConfigurations) {
|
||||
NotesDatabase.destroyInstance()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu, menu)
|
||||
menu.apply {
|
||||
@ -218,7 +226,7 @@ class MainActivity : SimpleActivity() {
|
||||
if (it as Int == 0) {
|
||||
displayNewNoteDialog(text)
|
||||
} else {
|
||||
updateSelectedNote(notes[it - 1].id)
|
||||
updateSelectedNote(notes[it - 1].id!!)
|
||||
addTextToCurrentNote(if (mCurrentNote.value.isEmpty()) text else "\n$text")
|
||||
}
|
||||
}
|
||||
@ -249,7 +257,7 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
onPageChangeListener {
|
||||
mCurrentNote = mNotes[it]
|
||||
config.currentNoteId = mCurrentNote.id
|
||||
config.currentNoteId = mCurrentNote.id!!
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,13 +569,13 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun doDeleteNote(note: Note, deleteFile: Boolean) {
|
||||
dbHelper.deleteNote(mCurrentNote.id)
|
||||
dbHelper.deleteNote(mCurrentNote.id!!)
|
||||
mNotes = dbHelper.getNotes()
|
||||
|
||||
val firstNoteId = mNotes[0].id
|
||||
updateSelectedNote(firstNoteId)
|
||||
updateSelectedNote(firstNoteId!!)
|
||||
if (config.widgetNoteId == note.id) {
|
||||
config.widgetNoteId = mCurrentNote.id
|
||||
config.widgetNoteId = mCurrentNote.id!!
|
||||
updateWidgets()
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||
private fun showNoteSelector() {
|
||||
val items = ArrayList<RadioItem>()
|
||||
mNotes.forEach {
|
||||
items.add(RadioItem(it.id, it.title))
|
||||
items.add(RadioItem(it.id!!, it.title))
|
||||
}
|
||||
|
||||
RadioGroupDialog(this, items, mCurrentNoteId) {
|
||||
@ -99,7 +99,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun updateCurrentNote(note: Note) {
|
||||
mCurrentNoteId = note.id
|
||||
mCurrentNoteId = note.id!!
|
||||
notes_picker_value.text = note.title
|
||||
val sampleValue = if (note.value.isEmpty() || mIsCustomizingColors) getString(R.string.widget_config) else note.value
|
||||
notes_view.text = sampleValue
|
||||
|
Reference in New Issue
Block a user