mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-01-30 14:04:48 +01:00
Fix #88
This commit is contained in:
parent
d31c918b98
commit
a9e466406c
@ -240,7 +240,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteNote(deleteFile: Boolean) {
|
||||
fun deleteNote(deleteFile: Boolean) {
|
||||
if (mNotes.size <= 1)
|
||||
return
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.simplemobiletools.notes.R
|
||||
import com.simplemobiletools.notes.helpers.*
|
||||
import com.simplemobiletools.notes.models.Note
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
fun Context.getTextSize() =
|
||||
when (config.fontSize) {
|
||||
@ -30,9 +31,13 @@ fun Context.updateWidget() {
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(this)
|
||||
|
||||
fun Context.getNoteStoredValue(note: Note): String {
|
||||
fun Context.getNoteStoredValue(note: Note): String? {
|
||||
return if (note.path.isNotEmpty()) {
|
||||
File(note.path).readText()
|
||||
try {
|
||||
return File(note.path).readText()
|
||||
} catch (e: FileNotFoundException) {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
note.value
|
||||
}
|
||||
|
@ -98,7 +98,14 @@ class NoteFragment : Fragment() {
|
||||
|
||||
val config = context.config
|
||||
view.notes_view.apply {
|
||||
setText(context.getNoteStoredValue(note))
|
||||
val fileContents = context.getNoteStoredValue(note)
|
||||
|
||||
if (fileContents == null) {
|
||||
(activity as MainActivity).deleteNote(false)
|
||||
return
|
||||
}
|
||||
|
||||
setText(fileContents)
|
||||
setColors(config.textColor, config.primaryColor, config.backgroundColor)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
|
||||
gravity = getTextGravity()
|
||||
|
Loading…
x
Reference in New Issue
Block a user