private void addOtherRows() {
   ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
   for (Movie movie : mItems) {
     listRowAdapter.add(movie);
   }
   HeaderItem header = new HeaderItem(0, getString(R.string.related_movies));
   mRowsAdapter.add(new ListRow(header, listRowAdapter));
 }
  public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(getResources().getColor(R.color.primary));
    setBadgeDrawable(getResources().getDrawable(R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
      ObjectAdapter rowContents =
          new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
      VideoDataManager manager =
          new VideoDataManager(
              getActivity(),
              getLoaderManager(),
              VideoItemContract.VideoItem.buildDirUri(),
              rowContents);
      manager.startDataLoading();

      HeaderItem headerItem = new HeaderItem(position, HEADERS[position], null);
      mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());
    setOnItemViewSelectedListener(getDefaultItemSelectedListener());

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();
  }
Exemplo n.º 3
0
  private void setupUIElements() {
    setBadgeDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.banner_shadow));
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.primary));
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.accent));

    setHeaderPresenterSelector(
        new PresenterSelector() {
          @Override
          public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
          }
        });

    boolean shouldAutoLoop = mPreferencesHelper.getShouldAutoLoop();
    String optionValue =
        shouldAutoLoop
            ? getString(R.string.text_auto_loop_enabled)
            : getString(R.string.text_auto_loop_disabled);

    mAutoLoopOption =
        new Option(getString(R.string.text_auto_loop_title), optionValue, R.drawable.lopp);

    HeaderItem gridHeader =
        new HeaderItem(mRowsAdapter.size(), getString(R.string.header_text_options));
    mOptionsAdapter = new OptionsAdapter(getActivity());
    mOptionsAdapter.addOption(mAutoLoopOption);
    mRowsAdapter.add(new ListRow(gridHeader, mOptionsAdapter));
  }
  private void setupMovieListRow() {
    String subcategories[] = {getString(R.string.related_movies)};
    HashMap<String, List<Movie>> movies = VideoProvider.getMovieList();

    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    for (Map.Entry<String, List<Movie>> entry : movies.entrySet()) {
      if (mSelectedMovie.getCategory().contains(entry.getKey())) {
        List<Movie> list = entry.getValue();
        for (int j = 0; j < list.size(); j++) {
          listRowAdapter.add(list.get(j));
        }
      }
    }
    HeaderItem header = new HeaderItem(0, subcategories[0]);
    mAdapter.add(new ListRow(header, listRowAdapter));
  }
    @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);
    }
  private void setupDetailsOverviewRow() {
    Log.d(TAG, "doInBackground: " + mSelectedMovie.toString());
    final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie);
    row.setImageDrawable(getResources().getDrawable(R.drawable.default_background));
    int width = Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_WIDTH);
    int height = Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_HEIGHT);

    Glide.with(getActivity())
        .load(mSelectedMovie.getCardImageUrl())
        .centerCrop()
        .error(R.drawable.default_background)
        .into(
            new SimpleTarget<GlideDrawable>(width, height) {
              @Override
              public void onResourceReady(
                  GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                Log.d(TAG, "details overview card image url ready: " + resource);
                row.setImageDrawable(resource);
                mAdapter.notifyArrayItemRangeChanged(0, mAdapter.size());
              }
            });

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

    adapter.set(
        ACTION_WATCH_TRAILER,
        new Action(
            ACTION_WATCH_TRAILER,
            getResources().getString(R.string.watch_trailer_1),
            getResources().getString(R.string.watch_trailer_2)));
    adapter.set(
        ACTION_RENT,
        new Action(
            ACTION_RENT,
            getResources().getString(R.string.rent_1),
            getResources().getString(R.string.rent_2)));
    adapter.set(
        ACTION_BUY,
        new Action(
            ACTION_BUY,
            getResources().getString(R.string.buy_1),
            getResources().getString(R.string.buy_2)));
    row.setActionsAdapter(adapter);

    mAdapter.add(row);
  }
  private void addPlaybackControlsRow() {
    if (SHOW_DETAIL) {
      mPlaybackControlsRow = new PlaybackControlsRow(mSelectedMovie);
    } else {
      mPlaybackControlsRow = new PlaybackControlsRow();
    }
    mRowsAdapter.add(mPlaybackControlsRow);

    updatePlaybackRow(mCurrentItem);

    ControlButtonPresenterSelector presenterSelector = new ControlButtonPresenterSelector();
    mPrimaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
    mSecondaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
    mPlaybackControlsRow.setPrimaryActionsAdapter(mPrimaryActionsAdapter);
    mPlaybackControlsRow.setSecondaryActionsAdapter(mSecondaryActionsAdapter);

    mPlayPauseAction = new PlayPauseAction(sContext);
    mRepeatAction = new RepeatAction(sContext);
    mThumbsUpAction = new ThumbsUpAction(sContext);
    mThumbsDownAction = new ThumbsDownAction(sContext);
    mShuffleAction = new ShuffleAction(sContext);
    mSkipNextAction = new PlaybackControlsRow.SkipNextAction(sContext);
    mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(sContext);
    mFastForwardAction = new PlaybackControlsRow.FastForwardAction(sContext);
    mRewindAction = new PlaybackControlsRow.RewindAction(sContext);

    if (PRIMARY_CONTROLS > 5) {
      mPrimaryActionsAdapter.add(mThumbsUpAction);
    } else {
      mSecondaryActionsAdapter.add(mThumbsUpAction);
    }

    mPrimaryActionsAdapter.add(mSkipPreviousAction);

    if (PRIMARY_CONTROLS > 3) {
      mPrimaryActionsAdapter.add(new PlaybackControlsRow.RewindAction(sContext));
    }

    mPrimaryActionsAdapter.add(mPlayPauseAction);

    if (PRIMARY_CONTROLS > 3) {
      mPrimaryActionsAdapter.add(new PlaybackControlsRow.FastForwardAction(sContext));
    }

    mPrimaryActionsAdapter.add(mSkipNextAction);

    mSecondaryActionsAdapter.add(mRepeatAction);
    mSecondaryActionsAdapter.add(mShuffleAction);

    if (PRIMARY_CONTROLS > 5) {
      mPrimaryActionsAdapter.add(mThumbsDownAction);
    } else {
      mSecondaryActionsAdapter.add(mThumbsDownAction);
    }
    mSecondaryActionsAdapter.add(new PlaybackControlsRow.HighQualityAction(sContext));
    mSecondaryActionsAdapter.add(new PlaybackControlsRow.ClosedCaptioningAction(sContext));
  }
Exemplo n.º 8
0
 private void loadPostsFromCategory(String tag, int headerPosition) {
   PostAdapter listRowAdapter = new PostAdapter(getActivity(), tag);
   addPostLoadSubscription(listRowAdapter);
   HeaderItem header = new HeaderItem(headerPosition, tag);
   mRowsAdapter.add(new ListRow(header, listRowAdapter));
 }