in LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/app/MainFragment.java [106:206]
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
Intent intent = null;
Card card = (Card) item;
int id = card.getId();
switch (id) {
case 0: {
intent = new Intent(getActivity().getBaseContext(),
CardExampleActivity.class);
break;
}
case 1:
intent = new Intent(getActivity().getBaseContext(),
PageAndListRowActivity.class);
break;
case 2: {
intent = new Intent(getActivity().getBaseContext(),
GridExampleActivity.class);
break;
}
case 3: {
intent = new Intent(getActivity().getBaseContext(),
VideoGridExampleActivity.class);
break;
}
case 4: {
intent = new Intent(getActivity().getBaseContext(),
DetailViewExampleActivity.class);
break;
}
case 5: {
intent = new Intent(getActivity().getBaseContext(),
DetailViewExampleWithVideoBackgroundActivity.class);
break;
}
case 6: {
intent = new Intent(getActivity().getBaseContext(),
VideoExampleActivity.class);
break;
}
case 7: {
intent = new Intent(getActivity().getBaseContext(),
VideoExampleWithExoPlayerActivity.class);
break;
}
case 8: {
intent = new Intent(getActivity().getBaseContext(),
MusicExampleActivity.class);
break;
}
case 9: {
// Let's create a new Wizard for a given Movie. The movie can come from any sort
// of data source. To simplify this example we decode it from a JSON source
// which might be loaded from a server in a real world example.
intent = new Intent(getActivity().getBaseContext(),
WizardExampleActivity.class);
// Prepare extras which contains the Movie and will be passed to the Activity
// which is started through the Intent/.
Bundle extras = new Bundle();
String json = Utils.inputStreamToString(
getResources().openRawResource(R.raw.wizard_example));
Movie movie = new Gson().fromJson(json, Movie.class);
extras.putSerializable("movie", movie);
intent.putExtras(extras);
// Finally, start the wizard Activity.
break;
}
case 10: {
intent = new Intent(getActivity().getBaseContext(),
SettingsExampleActivity.class);
startActivity(intent);
return;
}
case 11: {
intent = new Intent(getActivity().getBaseContext(),
DialogExampleActivity.class);
break;
}
case 12: {
intent = new Intent(getActivity().getBaseContext(),
DynamicVideoRowsActivity.class);
startActivity(intent);
return;
}
case 13: {
intent = new Intent(getActivity().getBaseContext(),
LiveDataRowsActivity.class);
startActivity(intent);
return;
}
default:
break;
}
if (intent != null) {
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity())
.toBundle();
startActivity(intent, bundle);
}
}