mirror of
				https://github.com/SimpleMobileTools/Simple-Notes.git
				synced 2025-06-05 17:00:23 +02:00 
			
		
		
		
	fix #69, weird behaviour at renaming note
This commit is contained in:
		| @@ -32,7 +32,7 @@ class RenameNoteDialog(val activity: Activity, val db: DBHelper, val note: Note, | ||||
|                     activity.toast(R.string.title_taken) | ||||
|                 } else { | ||||
|                     note.title = title | ||||
|                     db.updateNote(note) | ||||
|                     db.updateNoteTitle(note) | ||||
|                     dismiss() | ||||
|                     callback.invoke(note) | ||||
|                 } | ||||
|   | ||||
| @@ -62,7 +62,7 @@ class NoteFragment : Fragment() { | ||||
|         val oldText = note.value | ||||
|         if (newText != oldText) { | ||||
|             note.value = newText | ||||
|             mDb.updateNote(note) | ||||
|             mDb.updateNoteValue(note) | ||||
|             context.updateWidget() | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -125,10 +125,19 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe | ||||
|         return note | ||||
|     } | ||||
|  | ||||
|     fun updateNote(note: Note) { | ||||
|         val values = fillContentValues(note) | ||||
|     fun updateNoteValue(note: Note) { | ||||
|         val values = ContentValues().apply { put(COL_VALUE, note.value) } | ||||
|         updateNote(note.id, values) | ||||
|     } | ||||
|  | ||||
|     fun updateNoteTitle(note: Note) { | ||||
|         val values = ContentValues().apply { put(COL_TITLE, note.title) } | ||||
|         updateNote(note.id, values) | ||||
|     } | ||||
|  | ||||
|     fun updateNote(id: Int, values: ContentValues) { | ||||
|         val selection = "$COL_ID = ?" | ||||
|         val selectionArgs = arrayOf(note.id.toString()) | ||||
|         val selectionArgs = arrayOf(id.toString()) | ||||
|         mDb.update(TABLE_NAME, values, selection, selectionArgs) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user