mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
Refactor code
This commit is contained in:
@ -243,8 +243,7 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCurrentItemChecklist() = mAdapter?.isChecklistFragment(view_pager.currentItem)
|
||||
?: false
|
||||
private fun isCurrentItemChecklist() = mAdapter?.isChecklistFragment(view_pager.currentItem) ?: false
|
||||
|
||||
private fun checkIntents(intent: Intent) {
|
||||
intent.apply {
|
||||
@ -506,11 +505,11 @@ class MainActivity : SimpleActivity() {
|
||||
val licenses = LICENSE_RTL
|
||||
|
||||
val faqItems = arrayListOf(
|
||||
FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons),
|
||||
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
||||
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons),
|
||||
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons),
|
||||
FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons)
|
||||
FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons),
|
||||
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
||||
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons),
|
||||
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons),
|
||||
FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons)
|
||||
)
|
||||
|
||||
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
||||
@ -694,8 +693,8 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
private fun showExportFilePickUpdateDialog(exportPath: String, textToExport: String) {
|
||||
val items = arrayListOf(
|
||||
RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)),
|
||||
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content)))
|
||||
RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)),
|
||||
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content)))
|
||||
|
||||
RadioGroupDialog(this, items) {
|
||||
val syncFile = it as Int == EXPORT_FILE_SYNC
|
||||
@ -725,8 +724,8 @@ class MainActivity : SimpleActivity() {
|
||||
private fun exportAllNotes() {
|
||||
ExportFilesDialog(this, mNotes) { parent, extension ->
|
||||
val items = arrayListOf(
|
||||
RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)),
|
||||
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content)))
|
||||
RadioItem(EXPORT_FILE_SYNC, getString(R.string.update_file_at_note)),
|
||||
RadioItem(EXPORT_FILE_NO_SYNC, getString(R.string.only_export_file_content)))
|
||||
|
||||
RadioGroupDialog(this, items) {
|
||||
val syncFile = it as Int == EXPORT_FILE_SYNC
|
||||
@ -907,8 +906,7 @@ class MainActivity : SimpleActivity() {
|
||||
private fun saveCurrentNote(force: Boolean) {
|
||||
getPagerAdapter().saveCurrentNote(view_pager.currentItem, force)
|
||||
if (mCurrentNote.type == NoteType.TYPE_CHECKLIST.value) {
|
||||
mCurrentNote.value = getPagerAdapter().getNoteChecklistItems(view_pager.currentItem)
|
||||
?: ""
|
||||
mCurrentNote.value = getPagerAdapter().getNoteChecklistItems(view_pager.currentItem) ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
try {
|
||||
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
||||
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType)
|
||||
?: ArrayList(1)
|
||||
?: ArrayList(1)
|
||||
} catch (e: Exception) {
|
||||
migrateCheckListOnFailure(storedNote)
|
||||
}
|
||||
@ -81,9 +81,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
|
||||
note.value.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEachIndexed { index, value ->
|
||||
items.add(ChecklistItem(
|
||||
id = index,
|
||||
title = value,
|
||||
isDone = false
|
||||
id = index,
|
||||
title = value,
|
||||
isDone = false
|
||||
))
|
||||
}
|
||||
|
||||
@ -138,11 +138,11 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
updateUIVisibility()
|
||||
|
||||
ChecklistAdapter(
|
||||
activity = activity as SimpleActivity,
|
||||
items = items,
|
||||
listener = this,
|
||||
recyclerView = view.checklist_list,
|
||||
showIcons = true
|
||||
activity = activity as SimpleActivity,
|
||||
items = items,
|
||||
listener = this,
|
||||
recyclerView = view.checklist_list,
|
||||
showIcons = true
|
||||
) { item ->
|
||||
val clickedNote = item as ChecklistItem
|
||||
clickedNote.isDone = !clickedNote.isDone
|
||||
|
Reference in New Issue
Block a user