mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-23 03:50:07 +01:00
removing a useles fragment exception
This commit is contained in:
parent
60daf014c2
commit
670cfa152a
@ -1,10 +1,6 @@
|
|||||||
package com.simplemobiletools.notes.pro.extensions
|
package com.simplemobiletools.notes.pro.extensions
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
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!!
|
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
|
|||||||
import com.simplemobiletools.notes.pro.dialogs.NewChecklistItemDialog
|
import com.simplemobiletools.notes.pro.dialogs.NewChecklistItemDialog
|
||||||
import com.simplemobiletools.notes.pro.extensions.config
|
import com.simplemobiletools.notes.pro.extensions.config
|
||||||
import com.simplemobiletools.notes.pro.extensions.notesDB
|
import com.simplemobiletools.notes.pro.extensions.notesDB
|
||||||
import com.simplemobiletools.notes.pro.extensions.requiredActivity
|
|
||||||
import com.simplemobiletools.notes.pro.extensions.updateWidgets
|
import com.simplemobiletools.notes.pro.extensions.updateWidgets
|
||||||
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
|
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
|
||||||
import com.simplemobiletools.notes.pro.helpers.NotesHelper
|
import com.simplemobiletools.notes.pro.helpers.NotesHelper
|
||||||
@ -55,14 +54,14 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadNoteById(noteId: Long) {
|
private fun loadNoteById(noteId: Long) {
|
||||||
NotesHelper(requiredActivity).getNoteWithId(noteId) { storedNote ->
|
NotesHelper(activity!!).getNoteWithId(noteId) { storedNote ->
|
||||||
if (storedNote != null && activity?.isDestroyed == false) {
|
if (storedNote != null && activity?.isDestroyed == false) {
|
||||||
note = storedNote
|
note = storedNote
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
|
||||||
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType)
|
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType)
|
||||||
?: ArrayList(1)
|
?: ArrayList(1)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
migrateCheckListOnFailure(storedNote)
|
migrateCheckListOnFailure(storedNote)
|
||||||
}
|
}
|
||||||
@ -71,7 +70,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
items.sortBy { it.isDone }
|
items.sortBy { it.isDone }
|
||||||
}
|
}
|
||||||
|
|
||||||
requiredActivity.updateTextColors(view.checklist_holder)
|
activity?.updateTextColors(view.checklist_holder)
|
||||||
setupFragment()
|
setupFragment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,9 +81,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
|
|
||||||
note.value.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEachIndexed { index, value ->
|
note.value.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEachIndexed { index, value ->
|
||||||
items.add(ChecklistItem(
|
items.add(ChecklistItem(
|
||||||
id = index,
|
id = index,
|
||||||
title = value,
|
title = value,
|
||||||
isDone = false
|
isDone = false
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,19 +91,19 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFragment() {
|
private fun setupFragment() {
|
||||||
val plusIcon = resources.getColoredDrawableWithColor(R.drawable.ic_plus_vector, if (requiredActivity.isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
|
val plusIcon = resources.getColoredDrawableWithColor(R.drawable.ic_plus_vector, if (activity!!.isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
|
||||||
|
|
||||||
view.apply {
|
view.apply {
|
||||||
with(checklist_fab) {
|
with(checklist_fab) {
|
||||||
setImageDrawable(plusIcon)
|
setImageDrawable(plusIcon)
|
||||||
background.applyColorFilter(requiredActivity.getAdjustedPrimaryColor())
|
background.applyColorFilter(activity!!.getAdjustedPrimaryColor())
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
showNewItemDialog()
|
showNewItemDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(fragment_placeholder_2) {
|
with(fragment_placeholder_2) {
|
||||||
setTextColor(requiredActivity.getAdjustedPrimaryColor())
|
setTextColor(activity!!.getAdjustedPrimaryColor())
|
||||||
underlineText()
|
underlineText()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
showNewItemDialog()
|
showNewItemDialog()
|
||||||
@ -141,11 +140,11 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChecklistAdapter(
|
ChecklistAdapter(
|
||||||
activity = activity as SimpleActivity,
|
activity = activity as SimpleActivity,
|
||||||
items = items,
|
items = items,
|
||||||
listener = this,
|
listener = this,
|
||||||
recyclerView = view.checklist_list,
|
recyclerView = view.checklist_list,
|
||||||
showIcons = true
|
showIcons = true
|
||||||
) { item ->
|
) { item ->
|
||||||
val clickedNote = item as ChecklistItem
|
val clickedNote = item as ChecklistItem
|
||||||
clickedNote.isDone = !clickedNote.isDone
|
clickedNote.isDone = !clickedNote.isDone
|
||||||
|
Loading…
x
Reference in New Issue
Block a user