show a toast if the title already exists, when opening a file

This commit is contained in:
tibbi 2017-03-07 20:28:27 +01:00
parent 807b8409a0
commit 28ed5c654f

@ -165,9 +165,13 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
toast(R.string.file_too_large)
} else {
val filename = it.getFilenameFromPath()
val content = File(it).readText()
val note = Note(0, filename, content, TYPE_NOTE)
addNewNote(note)
if (mDb.doesTitleExist(filename)) {
toast(R.string.title_taken)
} else {
val content = File(it).readText()
val note = Note(0, filename, content, TYPE_NOTE)
addNewNote(note)
}
}
}
}