mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-22 03:20:16 +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
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.simplemobiletools.notes.pro.helpers.Config
|
||||
|
||||
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.extensions.config
|
||||
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.helpers.NOTE_ID
|
||||
import com.simplemobiletools.notes.pro.helpers.NotesHelper
|
||||
@ -55,14 +54,14 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
}
|
||||
|
||||
private fun loadNoteById(noteId: Long) {
|
||||
NotesHelper(requiredActivity).getNoteWithId(noteId) { storedNote ->
|
||||
NotesHelper(activity!!).getNoteWithId(noteId) { storedNote ->
|
||||
if (storedNote != null && activity?.isDestroyed == false) {
|
||||
note = storedNote
|
||||
|
||||
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)
|
||||
}
|
||||
@ -71,7 +70,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
items.sortBy { it.isDone }
|
||||
}
|
||||
|
||||
requiredActivity.updateTextColors(view.checklist_holder)
|
||||
activity?.updateTextColors(view.checklist_holder)
|
||||
setupFragment()
|
||||
}
|
||||
}
|
||||
@ -82,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
|
||||
))
|
||||
}
|
||||
|
||||
@ -92,19 +91,19 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
}
|
||||
|
||||
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 {
|
||||
with(checklist_fab) {
|
||||
setImageDrawable(plusIcon)
|
||||
background.applyColorFilter(requiredActivity.getAdjustedPrimaryColor())
|
||||
background.applyColorFilter(activity!!.getAdjustedPrimaryColor())
|
||||
setOnClickListener {
|
||||
showNewItemDialog()
|
||||
}
|
||||
}
|
||||
|
||||
with(fragment_placeholder_2) {
|
||||
setTextColor(requiredActivity.getAdjustedPrimaryColor())
|
||||
setTextColor(activity!!.getAdjustedPrimaryColor())
|
||||
underlineText()
|
||||
setOnClickListener {
|
||||
showNewItemDialog()
|
||||
@ -141,11 +140,11 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user