Skip to content

Commit 670cfa1

Browse files
committed
removing a useles fragment exception
1 parent 60daf01 commit 670cfa1

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package com.simplemobiletools.notes.pro.extensions
22

33
import androidx.fragment.app.Fragment
4-
import androidx.fragment.app.FragmentActivity
54
import com.simplemobiletools.notes.pro.helpers.Config
65

76
val Fragment.config: Config? get() = if (context != null) Config.newInstance(context!!) else null
8-
9-
val Fragment.requiredActivity: FragmentActivity get() = this.activity!!
10-

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
1515
import com.simplemobiletools.notes.pro.dialogs.NewChecklistItemDialog
1616
import com.simplemobiletools.notes.pro.extensions.config
1717
import com.simplemobiletools.notes.pro.extensions.notesDB
18-
import com.simplemobiletools.notes.pro.extensions.requiredActivity
1918
import com.simplemobiletools.notes.pro.extensions.updateWidgets
2019
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
2120
import com.simplemobiletools.notes.pro.helpers.NotesHelper
@@ -55,14 +54,14 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
5554
}
5655

5756
private fun loadNoteById(noteId: Long) {
58-
NotesHelper(requiredActivity).getNoteWithId(noteId) { storedNote ->
57+
NotesHelper(activity!!).getNoteWithId(noteId) { storedNote ->
5958
if (storedNote != null && activity?.isDestroyed == false) {
6059
note = storedNote
6160

6261
try {
6362
val checklistItemType = object : TypeToken<List<ChecklistItem>>() {}.type
6463
items = Gson().fromJson<ArrayList<ChecklistItem>>(storedNote.value, checklistItemType)
65-
?: ArrayList(1)
64+
?: ArrayList(1)
6665
} catch (e: Exception) {
6766
migrateCheckListOnFailure(storedNote)
6867
}
@@ -71,7 +70,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
7170
items.sortBy { it.isDone }
7271
}
7372

74-
requiredActivity.updateTextColors(view.checklist_holder)
73+
activity?.updateTextColors(view.checklist_holder)
7574
setupFragment()
7675
}
7776
}
@@ -82,29 +81,29 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
8281

8382
note.value.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEachIndexed { index, value ->
8483
items.add(ChecklistItem(
85-
id = index,
86-
title = value,
87-
isDone = false
84+
id = index,
85+
title = value,
86+
isDone = false
8887
))
8988
}
9089

9190
saveChecklist()
9291
}
9392

9493
private fun setupFragment() {
95-
val plusIcon = resources.getColoredDrawableWithColor(R.drawable.ic_plus_vector, if (requiredActivity.isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
94+
val plusIcon = resources.getColoredDrawableWithColor(R.drawable.ic_plus_vector, if (activity!!.isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
9695

9796
view.apply {
9897
with(checklist_fab) {
9998
setImageDrawable(plusIcon)
100-
background.applyColorFilter(requiredActivity.getAdjustedPrimaryColor())
99+
background.applyColorFilter(activity!!.getAdjustedPrimaryColor())
101100
setOnClickListener {
102101
showNewItemDialog()
103102
}
104103
}
105104

106105
with(fragment_placeholder_2) {
107-
setTextColor(requiredActivity.getAdjustedPrimaryColor())
106+
setTextColor(activity!!.getAdjustedPrimaryColor())
108107
underlineText()
109108
setOnClickListener {
110109
showNewItemDialog()
@@ -141,11 +140,11 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
141140
}
142141

143142
ChecklistAdapter(
144-
activity = activity as SimpleActivity,
145-
items = items,
146-
listener = this,
147-
recyclerView = view.checklist_list,
148-
showIcons = true
143+
activity = activity as SimpleActivity,
144+
items = items,
145+
listener = this,
146+
recyclerView = view.checklist_list,
147+
showIcons = true
149148
) { item ->
150149
val clickedNote = item as ChecklistItem
151150
clickedNote.isDone = !clickedNote.isDone

0 commit comments

Comments
 (0)