private DetailsOverviewRow setupDetailsOverviewRow(Object event) { final DetailsOverviewRow row = new DetailsOverviewRow(event); String thumbUrl; if (event instanceof Event) { thumbUrl = ((Event) event).getThumbUrl(); } else { thumbUrl = ((Room) event).getThumb(); } Glide.with(getActivity()) .load(thumbUrl) .asBitmap() .into(new SimpleTarget<Bitmap>(DETAIL_THUMB_WIDTH, DETAIL_THUMB_HEIGHT) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { row.setImageBitmap(getActivity(), resource); } @Override public void onLoadFailed(Exception e, Drawable errorDrawable) { // super.onLoadFailed(e, errorDrawable); row.setImageDrawable(getResources().getDrawable(DEFAULT_DRAWABLE)); } }); return row; }
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(), DetailsActivity.SHARED_ELEMENT_NAME); 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(DetailsActivity.MOVIE, mSelectedMovie); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BackgroundManager bgMngr = BackgroundManager.getInstance(getActivity()); bgMngr.attach(getActivity().getWindow()); bgMngr.setColor(getResources().getColor(R.color.leanback_background)); mShortcut = (Shortcut)getActivity().getIntent().getSerializableExtra(EXTRA_SHORTCUT); DetailsOverviewRow detailRow = new DetailsOverviewRow(mShortcut); detailRow.setImageScaleUpAllowed(false); addActions(detailRow); mDetailsRowPresenter = new FullWidthDetailsOverviewRowPresenter(new ShortcutDetailsPresenter()); mDetailsRowPresenter.setBackgroundColor(getResources().getColor(R.color.lightblue900)); mDetailsRowPresenter.setOnActionClickedListener(this); ArrayObjectAdapter adapter = new ArrayObjectAdapter(mDetailsRowPresenter); adapter.add(detailRow); setAdapter(adapter); }
@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 DetailsOverviewRow createDetailsOverviewRow() { final DetailsOverviewRow detailsRow = new DetailsOverviewRow(mItem); Picasso.with(getActivity()).load(mHeroImage).into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { detailsRow.setImageBitmap(getActivity(), bitmap); mAdapter.notifyArrayItemRangeChanged(0, mAdapter.size()); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onBitmapFailed(Drawable errorDrawable) { if(VersionUtils.isLollipop()) getActivity().startPostponedEnterTransition(); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } }); return detailsRow; }
@Override public void onSuccess(MediaProvider.Filters filters, ArrayList<Media> items, boolean changed) { if (!isAdded()) return; if (null == items || items.size() == 0) return; Media itemDetail = items.get(0); mItem = itemDetail; ThreadUtils.runOnUiThread(new Runnable() { @Override public void run() { final DetailsOverviewRow detailRow = createDetailsOverviewRow(); mAdapter.replace(0, detailRow); onDetailLoaded(); } }); }
@Provides @PerFragment public FullWidthDetailsOverviewSharedElementHelper provideHelper(Activity activity, PresenterSelector mPs, DetailsOverviewRow row, OnActionClickedListener listener) { FullWidthDetailsOverviewSharedElementHelper mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(activity, LiveDataDetailActivity.SHARED_ELEMENT_NAME); ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row)) .setListener(mHelper); ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row)) .setParticipatingEntranceTransition(false); ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row)) .setOnActionClickedListener(listener); return mHelper; }
@Override protected DetailsOverviewRow doInBackground(Movie... movies) { mSelectedMovie = movies[0]; DetailsOverviewRow row = new DetailsOverviewRow(mSelectedMovie); try { Bitmap poster = Picasso.with(getActivity()) .load(mSelectedMovie.getCardImageUrl()) .resize(Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_WIDTH), Utils.convertDpToPixel(getActivity().getApplicationContext(), DETAIL_THUMB_HEIGHT)) .centerCrop() .get(); row.setImageBitmap(getActivity(), poster); } catch (IOException e) { } row.addAction(new Action(ACTION_WATCH_TRAILER, getResources().getString( R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2))); row.addAction(new Action(ACTION_RENT, getResources().getString(R.string.rent_1), getResources().getString(R.string.rent_2))); row.addAction(new Action(ACTION_BUY, getResources().getString(R.string.buy_1), getResources().getString(R.string.buy_2))); return row; }
@Override protected DetailsOverviewRow doInBackground(Video... videos) { DetailsOverviewRow row = new DetailsOverviewRow(videos[0]); try { Bitmap poster = Picasso.with(getActivity()) .load(videos[0].getThumbUrl()) .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()), dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext())) .centerCrop() .get(); row.setImageBitmap(getActivity(), poster); } catch (IOException e) { Log.e("VideoDetailsFragment", "Cannot load thumbnail for " + videos[0].getId(), e); } SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter(); adapter.set(ACTION_PLAY, new Action(ACTION_PLAY, getResources().getString( R.string.action_play))); adapter.set(ACTION_WATCH_LATER, new Action(ACTION_WATCH_LATER, getResources().getString(R.string.action_watch_later))); row.setActionsAdapter(adapter); return row; }
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 protected DetailsOverviewRow doInBackground(Movie... movies) { selectedMovie = movies[0]; DetailsOverviewRow row = new DetailsOverviewRow(selectedMovie); try { Bitmap poster = Picasso.with(getActivity()) .load(selectedMovie.getCardImageUrl()) .resize(dpToPx(DETAIL_THUMB_WIDTH, getActivity().getApplicationContext()), dpToPx(DETAIL_THUMB_HEIGHT, getActivity().getApplicationContext())) .centerCrop() .get(); row.setImageBitmap(getActivity(), poster); } catch (IOException e) { } row.addAction(new Action(ACTION_WATCH_TRAILER, getResources().getString( R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2))); row.addAction(new Action(ACTION_RENT, getResources().getString(R.string.rent_1), getResources().getString(R.string.rent_2))); row.addAction(new Action(ACTION_BUY, getResources().getString(R.string.buy_1), getResources().getString(R.string.buy_2))); return row; }
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); }
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()); } }); row.addAction(new Action(ACTION_WATCH_TRAILER, getResources().getString( R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2))); row.addAction(new Action(ACTION_RENT, getResources().getString(R.string.rent_1), getResources().getString(R.string.rent_2))); row.addAction(new Action(ACTION_BUY, getResources().getString(R.string.buy_1), getResources().getString(R.string.buy_2))); mAdapter.add(row); }
private void setupDetailsOverviewRowPresenter() { // Set detail background. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); // Hook up transition element. FullWidthDetailsOverviewSharedElementHelper sharedElementHelper = new FullWidthDetailsOverviewSharedElementHelper(); sharedElementHelper.setSharedElementEnterTransition( getActivity(), DetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(sharedElementHelper); detailsPresenter.setParticipatingEntranceTransition(true); 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(DetailsActivity.MOVIE, mSelectedMovie); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); }
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { DetailsOverviewRow row = (DetailsOverviewRow) item; ImageView imageView = ((ImageView) viewHolder.view); imageView.setImageDrawable(row.getImageDrawable()); if (isBoundToImage((ViewHolder) viewHolder, row)) { EventDetailsOverviewLogoPresenter.ViewHolder vh = (EventDetailsOverviewLogoPresenter.ViewHolder) viewHolder; vh.getParentPresenter().notifyOnBindLogo(vh.getParentViewHolder()); } }
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 onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { DetailsOverviewRow row = (DetailsOverviewRow) item; ImageView imageView = ((ImageView) viewHolder.view); imageView.setImageDrawable(row.getImageDrawable()); if (isBoundToImage((ViewHolder) viewHolder, row)) { MovieDetailsOverviewLogoPresenter.ViewHolder vh = (MovieDetailsOverviewLogoPresenter.ViewHolder) viewHolder; vh.getParentPresenter().notifyOnBindLogo(vh.getParentViewHolder()); } }
private void setupDetailsOverviewRow() { final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo); Glide.with(this) .load(mSelectedVideo.cardImageUrl) .asBitmap() .dontAnimate() .error(R.drawable.default_background) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(final Bitmap resource, GlideAnimation glideAnimation) { row.setImageBitmap(getActivity(), resource); startEntranceTransition(); } }); 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); }
@Override public void onReceive(Context context, final Intent intent) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (mFinished) { return; } String syncStatusChangedInputId = intent.getStringExtra( SyncJobService.BUNDLE_KEY_INPUT_ID); if (syncStatusChangedInputId.equals(mInputId)) { String syncStatus = intent.getStringExtra(SyncJobService.SYNC_STATUS); if (syncStatus.equals(SyncJobService.SYNC_STARTED)) { DetailsOverviewRow detailRow = (DetailsOverviewRow) mAdapter.get(0); detailRow.removeAction(mAddChannelAction); if (detailRow.getActionForKeyCode(ACTION_IN_PROGRESS) == null) { detailRow.addAction(0, mInProgressAction); } mAdapter.notifyArrayItemRangeChanged(0, 1); } else if (syncStatus.equals(SyncJobService.SYNC_FINISHED)) { SyncUtils.setUpPeriodicSync(getActivity(), mInputId); getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); mFinished = true; } } } }); }
@Override public void addActions(DetailsOverviewRow detailRow){ detailRow.addAction(new Action(ACTION_OPEN, getResources().getString(R.string.open_indexed_folder))); if(ShortcutDbAdapter.VIDEO.isShortcut(getActivity(), mShortcut.getUri().toString())<0) { detailRow.addAction(new Action(ACTION_ADD_INDEX, getResources().getString(R.string.add_to_indexed_folders))); } else detailRow.addAction(new Action(ACTION_REINDEX, getResources().getString(R.string.network_reindex))); detailRow.addAction(new Action(ACTION_REMOVE, getResources().getString(R.string.remove_from_shortcuts))); detailRow.setImageDrawable(getResources().getDrawable(R.drawable.filetype_new_server)); }