android.support.v17.leanback.widget.ListRowPresenter Java Examples

The following examples show how to use android.support.v17.leanback.widget.ListRowPresenter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setSearchResultProvider(this);
    setOnItemViewClickedListener(new ItemViewClickedListener());
    if (!hasPermission(Manifest.permission.RECORD_AUDIO)) {
        // SpeechRecognitionCallback is not required and if not provided recognition will be handled
        // using internal speech recognizer, in which case you must have RECORD_AUDIO permission
        setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
            @Override
            public void recognizeSpeech() {
                if (DEBUG) Log.v(TAG, "recognizeSpeech");
                try {
                    startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
                } catch (ActivityNotFoundException e) {
                    Log.e(TAG, "Cannot find activity for speech recognizer", e);
                }
            }
        });
    }
}
 
Example #2
Source File: MainFragment.java    From TuentiTV with Apache License 2.0 6 votes vote down vote up
@Override public void showMainInformation(List<CardInfo> favorites, List<CardInfo> conversations,
    List<CardInfo> contacts, List<ImageInfo> mediaElements, List<IconInfo> preferences) {
  ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
  CardPresenter bigCardPresenter = new CardPresenter(CARD_WIDTH_IN_DP, CARD_HEIGHT_IN_DP);
  CardPresenter smallCarPresenter = new CardPresenter();

  addCardInfoElementsToRowsAdapter(R.string.favorites_item_title, favorites, rowsAdapter,
      smallCarPresenter, FAVORITES_ROW);
  addCardInfoElementsToRowsAdapter(R.string.recent_conversation_item_title, conversations,
      rowsAdapter, bigCardPresenter, CONVERSATIONS_ROW);
  addCardInfoElementsToRowsAdapter(R.string.contacts_item_title, contacts, rowsAdapter,
      smallCarPresenter, CONTACTS_ROW);
  addImageInfoElementsToRowAdapter(R.string.media_elements_item_title, mediaElements, rowsAdapter,
      new ImagePresenter(), MEDIA_ROW);
  addIconInfoElementsToRowAdapter(getResources().getString(R.string.preferences), preferences,
      rowsAdapter, new IconPresenter(), PREFERENCES_ROW);

  setAdapter(rowsAdapter);
}
 
Example #3
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
private void setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh) {
    RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter();
    RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder());

    if (rowVh instanceof ListRowPresenter.ViewHolder) {
        HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView();
        // Recycled view pool is shared between all list rows
        if (mRecycledViewPool == null) {
            mRecycledViewPool = view.getRecycledViewPool();
        } else {
            view.setRecycledViewPool(mRecycledViewPool);
        }

        ItemBridgeAdapter bridgeAdapter =
                ((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter();
        if (mPresenterMapper == null) {
            mPresenterMapper = bridgeAdapter.getPresenterMapper();
        } else {
            bridgeAdapter.setPresenterMapper(mPresenterMapper);
        }
    }
}
 
Example #4
Source File: RowsFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
private void setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh) {
    RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter();
    RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder());

    if (rowVh instanceof ListRowPresenter.ViewHolder) {
        HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView();
        // Recycled view pool is shared between all list rows
        if (mRecycledViewPool == null) {
            mRecycledViewPool = view.getRecycledViewPool();
        } else {
            view.setRecycledViewPool(mRecycledViewPool);
        }

        ItemBridgeAdapter bridgeAdapter =
                ((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter();
        if (mPresenterMapper == null) {
            mPresenterMapper = bridgeAdapter.getPresenterMapper();
        } else {
            bridgeAdapter.setPresenterMapper(mPresenterMapper);
        }
    }
}
 
Example #5
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), 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]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());

}
 
Example #6
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), 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]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

}
 
Example #7
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), 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]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

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

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();

}
 
Example #8
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), 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]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());

}
 
Example #9
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), 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]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

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

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();

}
 
Example #10
Source File: MainFragment.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
private void loadRows() {

        ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter( new ListRowPresenter() );
        CardPresenter cardPresenter = new CardPresenter();

        List<String> categories = getCategories();
        if( categories == null || categories.isEmpty() )
            return;

        for( String category : categories ) {
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter( cardPresenter );
            for( Movie movie : mMovies ) {
                if( category.equalsIgnoreCase( movie.getCategory() ) )
                    listRowAdapter.add( movie );
            }
            if( listRowAdapter.size() > 0 ) {
                HeaderItem header = new HeaderItem( rowsAdapter.size() - 1, category, null );
                rowsAdapter.add( new ListRow( header, listRowAdapter ) );
            }
        }

        setupPreferences( rowsAdapter );
        setAdapter( rowsAdapter );

    }
 
Example #11
Source File: CustomRowsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
private void loadRows() {
	rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
	cardPresenter = new CardPresenter();

	List<Movie> list = MovieList.setupMovies();

	int i;
	for (i = 0; i < NUM_ROWS; i++) {
		if (i != 0) {
			Collections.shuffle(list);
		}
		ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
		for (int j = 0; j < NUM_COLS; j++) {
			listRowAdapter.add(list.get(j % 5));
		}
		HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
		rowsAdapter.add(new ListRow(header, listRowAdapter));
	}

	setAdapter(rowsAdapter);
}
 
Example #12
Source File: CustomRowsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
private void loadRows() {
	rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
	cardPresenter = new CardPresenter();

	List<Movie> list = MovieList.setupMovies();

	int i;
	for (i = 0; i < NUM_ROWS; i++) {
		if (i != 0) {
			Collections.shuffle(list);
		}
		ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
		for (int j = 0; j < NUM_COLS; j++) {
			listRowAdapter.add(list.get(j % 5));
		}
		HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
		rowsAdapter.add(new ListRow(header, listRowAdapter));
	}

	setAdapter(rowsAdapter);
}
 
Example #13
Source File: MainFragment.java    From TvAppRepo with Apache License 2.0 6 votes vote down vote up
private void loadRows() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    mApkDownloadHelper = new ApkDownloadHelper(getActivity());
    // Setup the package installer for the session
    mApkDownloadHelper.addListener(mDownloadListener);
    HeaderItem header = null;

    if (getResources().getBoolean(R.bool.ENABLE_APP_REPO)) {
        createRowApkDownloads();
    }

    if (getResources().getBoolean(R.bool.ENABLE_DOWNLOADS_ROW)) {
        createRowDownloadedApks();
    }

    createRowShortcutGenerator();

    createRowCustomShortcuts();

    createRowMisc();

    setAdapter(mRowsAdapter);
}
 
Example #14
Source File: CustomRowsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<HashMap<String, List<Movie>>> arg0,
						   HashMap<String, List<Movie>> data) {

	rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
	CardPresenter cardPresenter = new CardPresenter();

	int i = 0;

	for (Map.Entry<String, List<Movie>> entry : data.entrySet()) {
		ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
		List<Movie> list = entry.getValue();

		for (int j = 0; j < list.size(); j++) {
			listRowAdapter.add(list.get(j));
		}
		HeaderItem header = new HeaderItem(i, entry.getKey());
		i++;
		rowsAdapter.add(new ListRow(header, listRowAdapter));
	}

	setAdapter(rowsAdapter);

	updateRecommendations();
}
 
Example #15
Source File: MoreSamplesFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
private void loadRows() {
    rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

    HeaderItem gridHeader = new HeaderItem(1, getString(R.string.more_samples));
    GridItemPresenter gridPresenter = new GridItemPresenter(this);

    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter);
    gridRowAdapter.add(getString(R.string.grid_view));
    gridRowAdapter.add(getString(R.string.guidedstep_first_title));
    gridRowAdapter.add(getString(R.string.error_fragment));
    gridRowAdapter.add(getString(R.string.personal_settings));

    rowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(rowsAdapter);
}
 
Example #16
Source File: TVDemoFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mCardPresenter = new CardPresenter();

    int i;
    for (i = 0; i < NUM_ROWS; i++) {
        if (i != 0) {
            Collections.shuffle(list);
        }
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter);
        for (int j = 0; j < NUM_COLS; j++) {
            listRowAdapter.add(list.get(j % 5));
        }
        HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES", null);

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.grid_view));
    gridRowAdapter.add(getResources().getString(R.string.send_feeback));
    gridRowAdapter.add(getResources().getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}
 
Example #17
Source File: DetailFragment.java    From TuentiTV with Apache License 2.0 5 votes vote down vote up
@Override public void showCardInfo(final CardInfo cardInfo) {
  new AsyncTask<Void, Void, Bitmap>() {

    @Override protected Bitmap doInBackground(Void... params) {
      Bitmap detailImage = null;
      try {
        detailImage = Picasso.with(getActivity())
            .load(cardInfo.getCardImageUrl())
            .placeholder(R.drawable.icn_wink)
            .error(R.drawable.icn_wink)
            .resize(Util.convertDpToPixel(getActivity(), DETAIL_THUMB_WIDTH),
                Util.convertDpToPixel(getActivity(), DETAIL_THUMB_HEIGHT))
            .centerCrop()
            .get();
      } catch (IOException e) {
        //Empty
      }
      return detailImage;
    }

    @Override protected void onPostExecute(Bitmap bitmap) {
      DetailsOverviewRow detailRow = configureDetailsOverviewRow(cardInfo, bitmap);
      ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
      DetailsOverviewRowPresenter dorPresenter =
          new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter());
      dorPresenter.setBackgroundColor(getResources().getColor(R.color.primary_color));
      dorPresenter.setStyleLarge(false);
      presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter);
      presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
      adapter = new ArrayObjectAdapter(presenterSelector);
      adapter.add(detailRow);
      setAdapter(adapter);
    }
  }.execute();
}
 
Example #18
Source File: SearchFragment.java    From TuentiTV with Apache License 2.0 5 votes vote down vote up
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
  setSearchResultProvider(this);
  setOnItemClickedListener(getDefaultItemClickedListener());
  delayedLoad = new SearchRunnable();
}
 
Example #19
Source File: SimpleClockDreamSettingsFragment.java    From androidtv-daydream with Apache License 2.0 5 votes vote down vote up
private void loadRows() {

        GridItemPresenter mGridPresenter = new GridItemPresenter();

        mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
        HeaderItem gridHeader = new HeaderItem(0, getString(R.string.setting_header));

        ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
        gridRowAdapter.add(getString(R.string.setting_12hour));
        gridRowAdapter.add(getString(R.string.setting_24hour));
        mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

        setAdapter(mRowsAdapter);
    }
 
Example #20
Source File: MainFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onLoadFinished(Loader<HashMap<String, List<Movie>>> arg0,
                           HashMap<String, List<Movie>> data) {

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    CardPresenter cardPresenter = new CardPresenter();

    int i = 0;

    for (Map.Entry<String, List<Movie>> entry : data.entrySet()) {
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
        List<Movie> list = entry.getValue();

        for (int j = 0; j < list.size(); j++) {
            listRowAdapter.add(list.get(j));
        }
        HeaderItem header = new HeaderItem(i, entry.getKey());
        i++;
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, getString(R.string.more_samples));

    GridItemPresenter gridPresenter = new GridItemPresenter(this);
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter);
    gridRowAdapter.add(getString(R.string.grid_view));
    gridRowAdapter.add(getString(R.string.guidedstep_first_title));
    gridRowAdapter.add(getString(R.string.error_fragment));
    gridRowAdapter.add(getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

    updateRecommendations();
}
 
Example #21
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
	setSearchResultProvider(this);
	setOnItemClickedListener(getDefaultItemClickedListener());
	mDelayedLoad = new SearchRunnable();
}
 
Example #22
Source File: BrowseFragment.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);
    mCardPresenter = new CardPresenter(getActivity());
    mTvShowsCardPresenter = new TvShowsCardPresenter(getActivity());
    mAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    addSettingsHeader();
    setAdapter(mAdapter);
    return v;
}
 
Example #23
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
	setSearchResultProvider(this);
	setOnItemClickedListener(getDefaultItemClickedListener());
	mDelayedLoad = new SearchRunnable();
}
 
Example #24
Source File: SearchFragment.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    allVideos = Source.listAll(Video.class);

    mListRowAdapter = new ArrayObjectAdapter(new CardPresenter(getActivity()));
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setSearchResultProvider(this);
    setOnItemClickedListener(getDefaultItemClickedListener());
    mDelayedLoad = new SearchRunnable();
}
 
Example #25
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
	setSearchResultProvider(this);
	setOnItemClickedListener(getDefaultItemClickedListener());
	mDelayedLoad = new SearchRunnable();
}
 
Example #26
Source File: DetailRowBuilderTask.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(DetailsOverviewRow detailRow) {
    ClassPresenterSelector ps = new ClassPresenterSelector();
    DetailsOverviewRowPresenter dorPresenter =
            new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter(mActivity));

    dorPresenter.setBackgroundColor(mActivity.getResources().getColor(R.color.fastlane_background));
    dorPresenter.setStyleLarge(true);
    dorPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        @Override
        public void onActionClicked(Action action) {
            if (action.getId() == ACTION_PLAY) {
                VideoUtils.playVideo(new WeakReference<Activity>(mActivity), mVideo);
            }
            else if (action.getId() == ACTION_VIEW_TRAILER) {
                Uri trailerUri = Uri.parse(mVideo.getMovie().getTrailer());
                mActivity.startActivity(new Intent(Intent.ACTION_VIEW, trailerUri));
            }
            else {
                Toast.makeText(mActivity, 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);

    addGroups(adapter);

    if (mRowBuilderTaskListener != null) {
        mRowBuilderTaskListener.taskCompleted(adapter);
    }
}
 
Example #27
Source File: VideoDetailsFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute( DetailsOverviewRow detailRow ) {
    if( detailRow == null )
        return;

    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 ) {
                Intent intent = new Intent( getActivity(), PlayerActivity.class );
                intent.putExtra( EXTRA_MOVIE, mSelectedMovie );
                intent.putExtra( EXTRA_SHOULD_AUTO_START, true );
                startActivity( intent );
            }
        }
    });

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


    ArrayObjectAdapter adapter = new ArrayObjectAdapter( ps );
    adapter.add( detailRow );
    loadRelatedMedia( adapter );
    setAdapter( adapter );
}
 
Example #28
Source File: TVDemoFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mCardPresenter = new CardPresenter();

    int i;
    for (i = 0; i < NUM_ROWS; i++) {
        if (i != 0) {
            Collections.shuffle(list);
        }
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter);
        for (int j = 0; j < NUM_COLS; j++) {
            listRowAdapter.add(list.get(j % 5));
        }
        HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES", null);

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.grid_view));
    gridRowAdapter.add(getResources().getString(R.string.send_feeback));
    gridRowAdapter.add(getResources().getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}
 
Example #29
Source File: TVDemoFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mCardPresenter = new CardPresenter();

    int i;
    for (i = 0; i < NUM_ROWS; i++) {
        if (i != 0) {
            Collections.shuffle(list);
        }
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter);
        for (int j = 0; j < NUM_COLS; j++) {
            listRowAdapter.add(list.get(j % 5));
        }
        HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES", null);

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.grid_view));
    gridRowAdapter.add(getResources().getString(R.string.send_feeback));
    gridRowAdapter.add(getResources().getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}
 
Example #30
Source File: SearchFragment.java    From iview-android-tv with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSearchResultProvider(this);
    setSpeechRecognitionCallback(null);
    adapter = new ArrayObjectAdapter(new ListRowPresenter());
    searcher = new SearchRunnable();
    setOnItemViewClickedListener(getItemClickedListener());
}