From ada6a473007d4403ad882edec7d2e68def1e84c3 Mon Sep 17 00:00:00 2001 From: Synced Synapse Date: Tue, 9 Jan 2024 17:25:21 +0000 Subject: [PATCH] Remove connection/disconnection to LibrarySyncService from fragments that don't have sync items (#1001) The creation and connection to the LibrarySyncService was being done by all descendants of AbstractInfoFragment, but this only needs to be done by fragments that have sync items. So, for instance the Addons info fragment was creating and connecting to the service even though it didn't have anything to do with it. This only creates and connects to the service if the fragment signals that it can use it (has sync items). --- .../main/java/org/xbmc/kore/ui/AbstractInfoFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/xbmc/kore/ui/AbstractInfoFragment.java b/app/src/main/java/org/xbmc/kore/ui/AbstractInfoFragment.java index eb3f9c0b2..141aadc27 100644 --- a/app/src/main/java/org/xbmc/kore/ui/AbstractInfoFragment.java +++ b/app/src/main/java/org/xbmc/kore/ui/AbstractInfoFragment.java @@ -206,7 +206,9 @@ public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) { @Override public void onStart() { super.onStart(); - serviceConnection = SyncUtils.connectToLibrarySyncService(getActivity(), this); + if (getSyncType() != null) { + serviceConnection = SyncUtils.connectToLibrarySyncService(getActivity(), this); + } // Force the exit view to invisible binding.exitTransitionView.setVisibility(View.INVISIBLE); } @@ -234,7 +236,9 @@ public void onPause() { @Override public void onStop() { - SyncUtils.disconnectFromLibrarySyncService(requireContext(), serviceConnection); + if (getSyncType() != null) { + SyncUtils.disconnectFromLibrarySyncService(requireContext(), serviceConnection); + } super.onStop(); }