Browse Source

fix LiveData value assignment nullability mismatch

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 năm trước cách đây
mục cha
commit
9afe4e44d6

+ 3 - 1
app/src/main/java/com/nextcloud/talk/polls/ui/PollResultsFragment.kt

@@ -92,7 +92,9 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
 
         viewModel.items.observe(viewLifecycleOwner) {
             val adapter = PollResultsAdapter(user, this).apply {
-                list = it
+                if (it != null) {
+                    list = it
+                }
             }
             binding.pollResultsList.adapter = adapter
         }

+ 2 - 2
app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollResultsViewModel.kt

@@ -65,8 +65,8 @@ class PollResultsViewModel @Inject constructor() : ViewModel() {
 
     private var _unfilteredItems: ArrayList<PollResultItem> = ArrayList()
 
-    private var _items: MutableLiveData<ArrayList<PollResultItem>> = MutableLiveData<ArrayList<PollResultItem>>()
-    val items: LiveData<ArrayList<PollResultItem>>
+    private var _items: MutableLiveData<ArrayList<PollResultItem>?> = MutableLiveData<ArrayList<PollResultItem>?>()
+    val items: MutableLiveData<ArrayList<PollResultItem>?>
         get() = _items
 
     private var disposable: Disposable? = null