mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
change the Note ID type to Long
This commit is contained in:
@ -9,12 +9,13 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.pro.extensions.dbHelper
|
||||
import com.simplemobiletools.notes.pro.extensions.notesDB
|
||||
import com.simplemobiletools.notes.pro.helpers.TYPE_NOTE
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_import_folder.view.*
|
||||
import java.io.File
|
||||
|
||||
class ImportFolderDialog(val activity: SimpleActivity, val path: String, val callback: (id: Int) -> Unit) : AlertDialog.Builder(activity) {
|
||||
class ImportFolderDialog(val activity: SimpleActivity, val path: String, val callback: () -> Unit) : AlertDialog.Builder(activity) {
|
||||
private var dialog: AlertDialog
|
||||
|
||||
init {
|
||||
@ -37,7 +38,6 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
|
||||
|
||||
private fun saveFolder(updateFilesOnEdit: Boolean) {
|
||||
val folder = File(path)
|
||||
var lastSavedNoteId = -1
|
||||
folder.listFiles { file ->
|
||||
val filename = file.path.getFilenameFromPath()
|
||||
when {
|
||||
@ -54,22 +54,21 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
|
||||
|
||||
if (updateFilesOnEdit) {
|
||||
activity.handleSAFDialog(path) {
|
||||
lastSavedNoteId = saveNote(title, value, storePath)
|
||||
saveNote(title, value, storePath)
|
||||
}
|
||||
} else {
|
||||
lastSavedNoteId = saveNote(title, value, storePath)
|
||||
saveNote(title, value, storePath)
|
||||
}
|
||||
}
|
||||
|
||||
if (lastSavedNoteId != -1) {
|
||||
callback(lastSavedNoteId)
|
||||
}
|
||||
|
||||
callback()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
private fun saveNote(title: String, value: String, path: String): Int {
|
||||
val note = Note(0, title, value, TYPE_NOTE, path)
|
||||
return activity.dbHelper.insertNote(note)
|
||||
private fun saveNote(title: String, value: String, path: String) {
|
||||
val note = Note(null, title, value, TYPE_NOTE, path)
|
||||
Thread {
|
||||
activity.notesDB.insertOrUpdate(note)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
|
||||
|
||||
private fun saveNote(storeContent: String, storePath: String) {
|
||||
val filename = path.getFilenameFromPath()
|
||||
val note = Note(0, filename, storeContent, TYPE_NOTE, storePath)
|
||||
val note = Note(null, filename, storeContent, TYPE_NOTE, storePath)
|
||||
callback(note)
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_open_note.view.*
|
||||
import kotlinx.android.synthetic.main.open_note_item.view.*
|
||||
|
||||
class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> Unit) {
|
||||
class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Long) -> Unit) {
|
||||
private var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
@ -34,10 +34,10 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> U
|
||||
open_note_item_radio_button.apply {
|
||||
text = note.title
|
||||
isChecked = note.id == activity.config.currentNoteId
|
||||
id = note.id!!
|
||||
id = note.id!!.toInt()
|
||||
|
||||
setOnClickListener {
|
||||
callback(id)
|
||||
callback(note.id!!)
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user