Converted to EventBus instead of broadcast
This commit is contained in:
parent
e2ec07f607
commit
190b54ad70
|
@ -11,6 +11,7 @@ import android.util.Log;
|
||||||
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.core.dialog.ConfirmationDialog;
|
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
||||||
|
import de.danoeh.antennapod.core.event.settings.VolumeAdaptionChangedEvent;
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
import de.danoeh.antennapod.core.feed.Feed;
|
||||||
import de.danoeh.antennapod.core.feed.FeedFilter;
|
import de.danoeh.antennapod.core.feed.FeedFilter;
|
||||||
import de.danoeh.antennapod.core.feed.FeedPreferences;
|
import de.danoeh.antennapod.core.feed.FeedPreferences;
|
||||||
|
@ -26,6 +27,8 @@ import io.reactivex.MaybeOnSubscribe;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -234,11 +237,8 @@ public class FeedSettingsFragment extends PreferenceFragmentCompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendVolumeAdaptionChangedIntent() {
|
private void sendVolumeAdaptionChangedIntent() {
|
||||||
Context context = getContext();
|
EventBus.getDefault().post(
|
||||||
Intent intent = new Intent(PlaybackService.ACTION_VOLUME_ADAPTION_CHANGED).setPackage(context.getPackageName());
|
new VolumeAdaptionChangedEvent(feedPreferences.getVolumeAdaptionSetting(), feed.getId()));
|
||||||
intent.putExtra(PlaybackService.EXTRA_VOLUME_ADAPTION_AFFECTED_FEED, feed.getIdentifyingValue());
|
|
||||||
intent.putExtra(PlaybackService.EXTRA_VOLUME_ADAPTION_SETTING, feedPreferences.getVolumeAdaptionSetting());
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVolumeReductionValue() {
|
private void updateVolumeReductionValue() {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package de.danoeh.antennapod.core.event.settings;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.feed.VolumeAdaptionSetting;
|
||||||
|
|
||||||
|
public class VolumeAdaptionChangedEvent {
|
||||||
|
private final VolumeAdaptionSetting volumeAdaptionSetting;
|
||||||
|
private final long feedId;
|
||||||
|
|
||||||
|
public VolumeAdaptionChangedEvent(VolumeAdaptionSetting volumeAdaptionSetting, long feedId) {
|
||||||
|
this.volumeAdaptionSetting = volumeAdaptionSetting;
|
||||||
|
this.feedId = feedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeAdaptionSetting getVolumeAdaptionSetting() {
|
||||||
|
return volumeAdaptionSetting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFeedId() {
|
||||||
|
return feedId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,7 +41,6 @@ import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -51,13 +50,13 @@ import de.danoeh.antennapod.core.R;
|
||||||
import de.danoeh.antennapod.core.event.MessageEvent;
|
import de.danoeh.antennapod.core.event.MessageEvent;
|
||||||
import de.danoeh.antennapod.core.event.PlaybackPositionEvent;
|
import de.danoeh.antennapod.core.event.PlaybackPositionEvent;
|
||||||
import de.danoeh.antennapod.core.event.ServiceEvent;
|
import de.danoeh.antennapod.core.event.ServiceEvent;
|
||||||
|
import de.danoeh.antennapod.core.event.settings.VolumeAdaptionChangedEvent;
|
||||||
import de.danoeh.antennapod.core.feed.Chapter;
|
import de.danoeh.antennapod.core.feed.Chapter;
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
import de.danoeh.antennapod.core.feed.Feed;
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.core.feed.MediaType;
|
import de.danoeh.antennapod.core.feed.MediaType;
|
||||||
import de.danoeh.antennapod.core.feed.SearchResult;
|
import de.danoeh.antennapod.core.feed.SearchResult;
|
||||||
import de.danoeh.antennapod.core.feed.VolumeAdaptionSetting;
|
|
||||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||||
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
||||||
|
@ -79,6 +78,7 @@ import io.reactivex.Observable;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the MediaPlayer that plays a FeedMedia-file
|
* Controls the MediaPlayer that plays a FeedMedia-file
|
||||||
|
@ -136,13 +136,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
*/
|
*/
|
||||||
public static final String ACTION_PAUSE_PLAY_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.pausePlayCurrentEpisode";
|
public static final String ACTION_PAUSE_PLAY_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.pausePlayCurrentEpisode";
|
||||||
|
|
||||||
/**
|
|
||||||
* If the PlaybackService receives this action, it will try to apply the supplied volume adaption setting.
|
|
||||||
*/
|
|
||||||
public static final String ACTION_VOLUME_ADAPTION_CHANGED = "action.de.danoeh.antennapod.core.service.volumedAdaptionChanged";
|
|
||||||
public static final String EXTRA_VOLUME_ADAPTION_SETTING = "PlaybackService.VolumeAdaptionSettingExtra";
|
|
||||||
public static final String EXTRA_VOLUME_ADAPTION_AFFECTED_FEED = "PlaybackService.VolumeAdaptionSettingAffectedFeed";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom action used by Android Wear
|
* Custom action used by Android Wear
|
||||||
*/
|
*/
|
||||||
|
@ -284,7 +277,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
registerReceiver(audioBecomingNoisy, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY));
|
registerReceiver(audioBecomingNoisy, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY));
|
||||||
registerReceiver(skipCurrentEpisodeReceiver, new IntentFilter(ACTION_SKIP_CURRENT_EPISODE));
|
registerReceiver(skipCurrentEpisodeReceiver, new IntentFilter(ACTION_SKIP_CURRENT_EPISODE));
|
||||||
registerReceiver(pausePlayCurrentEpisodeReceiver, new IntentFilter(ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
registerReceiver(pausePlayCurrentEpisodeReceiver, new IntentFilter(ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
||||||
registerReceiver(volumeAdaptionChangedReceiver, new IntentFilter(ACTION_VOLUME_ADAPTION_CHANGED));
|
EventBus.getDefault().register(this);
|
||||||
taskManager = new PlaybackServiceTaskManager(this, taskManagerCallback);
|
taskManager = new PlaybackServiceTaskManager(this, taskManagerCallback);
|
||||||
|
|
||||||
flavorHelper = new PlaybackServiceFlavorHelper(PlaybackService.this, flavorHelperCallback);
|
flavorHelper = new PlaybackServiceFlavorHelper(PlaybackService.this, flavorHelperCallback);
|
||||||
|
@ -356,7 +349,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
unregisterReceiver(audioBecomingNoisy);
|
unregisterReceiver(audioBecomingNoisy);
|
||||||
unregisterReceiver(skipCurrentEpisodeReceiver);
|
unregisterReceiver(skipCurrentEpisodeReceiver);
|
||||||
unregisterReceiver(pausePlayCurrentEpisodeReceiver);
|
unregisterReceiver(pausePlayCurrentEpisodeReceiver);
|
||||||
unregisterReceiver(volumeAdaptionChangedReceiver);
|
|
||||||
flavorHelper.removeCastConsumer();
|
flavorHelper.removeCastConsumer();
|
||||||
flavorHelper.unregisterWifiBroadcastReceiver();
|
flavorHelper.unregisterWifiBroadcastReceiver();
|
||||||
mediaPlayer.shutdown();
|
mediaPlayer.shutdown();
|
||||||
|
@ -1445,21 +1437,11 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final BroadcastReceiver volumeAdaptionChangedReceiver = new BroadcastReceiver() {
|
@Subscribe
|
||||||
@Override
|
public void volumeAdaptionChanged(VolumeAdaptionChangedEvent event) {
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (TextUtils.equals(intent.getAction(), ACTION_VOLUME_ADAPTION_CHANGED)) {
|
|
||||||
Log.d(TAG, "Received ACTION_VOLUME_ADAPTION_CHANGED intent");
|
|
||||||
|
|
||||||
String affectedFeed = intent.getStringExtra(EXTRA_VOLUME_ADAPTION_AFFECTED_FEED);
|
|
||||||
Serializable volumeAdaptionExtra = intent.getSerializableExtra(EXTRA_VOLUME_ADAPTION_SETTING);
|
|
||||||
VolumeAdaptionSetting volumeAdaptionSetting = (VolumeAdaptionSetting) volumeAdaptionExtra;
|
|
||||||
|
|
||||||
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
|
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, affectedFeed, volumeAdaptionSetting);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, event.getFeedId(), event.getVolumeAdaptionSetting());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static MediaType getCurrentMediaType() {
|
public static MediaType getCurrentMediaType() {
|
||||||
return currentMediaType;
|
return currentMediaType;
|
||||||
|
|
|
@ -7,18 +7,20 @@ import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
|
|
||||||
class PlaybackVolumeUpdater {
|
class PlaybackVolumeUpdater {
|
||||||
|
|
||||||
public void updateVolumeIfNecessary(PlaybackServiceMediaPlayer mediaPlayer, String affectedFeedIdentifier, VolumeAdaptionSetting volumeAdaptionSetting) {
|
public void updateVolumeIfNecessary(PlaybackServiceMediaPlayer mediaPlayer, long feedId,
|
||||||
|
VolumeAdaptionSetting volumeAdaptionSetting) {
|
||||||
Playable playable = mediaPlayer.getPlayable();
|
Playable playable = mediaPlayer.getPlayable();
|
||||||
boolean isFeedMedia = playable instanceof FeedMedia;
|
boolean isFeedMedia = playable instanceof FeedMedia;
|
||||||
boolean isPlayableLoaded = isPlayableLoaded(mediaPlayer.getPlayerStatus());
|
boolean isPlayableLoaded = isPlayableLoaded(mediaPlayer.getPlayerStatus());
|
||||||
|
|
||||||
if (isFeedMedia && isPlayableLoaded) {
|
if (isFeedMedia && isPlayableLoaded) {
|
||||||
updateFeedMediaVolumeIfNecessary(mediaPlayer, affectedFeedIdentifier, volumeAdaptionSetting, (FeedMedia) playable);
|
updateFeedMediaVolumeIfNecessary(mediaPlayer, feedId, volumeAdaptionSetting, (FeedMedia) playable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFeedMediaVolumeIfNecessary(PlaybackServiceMediaPlayer mediaPlayer, String affectedFeedIdentifier, VolumeAdaptionSetting volumeAdaptionSetting, FeedMedia feedMedia) {
|
private void updateFeedMediaVolumeIfNecessary(PlaybackServiceMediaPlayer mediaPlayer, long feedId,
|
||||||
if (mediaBelongsToAffectedFeed(feedMedia, affectedFeedIdentifier)) {
|
VolumeAdaptionSetting volumeAdaptionSetting, FeedMedia feedMedia) {
|
||||||
|
if (feedMedia.getItem().getFeed().getId() == feedId) {
|
||||||
FeedPreferences preferences = feedMedia.getItem().getFeed().getPreferences();
|
FeedPreferences preferences = feedMedia.getItem().getFeed().getPreferences();
|
||||||
preferences.setVolumeAdaptionSetting(volumeAdaptionSetting);
|
preferences.setVolumeAdaptionSetting(volumeAdaptionSetting);
|
||||||
|
|
||||||
|
@ -37,11 +39,6 @@ class PlaybackVolumeUpdater {
|
||||||
|| playerStatus == PlayerStatus.INITIALIZING;
|
|| playerStatus == PlayerStatus.INITIALIZING;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean mediaBelongsToAffectedFeed(FeedMedia feedMedia, String affectedFeedIdentifier) {
|
|
||||||
return affectedFeedIdentifier != null
|
|
||||||
&& affectedFeedIdentifier.equals(feedMedia.getItem().getFeed().getIdentifyingValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void forceUpdateVolume(PlaybackServiceMediaPlayer mediaPlayer) {
|
private void forceUpdateVolume(PlaybackServiceMediaPlayer mediaPlayer) {
|
||||||
mediaPlayer.pause(false, false);
|
mediaPlayer.pause(false, false);
|
||||||
mediaPlayer.resume();
|
mediaPlayer.resume();
|
||||||
|
|
|
@ -18,12 +18,12 @@ import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class PlaybackVolumeUpdaterTest {
|
public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
private static final String FEED_ID = "feedId";
|
private static final long FEED_ID = 42;
|
||||||
|
|
||||||
private PlaybackServiceMediaPlayer mediaPlayer;
|
private PlaybackServiceMediaPlayer mediaPlayer;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() {
|
||||||
mediaPlayer = mock(PlaybackServiceMediaPlayer.class);
|
mediaPlayer = mock(PlaybackServiceMediaPlayer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +89,14 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noChangeIfPlayableIsNoItemOfAffectedFeed() {
|
public void noChangeIfPlayableIsNoItemOfAffectedFeed() {
|
||||||
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
|
|
||||||
|
|
||||||
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PLAYING);
|
when(mediaPlayer.getPlayerStatus()).thenReturn(PlayerStatus.PLAYING);
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
Feed feed = mockFeed(feedMedia, FEED_ID);
|
Feed feed = mockFeed(feedMedia);
|
||||||
when(feed.getIdentifyingValue()).thenReturn("wrongFeedId");
|
when(feed.getIdentifyingValue()).thenReturn("wrongFeedId");
|
||||||
|
|
||||||
|
PlaybackVolumeUpdater playbackVolumeUpdater = new PlaybackVolumeUpdater();
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.OFF);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.OFF);
|
||||||
|
|
||||||
verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
|
verify(mediaPlayer, never()).pause(anyBoolean(), anyBoolean());
|
||||||
|
@ -112,7 +111,7 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia, FEED_ID);
|
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia);
|
||||||
|
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
||||||
|
|
||||||
|
@ -130,7 +129,7 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia, FEED_ID);
|
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia);
|
||||||
|
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia, FEED_ID);
|
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia);
|
||||||
|
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
||||||
|
|
||||||
|
@ -166,7 +165,7 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia, FEED_ID);
|
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia);
|
||||||
|
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia, FEED_ID);
|
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia);
|
||||||
|
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.LIGHT_REDUCTION);
|
||||||
|
|
||||||
|
@ -202,7 +201,7 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
|
|
||||||
FeedMedia feedMedia = mock(FeedMedia.class);
|
FeedMedia feedMedia = mock(FeedMedia.class);
|
||||||
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
when(mediaPlayer.getPlayable()).thenReturn(feedMedia);
|
||||||
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia, FEED_ID);
|
FeedPreferences feedPreferences = mockFeedPreferences(feedMedia);
|
||||||
|
|
||||||
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.HEAVY_REDUCTION);
|
playbackVolumeUpdater.updateVolumeIfNecessary(mediaPlayer, FEED_ID, VolumeAdaptionSetting.HEAVY_REDUCTION);
|
||||||
|
|
||||||
|
@ -212,18 +211,18 @@ public class PlaybackVolumeUpdaterTest {
|
||||||
verify(mediaPlayer, times(1)).resume();
|
verify(mediaPlayer, times(1)).resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FeedPreferences mockFeedPreferences(FeedMedia feedMedia, String feedId) {
|
private FeedPreferences mockFeedPreferences(FeedMedia feedMedia) {
|
||||||
Feed feed = mockFeed(feedMedia, feedId);
|
Feed feed = mockFeed(feedMedia);
|
||||||
FeedPreferences feedPreferences = mock(FeedPreferences.class);
|
FeedPreferences feedPreferences = mock(FeedPreferences.class);
|
||||||
when(feed.getPreferences()).thenReturn(feedPreferences);
|
when(feed.getPreferences()).thenReturn(feedPreferences);
|
||||||
return feedPreferences;
|
return feedPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Feed mockFeed(FeedMedia feedMedia, String feedId) {
|
private Feed mockFeed(FeedMedia feedMedia) {
|
||||||
FeedItem feedItem = mock(FeedItem.class);
|
FeedItem feedItem = mock(FeedItem.class);
|
||||||
when(feedMedia.getItem()).thenReturn(feedItem);
|
when(feedMedia.getItem()).thenReturn(feedItem);
|
||||||
Feed feed = mock(Feed.class);
|
Feed feed = mock(Feed.class);
|
||||||
when(feed.getIdentifyingValue()).thenReturn(feedId);
|
when(feed.getId()).thenReturn(FEED_ID);
|
||||||
when(feedItem.getFeed()).thenReturn(feed);
|
when(feedItem.getFeed()).thenReturn(feed);
|
||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue