mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
create a new background thread only when needed
This commit is contained in:
@ -14,10 +14,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_RTL
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FAQItem
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
@ -360,7 +357,7 @@ class MainActivity : SimpleActivity() {
|
||||
private fun openFile() {
|
||||
FilePickerDialog(this, canAddShowHiddenButton = true) {
|
||||
openFile(it, true) {
|
||||
Thread {
|
||||
ensureBackgroundThread {
|
||||
val fileText = it.readText().trim()
|
||||
val checklistItems = fileText.parseChecklistItems()
|
||||
if (checklistItems != null) {
|
||||
@ -373,7 +370,7 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -644,11 +641,11 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun doDeleteNote(note: Note, deleteFile: Boolean) {
|
||||
Thread {
|
||||
ensureBackgroundThread {
|
||||
notesDB.deleteNote(note)
|
||||
widgetsDB.deleteNoteWidgets(note.id!!)
|
||||
refreshNotes(note, deleteFile)
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshNotes(note: Note, deleteFile: Boolean) {
|
||||
|
@ -15,6 +15,7 @@ import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
|
||||
@ -150,9 +151,9 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||
views.setBackgroundColor(R.id.checklist_note_view, mBgColor)
|
||||
AppWidgetManager.getInstance(this).updateAppWidget(mWidgetId, views)
|
||||
val widget = Widget(null, mWidgetId, mCurrentNoteId)
|
||||
Thread {
|
||||
ensureBackgroundThread {
|
||||
widgetsDB.insertOrUpdate(widget)
|
||||
}.start()
|
||||
}
|
||||
|
||||
storeWidgetBackground()
|
||||
requestWidgetUpdate()
|
||||
|
Reference in New Issue
Block a user