mirror of
https://github.com/samsonjs/media.git
synced 2026-04-03 10:55:48 +00:00
Prevent a Demo app NPE on Android TV
The options menu is not available on Android TV, which triggers a null pointer exception whenever a sample is chosen. This CL is a temporary fix until we rework the UI to not use an options menu. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=209742076
This commit is contained in:
parent
afebd60ee4
commit
8927993b03
1 changed files with 8 additions and 2 deletions
|
|
@ -22,6 +22,7 @@ import android.content.res.AssetManager;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.JsonReader;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
|
|
@ -162,8 +163,8 @@ public class SampleChooserActivity extends Activity
|
|||
startActivity(
|
||||
sample.buildIntent(
|
||||
/* context= */ this,
|
||||
preferExtensionDecodersMenuItem.isChecked(),
|
||||
randomAbrMenuItem.isChecked()
|
||||
isNonNullAndChecked(preferExtensionDecodersMenuItem),
|
||||
isNonNullAndChecked(randomAbrMenuItem)
|
||||
? PlayerActivity.ABR_ALGORITHM_RANDOM
|
||||
: PlayerActivity.ABR_ALGORITHM_DEFAULT));
|
||||
return true;
|
||||
|
|
@ -198,6 +199,11 @@ public class SampleChooserActivity extends Activity
|
|||
return 0;
|
||||
}
|
||||
|
||||
private static boolean isNonNullAndChecked(@Nullable MenuItem menuItem) {
|
||||
// Temporary workaround for layouts that do not inflate the options menu.
|
||||
return menuItem != null && menuItem.isChecked();
|
||||
}
|
||||
|
||||
private final class SampleListLoader extends AsyncTask<String, Void, List<SampleGroup>> {
|
||||
|
||||
private boolean sawError;
|
||||
|
|
|
|||
Loading…
Reference in a new issue