mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-25 04:28:46 +02: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)
|
if (mNotes.size <= 1)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.simplemobiletools.notes.R
|
|||||||
import com.simplemobiletools.notes.helpers.*
|
import com.simplemobiletools.notes.helpers.*
|
||||||
import com.simplemobiletools.notes.models.Note
|
import com.simplemobiletools.notes.models.Note
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileNotFoundException
|
||||||
|
|
||||||
fun Context.getTextSize() =
|
fun Context.getTextSize() =
|
||||||
when (config.fontSize) {
|
when (config.fontSize) {
|
||||||
@ -30,9 +31,13 @@ fun Context.updateWidget() {
|
|||||||
|
|
||||||
val Context.config: Config get() = Config.newInstance(this)
|
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()) {
|
return if (note.path.isNotEmpty()) {
|
||||||
File(note.path).readText()
|
try {
|
||||||
|
return File(note.path).readText()
|
||||||
|
} catch (e: FileNotFoundException) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
note.value
|
note.value
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,14 @@ class NoteFragment : Fragment() {
|
|||||||
|
|
||||||
val config = context.config
|
val config = context.config
|
||||||
view.notes_view.apply {
|
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)
|
setColors(config.textColor, config.primaryColor, config.backgroundColor)
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())
|
||||||
gravity = getTextGravity()
|
gravity = getTextGravity()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user