From 09dc830c86d88cb67561d453f932ed09f1877e24 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 13 Nov 2023 16:44:29 +0100 Subject: [PATCH] fix: Collect the server capabilities in SFragment subclasses (#252) Not all subclasses were calling `super.onViewCreated()` so collecting the server capability wasn't happening consistently. Fix this, and add a `@CallSuper` annotation to prevent the problem from recurring. --- .../app/pachli/components/conversation/ConversationsFragment.kt | 1 + .../java/app/pachli/components/timeline/TimelineFragment.kt | 1 + .../java/app/pachli/components/viewthread/ViewThreadFragment.kt | 1 + app/src/main/java/app/pachli/fragment/SFragment.kt | 2 ++ 4 files changed, 5 insertions(+) diff --git a/app/src/main/java/app/pachli/components/conversation/ConversationsFragment.kt b/app/src/main/java/app/pachli/components/conversation/ConversationsFragment.kt index 7b21a8ed9..bce4e35c3 100644 --- a/app/src/main/java/app/pachli/components/conversation/ConversationsFragment.kt +++ b/app/src/main/java/app/pachli/components/conversation/ConversationsFragment.kt @@ -99,6 +99,7 @@ class ConversationsFragment : } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) viewLifecycleOwner.lifecycleScope.launch { diff --git a/app/src/main/java/app/pachli/components/timeline/TimelineFragment.kt b/app/src/main/java/app/pachli/components/timeline/TimelineFragment.kt index 50109dbbf..4aa32f9a4 100644 --- a/app/src/main/java/app/pachli/components/timeline/TimelineFragment.kt +++ b/app/src/main/java/app/pachli/components/timeline/TimelineFragment.kt @@ -178,6 +178,7 @@ class TimelineFragment : } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) layoutManager = LinearLayoutManager(context) diff --git a/app/src/main/java/app/pachli/components/viewthread/ViewThreadFragment.kt b/app/src/main/java/app/pachli/components/viewthread/ViewThreadFragment.kt index 326e0221b..8aaaf9401 100644 --- a/app/src/main/java/app/pachli/components/viewthread/ViewThreadFragment.kt +++ b/app/src/main/java/app/pachli/components/viewthread/ViewThreadFragment.kt @@ -103,6 +103,7 @@ class ViewThreadFragment : } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) binding.swipeRefreshLayout.setOnRefreshListener(this) diff --git a/app/src/main/java/app/pachli/fragment/SFragment.kt b/app/src/main/java/app/pachli/fragment/SFragment.kt index 978d02290..b405c2e3e 100644 --- a/app/src/main/java/app/pachli/fragment/SFragment.kt +++ b/app/src/main/java/app/pachli/fragment/SFragment.kt @@ -30,6 +30,7 @@ import android.os.Environment import android.view.MenuItem import android.view.View import android.widget.Toast +import androidx.annotation.CallSuper import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.PopupMenu import androidx.core.app.ActivityOptionsCompat @@ -109,6 +110,7 @@ abstract class SFragment : Fragment() { } } + @CallSuper override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState)