- updated code style format and removed debug extension

This commit is contained in:
Pavol Franek 2020-03-02 06:51:30 +01:00
parent 7b12650db9
commit f66c90e495
2 changed files with 128 additions and 121 deletions

View File

@ -2,11 +2,8 @@ package com.simplemobiletools.notes.pro.extensions
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import com.simplemobiletools.notes.pro.BuildConfig
import com.simplemobiletools.notes.pro.helpers.Config import com.simplemobiletools.notes.pro.helpers.Config
val Fragment.config: Config? get() = if (context != null) Config.newInstance(context!!) else null val Fragment.config: Config? get() = if (context != null) Config.newInstance(context!!) else null
val Fragment.requiredActivity: FragmentActivity get() = this.activity!! val Fragment.requiredActivity: FragmentActivity get() = this.activity!!
val Fragment.isDebug get(): Boolean = BuildConfig.DEBUG

View File

@ -46,7 +46,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
override fun setMenuVisibility(menuVisible: Boolean) { override fun setMenuVisibility(menuVisible: Boolean) {
super.setMenuVisibility(menuVisible) super.setMenuVisibility(menuVisible)
if (menuVisible) activity?.hideKeyboard() if (menuVisible) {
activity?.hideKeyboard()
}
} }
private fun loadNoteById(noteId: Long) { private fun loadNoteById(noteId: Long) {
@ -56,13 +58,16 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
try { try {
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType) ?: ArrayList(1) items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType)
?: ArrayList(1)
} catch (e: Exception) { } catch (e: Exception) {
migrateCheckListOnFailure(storedNote) migrateCheckListOnFailure(storedNote)
if (isDebug) e.printStackTrace()
} }
if (config?.moveUndoneChecklistItems == true) items.sortBy { it.isDone } if (config?.moveUndoneChecklistItems == true) {
items.sortBy { it.isDone }
}
requiredActivity.updateTextColors(view.checklist_holder) requiredActivity.updateTextColors(view.checklist_holder)
setupFragment() setupFragment()
} }
@ -167,6 +172,11 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
} }
} }
override fun saveChecklist() { saveNote() } override fun saveChecklist() {
override fun refreshItems() { setupAdapter() } saveNote()
}
override fun refreshItems() {
setupAdapter()
}
} }