diff --git a/app/src/main/java/dev/arkbuilders/arkmemo/utils/NoteExt.kt b/app/src/main/java/dev/arkbuilders/arkmemo/utils/NoteExt.kt index cc686754..07662da0 100644 --- a/app/src/main/java/dev/arkbuilders/arkmemo/utils/NoteExt.kt +++ b/app/src/main/java/dev/arkbuilders/arkmemo/utils/NoteExt.kt @@ -8,20 +8,31 @@ import dev.arkbuilders.arkmemo.models.TextNote import dev.arkbuilders.arkmemo.models.VoiceNote fun Note.getAutoTitle(context: Context? = null): String { + return if (context != null) { + when (this) { + is TextNote -> { + title.ifEmpty { text.take(20) }.ifEmpty { + context.getString(R.string.ark_memo_default_text_note_title) + } + } - return if (this is TextNote) { - this.title.ifEmpty { this.text.take(20) }.ifEmpty { - context?.getString(R.string.ark_memo_default_text_note_title) ?: "" - } - } else if (this is GraphicNote && context != null) { - this.title.ifEmpty { - String.format(context.getString(R.string.ark_memo_graphic_note), this.resource?.id) - } - } else if (this is VoiceNote && context != null) { - this.title.ifEmpty { - String.format(context.getString(R.string.ark_memo_voice_note), this.resource?.id) + is GraphicNote -> { + title.ifEmpty { + String.format( + context.getString(R.string.ark_memo_graphic_note), resource?.id + ) + } + } + + is VoiceNote -> { + title.ifEmpty { + String.format( + context.getString(R.string.ark_memo_voice_note), resource?.id + ) + } + } + + else -> { "" } } - } else { - "" - } + } else { "" } } \ No newline at end of file