@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate DetailsFragment"); super.onCreate(savedInstanceState); mDetailsBackground = new DetailsFragmentBackgroundController(this); mSelectedMovie = (Movie) getActivity().getIntent().getSerializableExtra(DetailsActivity.MOVIE); if (mSelectedMovie != null) { mPresenterSelector = new ClassPresenterSelector(); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setupDetailsOverviewRow(); setupDetailsOverviewRowPresenter(); setupRelatedMovieListRow(); setAdapter(mAdapter); initializeBackground(mSelectedMovie); setOnItemViewClickedListener(new ItemViewClickedListener()); } else { Intent intent = new Intent(getActivity(), MainActivity.class); startActivity(intent); } }
private ClassPresenterSelector buildFilePresenter() { ClassPresenterSelector filePresenterSelector = new ClassPresenterSelector(); switch (mDisplayMode) { case GRID: filePresenterSelector.addClassPresenter(MetaFile2.class, new PosterImageCardPresenter(getActivity())); filePresenterSelector.addClassPresenter(Video.class, new PosterImageCardPresenter(getActivity())); break; case LIST: filePresenterSelector.addClassPresenter(MetaFile2.class, new MetaFileListPresenter()); filePresenterSelector.addClassPresenter(Video.class, new VideoListPresenter(true)); break; default: throw new IllegalArgumentException("Invalid Display Mode! "+mDisplayMode); } return filePresenterSelector; }
@Override protected void onPostExecute(Void avoid) { ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(DetailsOverviewRow.class, mOverviewRowPresenter); ps.addClassPresenter(PlotAndGenresRow.class, new PlotAndGenresRowPresenter(16,mColor)); // 16 lines max to fit on screen ps.addClassPresenter(FullTextRow.class, new FullTextRowPresenter(18,mColor)); // 18 lines max to fit on screen ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mOverviewRowPresenter.setBackgroundColor(mColor); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.clear(); // Add all the non-null rows for (Row row : new Row[] {mDetailsRow, mPlotAndGenresRow, mCastRow, mPostersRow, mBackdropsRow, mWebLinksRow}) { if (row!=null) { mRowsAdapter.add(row); } } setAdapter(mRowsAdapter); }
private ListRow createNewSeasonRow(String seasonNumber, int position) { String seasonTitle = seasonNumber.isEmpty() ? mSeries.getTitle() : getString(R.string.dvr_detail_series_season_title, seasonNumber); HeaderItem header = new HeaderItem(mSeasonRowCount++, seasonTitle); ClassPresenterSelector selector = new ClassPresenterSelector(); selector.addClassPresenter(RecordedProgram.class, mRecordedProgramPresenter); ListRow row = new ListRow(header, new SeasonRowAdapter(selector, new Comparator<RecordedProgram>() { @Override public int compare(RecordedProgram lhs, RecordedProgram rhs) { return BaseProgram.EPISODE_COMPARATOR.compare(lhs, rhs); } }, seasonNumber)); getRowsAdapter().add(position, row); return row; }
private ArrayObjectAdapter initializeRelatedVideosRow() { /* * To add a new row to the mPlayerAdapter and not lose the controls row that is provided by the * glue, we need to compose a new row with the controls row and our related videos row. * * We start by creating a new {@link ClassPresenterSelector}. Then add the controls row from * the media player glue, then add the related videos row. */ ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); presenterSelector.addClassPresenter( mPlayerGlue.getControlsRow().getClass(), mPlayerGlue.getPlaybackRowPresenter()); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(presenterSelector); rowsAdapter.add(mPlayerGlue.getControlsRow()); HeaderItem header = new HeaderItem(getString(R.string.related_movies)); ListRow row = new ListRow(header, mVideoCursorAdapter); rowsAdapter.add(row); setOnItemViewClickedListener(new ItemViewClickedListener()); return rowsAdapter; }
private ArrayObjectAdapter buildAboutAdapter() { DetailsOverviewRowPresenter rowPresenter = new DetailsOverviewRowPresenter(new AboutDetailsDescriptionPresenter()); rowPresenter.setBackgroundColor(getResources().getColor(R.color.about_background)); rowPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) {} }); ClassPresenterSelector selector = new ClassPresenterSelector(); selector.addClassPresenter(DetailsOverviewRow.class, rowPresenter); selector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(selector); rowsAdapter.add(generateAboutMeRow()); rowsAdapter.add(generateAboutGDGRow()); return rowsAdapter; }
@Override public void onStart() { super.onStart(); // Set up UI Video video = getActivity().getIntent().getParcelableExtra(VideoDetailsActivity.VIDEO); if (!updateSelectedVideo(video)) { return; } mGlue = new PlaybackControlHelper(getActivity(), this, mSelectedVideo); PlaybackControlsRowPresenter controlsRowPresenter = mGlue.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mGlue.getControlsRow(); mMediaControllerCallback = mGlue.createMediaControllerCallback(); mMediaController = getActivity().getMediaController(); mMediaController.registerCallback(mMediaControllerCallback); ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.add(controlsRow); addOtherRows(); updatePlaybackRow(); setAdapter(mRowsAdapter); startPlaying(); }
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), VideoDetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlaybackOverlayActivity.class); intent.putExtra(VideoDetailsActivity.VIDEO, mSelectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mScraper = new Scraper(getActivity()); mSearchExecutor = new SerialExecutor(); ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector(); rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector); setBadgeDrawable(getResources().getDrawable(R.mipmap.video2)); setSearchResultProvider(this); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof BaseTags) { saveTagsAndFinish((BaseTags) item); } } }); mSpeechRecognitionCallback = new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { // ACTION_RECOGNIZE_SPEECH try{ startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE); }catch (ActivityNotFoundException e){/*non google device*/} } }; setSpeechRecognitionCallback(mSpeechRecognitionCallback); }
private void updateRow(){ if ((mSearchResults==null||mSearchResults.isEmpty())&&mNfoTags==null) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new EmptyViewPresenter()); listRowAdapter.add(new EmptyView(getEmptyText())); mRowsAdapter.clear(); mRowsAdapter.add(new ShadowLessListRow(new HeaderItem(getString(R.string.search_results)), listRowAdapter)); } else { // Prepare the result list widget ClassPresenterSelector classPresenter = new ClassPresenterSelector(); classPresenter.addClassPresenter(SearchResult.class, new ScraperSearchResultPresenter()); // for initial search result classPresenter.addClassPresenter(BaseTags.class, new ScraperBaseTagsPresenter()); // for detailed result info mResultsAdapter = new ArrayObjectAdapter(classPresenter); if(mNfoTags!=null) { mResultsAdapter.add(0, mNfoTags); mOffset=1; } if(mSearchResults!=null) mResultsAdapter.addAll(mOffset, mSearchResults); ListRow listRow = new ListRow(new HeaderItem(getResultsHeaderText()), mResultsAdapter); mRowsAdapter.clear(); mRowsAdapter.add(listRow); if(mSearchResults!=null) { // Launch the details task to get posters, etc. SearchResult[] array = mSearchResults.toArray(new SearchResult[mSearchResults.size()]); mDetailsTask = new ScraperDetailsFetchTask().executeOnExecutor(mSearchExecutor,array); } } }
private void loadRows() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); ClassPresenterSelector classPresenter = new ClassPresenterSelector(); classPresenter.addClassPresenter(NetworkShortcut.class, new NetworkShortcutPresenter()); classPresenter.addClassPresenter(Box.class, new RescanBoxItemPresenter()); // for the rescan item mIndexedFoldersAdapter = new ArrayObjectAdapter(classPresenter); mIndexedFoldersListRow = new ListRow( new HeaderItem(getString(R.string.indexed_folders)), mIndexedFoldersAdapter); mRowsAdapter.add(mIndexedFoldersListRow); mSmbDiscoveryAdapter = new ArrayObjectAdapter(new SmbSharePresenter()); mRowsAdapter.add(new ListRow( new HeaderItem(getString(R.string.network_shared_folders)), mSmbDiscoveryAdapter)); if(UpnpAvailability.isUpnpAvaialbe()) { mUpnpDiscoveryAdapter = new ArrayObjectAdapter(new SmbSharePresenter()); mRowsAdapter.add(new ListRow( new HeaderItem(getString(R.string.network_media_servers)), mUpnpDiscoveryAdapter)); } mFtpShortcutsAdapter = new ArrayObjectAdapter(new NetworkShortcutPresenter()); mRowsAdapter.add(new ListRow( new HeaderItem(getString(R.string.ftp_shortcuts)), mFtpShortcutsAdapter)); setOnItemViewClickedListener(mClickListener); setAdapter(mRowsAdapter); }
@Override public void onStart() { super.onStart(); // Set up UI Video video = getActivity().getIntent().getParcelableExtra(VideoDetailsActivity.VIDEO); if (!updateSelectedVideo(video)) { return; } mGlue = new PlaybackControlHelper(getActivity(), this, mSelectedVideo); PlaybackControlsRowPresenter controlsRowPresenter = mGlue.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mGlue.getControlsRow(); mMediaControllerCallback = mGlue.createMediaControllerCallback(); // mMediaController = getActivity().getMediaController(); mMediaController.registerCallback(mMediaControllerCallback); // ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.add(controlsRow); addOtherRows(); updatePlaybackRow(); setAdapter(mRowsAdapter); startPlaying(); }
private void setupAdapter() { FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter( new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.background_dark)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); detailsPresenter.setOnActionClickedListener( new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH) { Intent intent = PlaybackActivity.createIntent(getContext(), mMovie.getId()); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT) .show(); } } }); ClassPresenterSelector mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
private void setUpRows() { PlaybackControlsRowPresenter controlsRowPresenter = mPlaybackControlHelper.createControlsRowAndPresenter(); ClassPresenterSelector selector = new ClassPresenterSelector(); selector.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); selector.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(selector); mRowsAdapter.add(mPlaybackControlHelper.getControlsRow()); mRelatedRecordingsRow = getRelatedRecordingsRow(); setAdapter(mRowsAdapter); }
@Override protected PresenterSelector onCreatePresenterSelector( DetailsOverviewRowPresenter rowPresenter) { ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); presenterSelector.addClassPresenter(DetailsOverviewRow.class, rowPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); return presenterSelector; }
@Override public void onCreate(Bundle savedInstanceState) { if (DEBUG) Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); Context context = getContext(); ApplicationSingletons singletons = TvApplication.getSingletons(context); mDvrDataManager = singletons.getDvrDataManager(); mDvrScheudleManager = singletons.getDvrScheduleManager(); mPresenterSelector = new ClassPresenterSelector() .addClassPresenter(ScheduledRecording.class, new ScheduledRecordingPresenter(context)) .addClassPresenter(RecordedProgram.class, new RecordedProgramPresenter(context)) .addClassPresenter(SeriesRecording.class, new SeriesRecordingPresenter(context)) .addClassPresenter(FullScheduleCardHolder.class, new FullSchedulesCardPresenter()); mGenreLabels = new ArrayList<>(Arrays.asList(GenreItems.getLabels(context))); mGenreLabels.add(getString(R.string.dvr_main_others)); setupUiElements(); setupAdapters(); mDvrScheudleManager.addOnConflictStateChangeListener(mOnConflictStateChangeListener); prepareEntranceTransition(); if (mDvrDataManager.isInitialized()) { startEntranceTransition(); } else { if (!mDvrDataManager.isDvrScheduleLoadFinished()) { mDvrDataManager.addDvrScheduleLoadFinishedListener(this); } if (!mDvrDataManager.isRecordedProgramLoadFinished()) { mDvrDataManager.addRecordedProgramLoadFinishedListener(this); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); presenterSelector.addClassPresenter(SchedulesHeaderRow.class, onCreateHeaderRowPresenter()); presenterSelector.addClassPresenter(ScheduleRow.class, onCreateRowPresenter()); mRowsAdapter = onCreateRowsAdapter(presenterSelector); setAdapter(mRowsAdapter); mRowsAdapter.start(); ApplicationSingletons singletons = TvApplication.getSingletons(getContext()); singletons.getDvrDataManager().addScheduledRecordingListener(this); singletons.getDvrScheduleManager().addOnConflictStateChangeListener(this); mEmptyInfoScreenView = (TextView) getActivity().findViewById(R.id.empty_info_screen); }
public SeriesScheduleRowAdapter(Context context, ClassPresenterSelector classPresenterSelector, SeriesRecording seriesRecording) { super(context, classPresenterSelector); mSeriesRecording = seriesRecording; TvInputInfo input = Utils.getTvInputInfoForInputId(context, mSeriesRecording.getInputId()); if (SoftPreconditions.checkNotNull(input) != null) { mInputId = input.getId(); } else { mInputId = null; } ApplicationSingletons singletons = TvApplication.getSingletons(context); mDvrManager = singletons.getDvrManager(); mDataManager = singletons.getDvrDataManager(); setHasStableIds(true); }
/** * Creates and returns presenter selector will be used by rows adaptor. */ protected PresenterSelector onCreatePresenterSelector( DetailsOverviewRowPresenter rowPresenter) { ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); presenterSelector.addClassPresenter(DetailsOverviewRow.class, rowPresenter); return presenterSelector; }
private void setupAdapter() { mPresenterSelector = new ClassPresenterSelector(); createPresenters(mPresenterSelector); mAdapter = createAdapter(mPresenterSelector); setAdapter(mAdapter); }
private void initialisePlaybackControlPresenter() { ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); mPlaybackControlsRowPresenter = new PlaybackControlsRowPresenter(new DescriptionPresenter()); mPlaybackControlsRowPresenter.setSecondaryActionsHidden(false); presenterSelector.addClassPresenter(PlaybackControlsRow.class, mPlaybackControlsRowPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(presenterSelector); setAdapter(mRowsAdapter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LogHelper.i(TAG, "onCreate"); mBackgroundManager = BackgroundManager.getInstance(getActivity()); mBackgroundManager.attach(getActivity().getWindow()); mHandler = new Handler(); mListRowAdapter = new ArrayObjectAdapter(new CardPresenter()); mPresenterSelector = new ClassPresenterSelector(); mRowsAdapter = new ArrayObjectAdapter(mPresenterSelector); setBackgroundType(BACKGROUND_TYPE); setFadingEnabled(false); }
private void initUi() { FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new VideoDetailsPresenter()); ClassPresenterSelector selector = new ClassPresenterSelector(); selector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); selector.addClassPresenter(ListRow.class, new ListRowPresenter()); rows = new ArrayObjectAdapter(selector); setAdapter(rows); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LogHelper.i(TAG, "onCreate"); mBackgroundManager = BackgroundManager.getInstance(getActivity()); mBackgroundManager.attach(getActivity().getWindow()); mHandler = new Handler(); mListRowAdapter = new ArrayObjectAdapter(new CardPresenter(getActivity())); mPresenterSelector = new ClassPresenterSelector(); mRowsAdapter = new ArrayObjectAdapter(mPresenterSelector); setBackgroundType(BACKGROUND_TYPE); setFadingEnabled(false); }
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); // set detail background and style mDorPresenter.setBackgroundColor(getResources().getColor(R.color.detail_background)); mDorPresenter.setStyleLarge(true); mDorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, mDorPresenter); 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]); adapter.add(new ListRow(header, listRowAdapter)); setAdapter(adapter); }
private void setupFragment() { mDetailsPresenter = new DetailsOverviewRowPresenter(getDetailsPresenter()); mDetailsPresenter.setStyleLarge(false); ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(DetailsOverviewRow.class, mDetailsPresenter); ps.addClassPresenter(TracksHeaderRow.class, new TracksHeaderRowPresenter()); OnItemViewClickedListener onTrackRowItemClicked = new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof TrackSimple) { playFromTrack(((TrackSimple) item)); } } }; ps.addClassPresenter(TrackRow.class, getTrackRowPresenter(onTrackRowItemClicked)); mRowsAdapter = new ArrayObjectAdapter(ps); setAdapter(mRowsAdapter); setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { TracksDetailsFragment.this.onActionClicked(action); } }); }
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new TVContactRequestDetailPresenter(), new TVContactRequestDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.color_primary_dark)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. FullWidthDetailsOverviewSharedElementHelper mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), TVContactRequestActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); detailsPresenter.setOnActionClickedListener(action -> { if (action.getId() == ACTION_ACCEPT) { presenter.acceptTrustRequest(mSelectedContactRequest); } else if (action.getId() == ACTION_REFUSE) { presenter.refuseTrustRequest(mSelectedContactRequest); } else if (action.getId() == ACTION_BLOCK) { presenter.blockTrustRequest(mSelectedContactRequest); } }); ClassPresenterSelector mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
@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(); }
@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 ); }
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), VideoDetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); 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(VideoDetailsActivity.VIDEO, mSelectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
@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); } }
private void setupAdapter() { mPresenterSelector = new ClassPresenterSelector(); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
@Override public synchronized void onStart() { super.onStart(); Log.d(TAG, "OnStart"); PlaybackControlsRowPresenter playbackControlsRowPresenter = mHelper.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mHelper.getControlsRow(); mMediaControllerCallback = mHelper.createMediaControllerCallback(); requestAudioFocus(); mMediaControler = getActivity().getMediaController(); if (mMediaControler != null) { mMediaControler.registerCallback(mMediaControllerCallback); } else { Log.d(TAG, "MediaController is null"); getActivity().finish(); } ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(PlaybackControlsRow.class, playbackControlsRowPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.add(controlsRow); if (eventType == DetailsActivity.TYPE_RECORDING) { if (mSelectedEvent.getMetadata() != null && mSelectedEvent.getMetadata().getRelated() != null) { mRowsAdapter.add(getRelatedItems()); setOnItemViewClickedListener(new ItemViewClickedListener(this)); } } else if (eventType == DetailsActivity.TYPE_STREAM) { // TODO add other streams as related events } setAdapter(mRowsAdapter); if (mCallback != null && eventType == DetailsActivity.TYPE_STREAM) { mCallback.setVideoSource(mSelectedStream.getUrl()); } else if (mCallback != null && eventType == DetailsActivity.TYPE_RECORDING) { mCallback.setVideoSource(mSelectedRecording.getRecordingUrl()); } else { Log.d(TAG, "Callback not set or not event/stream"); } requestAudioFocus(); if (mPlaybackProgress != null) { showContinueOrRestartDialog(); } else { play(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String displayNumber = getActivity().getIntent().getStringExtra( RichFeedUtil.EXTRA_DISPLAY_NUMBER); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter( new DetailsDescriptionPresenter()); dorPresenter.setSharedElementEnterTransition(getActivity(), "RichAppLinkDetailsFragment"); DetailsOverviewRow row = new DetailsOverviewRow(displayNumber); Resources res = getResources(); Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.nejnettv); int length = Math.min(bitmap.getWidth(), bitmap.getHeight()); Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, (bitmap.getWidth() - length) / 2, (bitmap.getHeight() - length) / 2, length, length); row.setImageBitmap(getActivity(), croppedBitmap); Action action1 = new Action(0, res.getString(R.string.details_fragment_action_1)); Action action2 = new Action(1, res.getString(R.string.details_fragment_action_2)); row.addAction(action1); row.addAction(action2); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); dorPresenter.setBackgroundColor(res.getColor(R.color.detail_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { getActivity().finish(); } }); presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); adapter.add(row); setAdapter(adapter); }
private void initUIs(Bitmap bitmap) { DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); dorPresenter.setSharedElementEnterTransition(getActivity(), "SetUpFragment"); mAddChannelAction = new Action(ACTION_ADD_CHANNELS, getResources().getString(R.string.rich_setup_add_channel)); Action cancelAction = new Action(ACTION_CANCEL, getResources().getString(R.string.rich_setup_cancel)); mInProgressAction = new Action(ACTION_IN_PROGRESS, getResources().getString(R.string.rich_setup_in_progress)); DetailsOverviewRow row = new DetailsOverviewRow(mTvListing); if (bitmap != null) { int length = Math.min(bitmap.getWidth(), bitmap.getHeight()); Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, (bitmap.getWidth() - length) / 2, (bitmap.getHeight() - length) / 2, length, length); row.setImageBitmap(getActivity(), croppedBitmap); } row.addAction(mAddChannelAction); row.addAction(cancelAction); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); // 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_ADD_CHANNELS) { setupChannels(mInputId); } else if (action.getId() == ACTION_CANCEL) { getActivity().finish(); } } }); presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(presenterSelector); mAdapter.add(row); setAdapter(mAdapter); BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); if (bitmap != null) { backgroundManager.setBitmap(bitmap); } else { backgroundManager.setDrawable( getActivity().getDrawable(R.drawable.default_background)); } }
private void loadRows() { Log.d(TAG,"loadRows()"); // Two different row presenters, one standard for regular cards, one special for the icon items ListRowPresenter listRowPresenter = new ListRowPresenter(); IconItemRowPresenter iconItemRowPresenter = new IconItemRowPresenter(); // Only way I found to use two different presenter is using a ClassPresenterSelector, hence i needed // to create a dummy IconListRow that does nothing more than a regular ListRow ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector(); rowsPresenterSelector.addClassPresenter(ListRow.class, listRowPresenter); rowsPresenterSelector.addClassPresenter(IconListRow.class, iconItemRowPresenter); // Basic header presenter for both row presenters listRowPresenter.setHeaderPresenter(new RowHeaderPresenter()); iconItemRowPresenter.setHeaderPresenter(new RowHeaderPresenter()); mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector); mLastAddedAdapter = new CursorObjectAdapter(new PosterImageCardPresenter(getActivity())); mLastAddedAdapter.setMapper(new CompatibleCursorMapperConverter(new VideoCursorMapper())); mLastAddedRow = new ListRow(ROW_ID_LAST_ADDED, new HeaderItem(getString(R.string.recently_added)), mLastAddedAdapter); mRowsAdapter.add(mLastAddedRow); mLastPlayedAdapter = new CursorObjectAdapter(new PosterImageCardPresenter(getActivity())); mLastPlayedAdapter.setMapper(new CompatibleCursorMapperConverter(new VideoCursorMapper())); mLastPlayedRow = new ListRow(ROW_ID_LAST_PLAYED, new HeaderItem(getString(R.string.recently_played)), mLastPlayedAdapter); mRowsAdapter.add(mLastPlayedRow); ArrayObjectAdapter movieRowAdapter = new ArrayObjectAdapter(new BoxItemPresenter()); movieRowAdapter.add(buildAllMoviesBox()); movieRowAdapter.add(new Box(Box.ID.MOVIES_BY_GENRE, getString(R.string.movies_by_genre), R.drawable.genres_banner)); movieRowAdapter.add(new Box(Box.ID.MOVIES_BY_YEAR, getString(R.string.movies_by_year), R.drawable.years_banner)); mRowsAdapter.add(new ListRow(ROW_ID_MOVIES, new HeaderItem(getString(R.string.movies)), movieRowAdapter)); mTvshowsAdapter = new CursorObjectAdapter(new PosterImageCardPresenter(getActivity())); mTvshowsAdapter.setMapper(new CompatibleCursorMapperConverter(new TvshowCursorMapper())); mTvshowsRow = new ListRow(ROW_ID_TVSHOWS, new HeaderItem(getString(R.string.all_tv_shows)), mTvshowsAdapter); mRowsAdapter.add(mTvshowsRow); mFileBrowsingRowAdapter = new ArrayObjectAdapter(new BoxItemPresenter()); mFileBrowsingRowAdapter.add(new Box(Box.ID.NETWORK, getString(R.string.network_storage), R.drawable.filetype_new_server)); mFileBrowsingRowAdapter.add(new Box(Box.ID.FOLDERS, getString(R.string.internal_storage), R.drawable.filetype_new_folder)); mFileBrowsingRowAdapter.add(new Box(Box.ID.VIDEOS_BY_LISTS, getString(R.string.video_lists), R.drawable.filetype_new_playlist)); mNonScrapedVideosItem = new Box(Box.ID.NON_SCRAPED_VIDEOS, getString(R.string.non_scraped_videos), R.drawable.filetype_new_unscraped_video); // Add USB and SDcard items at init ?depending of their availability updateUsbAndSdcardVisibility(); mRowsAdapter.add(new ListRow(ROW_ID_FILES, new HeaderItem(getString(R.string.leanback_browsing)), mFileBrowsingRowAdapter)); mPreferencesRowAdapter = new ArrayObjectAdapter(new IconItemPresenter()); mPreferencesRowAdapter.add(new Icon(Icon.ID.PREFERENCES, getString(R.string.preferences), R.drawable.lollipop_settings)); mPreferencesRowAdapter.add(new Icon(Icon.ID.PRIVATE_MODE, getString(R.string.private_mode_is_on), getString(R.string.private_mode_is_off), R.drawable.private_mode, R.drawable.private_mode_off, PrivateMode.isActive())); mPreferencesRowAdapter.add(new Icon(Icon.ID.LEGACY_UI, getString(R.string.leanback_legacy_ui), R.drawable.legacy_ui_icon)); mPreferencesRowAdapter.add(new Icon(Icon.ID.HELP_FAQ, getString(R.string.help_faq), R.drawable.lollipop_help)); // Must use an IconListRow to have the dedicated presenter used (see ClassPresenterSelector above) mRowsAdapter.add(new IconListRow(ROW_ID_PREFERENCES, new HeaderItem(getString(R.string.preferences)), mPreferencesRowAdapter)); setAdapter(mRowsAdapter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector(); rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector); mSpeechRecognitionCallback = new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { // ACTION_RECOGNIZE_SPEECH try { startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE); }catch (android.content.ActivityNotFoundException e){ //no google device } } }; setSpeechRecognitionCallback(mSpeechRecognitionCallback); setSearchResultProvider(this); setOnItemViewClickedListener(new VideoViewClickedListener(getActivity())); setBadgeDrawable(getResources().getDrawable(R.mipmap.video2)); mDelayedLoad = new SearchRunnable(); int searchMode = getArguments() != null ? getArguments().getInt(VideoSearchActivity.EXTRA_SEARCH_MODE, VideoSearchActivity.SEARCH_MODE_ALL) : VideoSearchActivity.SEARCH_MODE_ALL; if (searchMode == VideoSearchActivity.SEARCH_MODE_MOVIE) { setTitle(getString(R.string.movies)); mSearchLoader = new SearchMovieLoader(getActivity()); } else if (searchMode == VideoSearchActivity.SEARCH_MODE_NON_SCRAPED) { setTitle(getString(R.string.videos)); mSearchLoader = new SearchNonScrapedVideoLoader(getActivity()); } else { setTitle(getString(R.string.videos)); mSearchLoader = new SearchVideoLoader(getActivity()); } }