Fix infinite refresh indicator (#7137)

Before when refreshing any feed(s) without network the refresh indicator
stayed indefinitely.

This was also the case if you were on mobile, trying to refresh a need
and in the popup selected "don't update over mobile".
This commit is contained in:
flofriday 2024-04-25 22:42:23 +02:00 committed by GitHub
parent 7b048ed579
commit 4cf362393a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import androidx.work.OutOfQuotaPolicy;
import androidx.work.PeriodicWorkRequest; import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager; import androidx.work.WorkManager;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import de.danoeh.antennapod.event.FeedUpdateRunningEvent;
import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.net.common.NetworkUtils;
import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.event.MessageEvent;
import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.Feed;
@ -90,6 +91,7 @@ public class FeedUpdateManagerImpl extends FeedUpdateManager {
runOnce(context, feed); runOnce(context, feed);
} else if (!NetworkUtils.networkAvailable()) { } else if (!NetworkUtils.networkAvailable()) {
EventBus.getDefault().post(new MessageEvent(context.getString(R.string.download_error_no_connection))); EventBus.getDefault().post(new MessageEvent(context.getString(R.string.download_error_no_connection)));
EventBus.getDefault().postSticky(new FeedUpdateRunningEvent(false));
} else if (NetworkUtils.isFeedRefreshAllowed()) { } else if (NetworkUtils.isFeedRefreshAllowed()) {
runOnce(context, feed); runOnce(context, feed);
} else { } else {
@ -106,7 +108,9 @@ public class FeedUpdateManagerImpl extends FeedUpdateManager {
UserPreferences.setAllowMobileFeedRefresh(true); UserPreferences.setAllowMobileFeedRefresh(true);
runOnce(context, feed); runOnce(context, feed);
}) })
.setNegativeButton(R.string.no, null); .setNegativeButton(R.string.no, (dialog, which) -> {
EventBus.getDefault().postSticky(new FeedUpdateRunningEvent(false));
});
if (NetworkUtils.isNetworkRestricted() && NetworkUtils.isVpnOverWifi()) { if (NetworkUtils.isNetworkRestricted() && NetworkUtils.isVpnOverWifi()) {
builder.setMessage(R.string.confirm_mobile_feed_refresh_dialog_message_vpn); builder.setMessage(R.string.confirm_mobile_feed_refresh_dialog_message_vpn);
} else { } else {