diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-04-04 21:58:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 21:58:36 +0200 |
commit | 0288d4e51eb7eef565be8d814fb8c152383e5031 (patch) | |
tree | 39c16b63f4d5503df2e08fe07b959c6bed40b678 /app/src/main/java/de | |
parent | e894ff1ccb279237be2ab04063d1f7505b30a86f (diff) | |
download | AntennaPod-0288d4e51eb7eef565be8d814fb8c152383e5031.zip |
Small database efficiency tweaks (#7058)
- When checking whether there is a subscription, there is no need to create feed objects (plus counters etc). Just the number of episodes is enough.
- Downloads section only needs to load the items it actually displays.
- No need to load FeedMedia, just to load FeedItem including the same FeedMedia afterwards.
- No need to convert columns to Strings and back to Longs.
- No need to join favorites when we are only interested in the list of IDs anyway.
Diffstat (limited to 'app/src/main/java/de')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/ui/screen/home/HomeFragment.java | 12 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java | 5 |
2 files changed, 6 insertions, 11 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/HomeFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/HomeFragment.java index bcbc2675a..0ed96a70c 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/HomeFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/HomeFragment.java @@ -19,6 +19,7 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentContainerView; +import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.net.download.serviceinterface.FeedUpdateManager; import de.danoeh.antennapod.ui.echo.EchoConfig; import de.danoeh.antennapod.ui.screen.home.sections.AllowNotificationsSection; @@ -44,7 +45,6 @@ import de.danoeh.antennapod.databinding.HomeFragmentBinding; import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.FeedUpdateRunningEvent; import de.danoeh.antennapod.ui.screen.SearchFragment; -import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.ui.view.LiftOnScrollListener; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -193,14 +193,12 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis if (disposable != null) { disposable.dispose(); } - disposable = Observable.fromCallable(() -> - DBReader.getNavDrawerData(UserPreferences.getSubscriptionsFilter(), - UserPreferences.getFeedOrder(), UserPreferences.getFeedCounterSetting()).items.size()) + disposable = Observable.fromCallable(() -> DBReader.getTotalEpisodeCount(FeedItemFilter.unfiltered())) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(numSubscriptions -> { - viewBinding.welcomeContainer.setVisibility(numSubscriptions == 0 ? View.VISIBLE : View.GONE); - viewBinding.homeContainer.setVisibility(numSubscriptions == 0 ? View.GONE : View.VISIBLE); + .subscribe(numEpisodes -> { + viewBinding.welcomeContainer.setVisibility(numEpisodes == 0 ? View.VISIBLE : View.GONE); + viewBinding.homeContainer.setVisibility(numEpisodes == 0 ? View.GONE : View.VISIBLE); }, error -> Log.e(TAG, Log.getStackTraceString(error))); } diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java index 4dc34a80e..cc3288e2f 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/home/sections/DownloadsSection.java @@ -124,14 +124,11 @@ public class DownloadsSection extends HomeSection { disposable.dispose(); } SortOrder sortOrder = UserPreferences.getDownloadsSortedOrder(); - disposable = Observable.fromCallable(() -> DBReader.getEpisodes(0, Integer.MAX_VALUE, + disposable = Observable.fromCallable(() -> DBReader.getEpisodes(0, NUM_EPISODES, new FeedItemFilter(FeedItemFilter.DOWNLOADED), sortOrder)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(downloads -> { - if (downloads.size() > NUM_EPISODES) { - downloads = downloads.subList(0, NUM_EPISODES); - } items = downloads; adapter.setDummyViews(0); adapter.updateItems(items); |