allow audioplayer and videoplayer to pass the view intent to the service if the app happens to be casting at the moment

This commit is contained in:
Domingos Lopes 2016-04-17 12:39:47 -04:00
parent efacb68657
commit 900dbf7beb
2 changed files with 10 additions and 18 deletions

View File

@ -1,7 +1,6 @@
package de.danoeh.antennapod.activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
@ -16,17 +15,6 @@ import de.danoeh.antennapod.core.util.playback.ExternalMedia;
public class AudioplayerActivity extends MediaplayerInfoActivity {
public static final String TAG = "AudioPlayerActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (CastManager.getInstance().isConnected()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(AudioplayerActivity.class.getName())) {
startActivity(intent);
}
}
}
@Override
protected void onResume() {
super.onResume();
@ -43,6 +31,11 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY,
true);
startService(launchIntent);
} else if (CastManager.getInstance().isConnected()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(AudioplayerActivity.class.getName())) {
startActivity(intent);
}
}
}

View File

@ -65,12 +65,6 @@ public class VideoplayerActivity extends MediaplayerActivity {
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); // has to be called before setting layout content
super.onCreate(savedInstanceState);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0x80000000));
if (CastManager.getInstance().isConnected()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
startActivity(intent);
}
}
}
@Override
@ -90,6 +84,11 @@ public class VideoplayerActivity extends MediaplayerActivity {
launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY,
true);
startService(launchIntent);
} else if (CastManager.getInstance().isConnected()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
startActivity(intent);
}
}
}