save current fragment before starting a different activity

This commit is contained in:
Domingos Lopes 2016-04-28 11:09:34 -04:00
parent f8266d0181
commit 358ad6484a
4 changed files with 9 additions and 1 deletions

View File

@ -41,6 +41,8 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
} else if (PlaybackService.isCasting()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(AudioplayerActivity.class.getName())) {
saveCurrentFragment();
finish();
startActivity(intent);
}
}
@ -50,6 +52,7 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
protected void onReloadNotification(int notificationCode) {
if (notificationCode == PlaybackService.EXTRA_CODE_CAST) {
Log.d(TAG, "ReloadNotification received, switching to Castplayer now");
saveCurrentFragment();
finish();
startActivity(new Intent(this, CastplayerActivity.class));

View File

@ -23,6 +23,7 @@ public class CastplayerActivity extends MediaplayerInfoActivity {
if (!PlaybackService.isCasting()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(CastplayerActivity.class.getName())) {
finish();
startActivity(intent);
}
}
@ -32,6 +33,7 @@ public class CastplayerActivity extends MediaplayerInfoActivity {
protected void onReloadNotification(int notificationCode) {
if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO) {
Log.d(TAG, "ReloadNotification received, switching to Audioplayer now");
saveCurrentFragment();
finish();
startActivity(new Intent(this, AudioplayerActivity.class));
} else {
@ -59,6 +61,8 @@ public class CastplayerActivity extends MediaplayerInfoActivity {
if (!PlaybackService.isCasting()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(CastplayerActivity.class.getName())) {
saveCurrentFragment();
finish();
startActivity(intent);
}
}

View File

@ -134,7 +134,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
setTheme(UserPreferences.getNoTitleTheme());
}
private void saveCurrentFragment() {
protected void saveCurrentFragment() {
if(pager == null) {
return;
}

View File

@ -86,6 +86,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
} else if (PlaybackService.isCasting()) {
Intent intent = PlaybackService.getPlayerActivityIntent(this);
if (!intent.getComponent().getClassName().equals(VideoplayerActivity.class.getName())) {
finish();
startActivity(intent);
}
}