removing a useles fragment exception

This commit is contained in:
tibbi 2020-09-26 14:14:03 +02:00
parent 60daf014c2
commit 670cfa152a
2 changed files with 14 additions and 19 deletions

View File

@ -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!!

View File

@ -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,7 +54,7 @@ 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
@ -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()
} }
} }
@ -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()