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