private void loadProjectData() { ViewUtils.setTextOrClear( binding.projectSubtitleTv, getString(R.string.project_details_made_by, project.getAuthorName())); if (LUtils.hasL()) { animateAlphaAfterTransition(binding.projectSubtitleTv); } binding.projectBackingProgress.setText( project.isFunded() ? R.string.funded : R.string.backing_in_progress); binding.projectItemBigProgressSb.setProgress((int) project.getPercentProgress()); ProjectsAdapter.setProjectDetailsInfo( binding.projectItemBigGatheredMoneyTv, binding.projectItemBigPledgedOfTv, binding.projectItemBigDaysLeft, binding.projectItemTimeLeftTypeTv, project); // TODO: animate elevation on scroll. ViewCompat.setElevation( binding.detailsContainer, ViewUtils.convertDpToPixel(4, ProjectDetailsActivity.this)); loadProjectPhoto(); }
private void loadProjectPhoto() { Bitmap bitmap = picassoCache.getPlaceholder(project.getBigPhotoUrl()); boolean bigPhotoMustBeFetched = bitmap == null; if (bigPhotoMustBeFetched) { bitmap = picassoCache.getPlaceholder(project.getPhotoUrl()); boolean placeholderAlreadyFetched = bitmap != null; if (placeholderAlreadyFetched) { binding.projectPhotoIv.setImageBitmap(bitmap); } } // Make sure that transition starts soon even if image is not ready. binding.projectPhotoIv.postDelayed( this::supportStartPostponedEnterTransition, MAX_TRANSITION_DELAY); Picasso.with(this) .load(project.getBigPhotoUrl()) .resize(imageWidth, imageHeight) .onlyScaleDown() .centerCrop() .transform(PaletteAndAplaTransformation.instance()) .into( binding.projectPhotoIv, new Callback() { @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) binding.projectPhotoIv.getDrawable()).getBitmap(); // Ew! Palette palette = PaletteAndAplaTransformation.getPalette(bitmap); binding.detailsContainer.setBackgroundColor( palette.getDarkVibrantColor(Color.BLACK)); supportStartPostponedEnterTransition(); } @Override public void onError() { supportStartPostponedEnterTransition(); } }); }
public static void launch(Activity context, Project project, View... sharedViews) { final Bundle options; if (LUtils.hasL()) { options = getSharedElementsBundle(context, sharedViews); } else { options = new Bundle(); } Intent intent = new Intent(context, ProjectDetailsActivity.class); Parcelable wrapped = Parcels.wrap(project); intent.putExtra(EXTRA_PROJECT, wrapped); // Preload big photo Picasso.with(context).load(project.getBigPhotoUrl()); ActivityCompat.startActivity(context, intent, options); }
@OnClick({R.id.project_author_name_label_tv, R.id.author_photo_iv, R.id.project_author_name_tv}) public void authorClicked() { showWebView(project.getAuthorUrl(), new Intent(this, WebViewFlickrActivity.class)); }
@OnClick(R.id.project_updates_ll) public void onUpdatesClicked() { showWebView(project.getUpdatesUrl()); }
@OnClick(R.id.project_comments_ll) public void onCommentsClicked() { showWebView(project.getCommentsUrl()); }
private void postProjectDetails() { ProjectIdAndSignature params = ProjectIdAndSignature.create(project.id, project.getDetailsQueryMap()); projectDetailsField.postValue(params); }