Make demo app ready for multi-window environment coming with N.

* Do not stop playback onPause but onStop in N and greater.
* Fix back navigation after app has been put to background.
* Make VIEW intent work when PlaybackActitivty is already launched.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=118022964
This commit is contained in:
olly 2016-03-24 06:01:19 -07:00 committed by Oliver Woodman
parent d5c80a31e8
commit 454b3e896c
2 changed files with 31 additions and 3 deletions

View file

@ -41,8 +41,8 @@
</activity> </activity>
<activity android:name="com.google.android.exoplayer.demo.PlayerActivity" <activity android:name="com.google.android.exoplayer.demo.PlayerActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:launchMode="singleInstance" android:launchMode="singleTop"
android:label="@string/application_name" android:label="@string/application_name"
android:theme="@style/PlayerTheme"> android:theme="@style/PlayerTheme">
<intent-filter> <intent-filter>

View file

@ -180,9 +180,23 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
setIntent(intent); setIntent(intent);
} }
@Override
public void onStart() {
super.onStart();
if (Util.SDK_INT > 23) {
onShown();
}
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (Util.SDK_INT <= 23 || player == null) {
onShown();
}
}
private void onShown() {
Intent intent = getIntent(); Intent intent = getIntent();
contentUri = intent.getData(); contentUri = intent.getData();
contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA, contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA,
@ -197,9 +211,23 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
@Override @Override
public void onPause() { public void onPause() {
super.onPause();
if (Util.SDK_INT <= 23) {
onHidden();
}
}
@Override
public void onStop() {
super.onStop();
if (Util.SDK_INT > 23) {
onHidden();
}
}
private void onHidden() {
shutterView.setVisibility(View.VISIBLE); shutterView.setVisibility(View.VISIBLE);
releasePlayer(); releasePlayer();
super.onPause();
} }
// OnClickListener methods // OnClickListener methods