From a722bcd1a51fc0bf34b08dc959e8b47dbccdd49a Mon Sep 17 00:00:00 2001 From: Aman Jain Date: Sun, 7 Dec 2025 01:55:20 +0530 Subject: [PATCH] Show progress indicator when archiving podcasts via multi-select (#8133) --- .../ui/screen/feed/RemoveFeedDialog.java | 46 +++++++++++++++++-- ui/i18n/src/main/res/values/strings.xml | 2 + 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/RemoveFeedDialog.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/RemoveFeedDialog.java index 3d41bbcf2..c2bc5821c 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/RemoveFeedDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/RemoveFeedDialog.java @@ -125,7 +125,9 @@ public class RemoveFeedDialog extends BottomSheetDialogFragment { disposable = Completable.fromAction( () -> { - for (Feed feed : feeds) { + for (int i = 0; i < feeds.size(); i++) { + Feed feed = feeds.get(i); + updateProgressText(R.string.deleting_podcast_progress, i + 1, feeds.size()); DBWriter.deleteFeed(context, feed.getId()).get(); } }) @@ -142,9 +144,45 @@ public class RemoveFeedDialog extends BottomSheetDialogFragment { } private void onArchiveButtonPressed() { - dismiss(); - for (Feed feed : feeds) { - DBWriter.setFeedState(getContext(), feed, Feed.STATE_ARCHIVED); + Context context = getContext(); + if (context == null) { + return; + } + + binding.progressBar.setVisibility(View.VISIBLE); + binding.removeButton.setVisibility(View.GONE); + binding.archiveButton.setVisibility(View.GONE); + binding.cancelButton.setVisibility(View.GONE); + + disposable = Completable.fromAction( + () -> { + for (int i = 0; i < feeds.size(); i++) { + Feed feed = feeds.get(i); + updateProgressText(R.string.archiving_podcast_progress, i + 1, feeds.size()); + DBWriter.setFeedState(context, feed, Feed.STATE_ARCHIVED).get(); + } + }) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + () -> { + Log.d(TAG, "Feed(s) archived"); + dismiss(); + }, error -> { + Log.e(TAG, Log.getStackTraceString(error)); + dismiss(); + }); + } + + private void updateProgressText(int stringResId, int currentIndex, int total) { + // Update UI on main thread if fragment is still attached + if (isAdded() && getActivity() != null) { + getActivity().runOnUiThread(() -> { + if (binding != null) { + String progressText = getString(stringResId, currentIndex, total); + binding.selectionText.setText(progressText); + } + }); } } diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 5be76a679..272676b10 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -214,6 +214,8 @@ Share file Deleting will remove ALL its episodes including downloads, playback history, and statistics. Archiving will hide it from the subscription list and avoid it getting updates. Downloads, statistics and playback state are kept. + Archiving podcast %1$d of %2$d… + Deleting podcast %1$d of %2$d… Refresh complete podcast Multi select Select all above