From 4cf519e96a273e5b6a8340b9ec1373f0be6ff586 Mon Sep 17 00:00:00 2001 From: Neel Doshi Date: Wed, 19 Jun 2024 14:49:59 +0530 Subject: [PATCH] Remove !! from loadCategories() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Irfan Ömür <2471769+irfano@users.noreply.github.com> --- .../wordpress/android/ui/posts/AddCategoryFragment.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.kt index 931a562f6f2f..c4030d07572b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.kt @@ -23,8 +23,8 @@ class AddCategoryFragment : AppCompatDialogFragment() { private var site: SiteModel? = null private var binding: AddCategoryBinding? = null - @set:Inject - var taxonomyStore: TaxonomyStore? = null + @Inject + lateinit var taxonomyStore: TaxonomyStore override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { (requireActivity().application as WordPress).component().inject(this) @@ -93,11 +93,7 @@ class AddCategoryFragment : AppCompatDialogFragment() { } private fun loadCategories() { - val rootCategory = CategoryNode.createCategoryTreeFromList( - taxonomyStore!!.getCategoriesForSite( - site!! - ) - ) + val rootCategory = site?.let { CategoryNode.createCategoryTreeFromList(taxonomyStore.getCategoriesForSite(it)) } val categoryLevels = CategoryNode.getSortedListOfCategoriesFromRoot(rootCategory) categoryLevels.add(0, CategoryNode(0, 0, getString(R.string.top_level_category_name))) if (categoryLevels.size > 0) {