コード例 #1
0
  private void setupDetailsOverviewRowPresenter() {
    // Set detail background and style.
    DetailsOverviewRowPresenter detailsPresenter =
        new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
    detailsPresenter.setBackgroundColor(getResources().getColor(R.color.selected_background));
    detailsPresenter.setStyleLarge(true);

    // Hook up transition element.
    detailsPresenter.setSharedElementEnterTransition(
        getActivity(), MovieDetailsActivity.SHARED_ELEMENT_NAME);

    detailsPresenter.setOnActionClickedListener(
        new OnActionClickedListener() {
          @Override
          public void onActionClicked(Action action) {
            if (action.getId() == ACTION_WATCH_TRAILER) {
              Intent intent = new Intent(getActivity(), PlaybackActivity.class);
              intent.putExtra(MovieDetailsActivity.MOVIE, mSelectedMovie);
              startActivity(intent);
            } else {
              Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
            }
          }
        });
    mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter);
  }
コード例 #2
0
    @Override
    protected void onPostExecute(DetailsOverviewRow detailRow) {
      ClassPresenterSelector ps = new ClassPresenterSelector();
      DetailsOverviewRowPresenter dorPresenter =
          new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
      // set detail background and style
      dorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background));
      dorPresenter.setStyleLarge(true);
      dorPresenter.setOnActionClickedListener(
          new OnActionClickedListener() {
            @Override
            public void onActionClicked(Action action) {
              if (action.getId() == ACTION_WATCH_TRAILER) {
                Intent intent = new Intent(getActivity(), PlayerActivity.class);
                intent.putExtra(getResources().getString(R.string.movie), selectedMovie);
                intent.putExtra(getResources().getString(R.string.should_start), true);
                startActivity(intent);
              } else {
                Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show();
              }
            }
          });

      ps.addClassPresenter(DetailsOverviewRow.class, dorPresenter);
      ps.addClassPresenter(ListRow.class, new ListRowPresenter());

      ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps);
      adapter.add(detailRow);

      String subcategories[] = {getString(R.string.related_movies)};
      List<Movie> list = MovieList.list;
      Collections.shuffle(list);
      ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
      for (int j = 0; j < NUM_COLS; j++) {
        listRowAdapter.add(list.get(j % 5));
      }

      HeaderItem header = new HeaderItem(0, subcategories[0], null);
      adapter.add(new ListRow(header, listRowAdapter));

      setAdapter(adapter);
    }