mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-27 09:01:22 +01:00
Using utils
This commit is contained in:
parent
02186a3f0d
commit
9cf71f85b9
@ -31,6 +31,7 @@ import android.widget.ListView;
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import de.danoeh.antennapod.core.event.ServiceEvent;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
@ -627,9 +628,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
|
||||
remover.skipOnCompletion = true;
|
||||
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
||||
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
||||
sendBroadcast(new Intent(
|
||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)
|
||||
.setPackage(getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(MainActivity.this, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||
}
|
||||
}
|
||||
remover.executeAsync();
|
||||
|
@ -45,6 +45,7 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.Flavors;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.ShareUtils;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.Supplier;
|
||||
@ -863,8 +864,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
||||
}
|
||||
|
||||
if (butSkip != null) {
|
||||
butSkip.setOnClickListener(v -> sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE)
|
||||
.setPackage(getPackageName())));
|
||||
butSkip.setOnClickListener(v ->
|
||||
IntentUtils.sendLocalBroadcast(MediaplayerActivity.this, PlaybackService.ACTION_SKIP_CURRENT_EPISODE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
||||
@ -413,9 +414,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
|
||||
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
|
||||
remover.skipOnCompletion = true;
|
||||
if(controller.getStatus() == PlayerStatus.PLAYING) {
|
||||
sendBroadcast(new Intent(
|
||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)
|
||||
.setPackage(getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(MediaplayerInfoActivity.this, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
@ -86,15 +87,13 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
|
||||
.startWhenPrepared(true)
|
||||
.shouldStream(false)
|
||||
.start();
|
||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||
} else if (media.isCurrentlyPaused()) {
|
||||
new PlaybackServiceStarter(context, media)
|
||||
.startWhenPrepared(true)
|
||||
.shouldStream(false)
|
||||
.start();
|
||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE);
|
||||
} else {
|
||||
DBTasks.playMedia(context, media, false, true, false);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import android.widget.GridView;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.activity.MediaplayerInfoActivity;
|
||||
import de.danoeh.antennapod.adapter.SubscriptionsAdapter;
|
||||
import de.danoeh.antennapod.core.asynctask.FeedRemover;
|
||||
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
||||
@ -26,6 +27,7 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
@ -211,9 +213,8 @@ public class SubscriptionFragment extends Fragment {
|
||||
remover.skipOnCompletion = true;
|
||||
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
||||
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
||||
getActivity().sendBroadcast(new Intent(
|
||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)
|
||||
.setPackage(getContext().getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(getContext(), PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||
|
||||
}
|
||||
}
|
||||
remover.executeAsync();
|
||||
|
@ -158,8 +158,7 @@ public class FeedItemMenuHandler {
|
||||
FeedItem selectedItem) {
|
||||
switch (menuItemId) {
|
||||
case R.id.skip_episode_item:
|
||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||
break;
|
||||
case R.id.remove_item:
|
||||
DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId());
|
||||
|
@ -6,6 +6,9 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.activity.MediaplayerInfoActivity;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.BuildConfig;
|
||||
@ -41,8 +44,8 @@ public class SPAUtil {
|
||||
}
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
||||
if (!prefs.getBoolean(PREF_HAS_QUERIED_SP_APPS, false)) {
|
||||
appContext.sendBroadcast(new Intent(SPAReceiver.ACTION_SP_APPS_QUERY_FEEDS)
|
||||
.setPackage(context.getPackageName()));
|
||||
appContext.sendBroadcast(new Intent(SPAReceiver.ACTION_SP_APPS_QUERY_FEEDS));
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Sending SP_APPS_QUERY_FEEDS intent");
|
||||
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
@ -9,8 +9,10 @@ import java.util.concurrent.ExecutionException;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
|
||||
/** Removes a feed in the background. */
|
||||
public class FeedRemover extends AsyncTask<Void, Void, Void> {
|
||||
@ -41,8 +43,7 @@ public class FeedRemover extends AsyncTask<Void, Void, Void> {
|
||||
dialog.dismiss();
|
||||
}
|
||||
if(skipOnCompletion) {
|
||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.FeedSearcher;
|
||||
import de.danoeh.antennapod.core.util.IntList;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
import de.danoeh.antennapod.core.util.QueueAccess;
|
||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
||||
@ -699,10 +700,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
|
||||
}
|
||||
|
||||
Intent statusUpdate = new Intent(ACTION_PLAYER_STATUS_CHANGED);
|
||||
// statusUpdate.putExtra(EXTRA_NEW_PLAYER_STATUS, newInfo.playerStatus.ordinal());
|
||||
statusUpdate.setPackage(getPackageName());
|
||||
sendBroadcast(statusUpdate);
|
||||
IntentUtils.sendLocalBroadcast(getApplicationContext(), ACTION_PLAYER_STATUS_CHANGED);
|
||||
PlayerWidgetJobService.updateWidget(getBaseContext());
|
||||
bluetoothNotifyChange(newInfo, AVRCP_ACTION_PLAYER_STATUS_CHANGED);
|
||||
bluetoothNotifyChange(newInfo, AVRCP_ACTION_META_CHANGED);
|
||||
|
@ -36,6 +36,7 @@ import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
|
||||
import de.danoeh.antennapod.core.util.exception.MediaFileNotFoundException;
|
||||
@ -142,9 +143,7 @@ public final class DBTasks {
|
||||
} catch (MediaFileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
if (media.isPlaying()) {
|
||||
context.sendBroadcast(new Intent(
|
||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||
}
|
||||
notifyMissingFeedMediaFile(context, media);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import org.shredzone.flattr4j.model.Flattr;
|
||||
|
||||
import java.io.File;
|
||||
@ -116,12 +117,8 @@ public class DBWriter {
|
||||
true);
|
||||
editor.commit();
|
||||
}
|
||||
if (PlaybackPreferences
|
||||
.getCurrentlyPlayingFeedMediaId() == media
|
||||
.getId()) {
|
||||
context.sendBroadcast(new Intent(
|
||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)
|
||||
.setPackage(context.getPackageName()));
|
||||
if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == media.getId()) {
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||
}
|
||||
}
|
||||
// Gpodder: queue delete action for synchronization
|
||||
@ -158,9 +155,7 @@ public class DBWriter {
|
||||
if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA
|
||||
&& PlaybackPreferences.getLastPlayedFeedId() == feed
|
||||
.getId()) {
|
||||
context.sendBroadcast(new Intent(
|
||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putLong(
|
||||
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID,
|
||||
|
@ -9,6 +9,8 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -251,9 +253,7 @@ public class DownloadRequester {
|
||||
*/
|
||||
public synchronized void cancelAllDownloads(Context context) {
|
||||
Log.d(TAG, "Cancelling all running downloads");
|
||||
context.sendBroadcast(new Intent(
|
||||
DownloadService.ACTION_CANCEL_ALL_DOWNLOADS)
|
||||
.setPackage(context.getPackageName()));
|
||||
IntentUtils.sendLocalBroadcast(context, DownloadService.ACTION_CANCEL_ALL_DOWNLOADS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,4 +23,8 @@ public class IntentUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void sendLocalBroadcast(Context context, String action) {
|
||||
context.sendBroadcast(new Intent(action).setPackage(context.getPackageName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user