diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt index d83663b5..4adbc2df 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt @@ -30,6 +30,8 @@ import com.simplemobiletools.notes.pro.models.Note import com.simplemobiletools.notes.pro.models.NoteType import com.simplemobiletools.notes.pro.models.Widget import kotlinx.android.synthetic.main.widget_config.* +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.json.Json class WidgetConfigureActivity : SimpleActivity() { private var mBgAlpha = 0f diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt index 8eb5f708..9a05e03a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt @@ -31,7 +31,7 @@ import kotlinx.android.synthetic.main.item_checklist.view.* import java.util.* class ChecklistAdapter( - activity: BaseSimpleActivity, var items: ArrayList, val listener: ChecklistItemsListener?, + activity: BaseSimpleActivity, var items: MutableList, val listener: ChecklistItemsListener?, recyclerView: MyRecyclerView, val showIcons: Boolean, itemClick: (Any) -> Unit ) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), ItemTouchHelperContract { diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt index e01751e1..3f71fd48 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt @@ -21,6 +21,8 @@ import com.simplemobiletools.notes.pro.helpers.* import com.simplemobiletools.notes.pro.models.ChecklistItem import com.simplemobiletools.notes.pro.models.Note import com.simplemobiletools.notes.pro.models.NoteType +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.json.Json class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsService.RemoteViewsFactory { private val textIds = arrayOf( @@ -33,7 +35,7 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi ) private var widgetTextColor = DEFAULT_WIDGET_TEXT_COLOR private var note: Note? = null - private var checklistItems = ArrayList() + private var checklistItems = mutableListOf() override fun getViewAt(position: Int): RemoteViews { val noteId = intent.getLongExtra(NOTE_ID, 0L) @@ -125,8 +127,7 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi val noteId = intent.getLongExtra(NOTE_ID, 0L) note = context.notesDB.getNoteWithId(noteId) if (note?.type == NoteType.TYPE_CHECKLIST) { - val checklistItemType = object : TypeToken>() {}.type - checklistItems = Gson().fromJson>(note!!.getNoteStoredValue(context), checklistItemType) ?: ArrayList(1) + checklistItems = note!!.getNoteStoredValue(context)?.let { Json.decodeFromString(it) } ?: mutableListOf() // checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt index ffd1c840..0f44895a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt @@ -29,7 +29,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { lateinit var view: ViewGroup - var items = ArrayList() + var items = mutableListOf() override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { view = inflater.inflate(R.layout.fragment_checklist, container, false) as ViewGroup