From dd53a6ed94d56f099a13e48b30ad8e90c587ec68 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 5 Feb 2020 18:33:36 +0100 Subject: [PATCH] Make lists react to events --- .../fragment/PlaybackHistoryFragment.java | 2 +- .../danoeh/antennapod/fragment/SearchFragment.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java index 63a2fc657..923a6325c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -93,7 +93,7 @@ public class PlaybackHistoryFragment extends ListFragment { } } - @Subscribe(sticky = true) + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEvent(DownloadEvent event) { Log.d(TAG, "onEvent() called with: " + "event = [" + event + "]"); DownloaderUpdate update = event.update; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java index 6a698ecce..7d284835d 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -21,11 +21,11 @@ import androidx.fragment.app.Fragment; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.FeedItemlistAdapter; +import de.danoeh.antennapod.core.event.DownloadEvent; import de.danoeh.antennapod.core.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedComponent; import de.danoeh.antennapod.core.feed.FeedItem; -import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.FeedSearcher; import de.danoeh.antennapod.view.EmptyViewHandler; import io.reactivex.Observable; @@ -34,11 +34,10 @@ import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; /** * Performs a search operation on all feeds or one specific feed and displays the search result. @@ -168,6 +167,14 @@ public class SearchFragment extends Fragment implements AdapterView.OnItemClickL search(); } + @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) + public void onEventMainThread(DownloadEvent event) { + Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); + if (searchAdapter != null) { + searchAdapter.notifyDataSetChanged(); + } + } + private void onSearchResults(List results) { progressBar.setVisibility(View.GONE); searchResults = results;