use of com.squareup.picasso.Callback in project wh-app-android by WhiteHouse.
the class GalleryPhotoFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mPhotoDescription.setText(Html.fromHtml(prepDescription(mFeedItem.description())));
Picasso.with(view.getContext()).load(mFeedItem.getBestThumbnailUrl(1500)).into(mPhotoView, new Callback() {
@Override
public void onSuccess() {
mPhotoViewAttacher = new PhotoViewAttacher(mPhotoView) {
@Override
public boolean onTouch(View v, MotionEvent ev) {
switch(ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mTouching = true;
decideDescriptionVisibility(getScale());
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
mTouching = false;
decideDescriptionVisibility(getScale());
break;
}
return super.onTouch(v, ev);
}
};
mPhotoViewAttacher.setOnMatrixChangeListener(rectF -> {
decideDescriptionVisibility(mPhotoViewAttacher.getScale());
if (mPhotoViewAttacher.getScale() > 1.1f) {
mPhotoViewAttacher.setAllowParentInterceptOnEdge(false);
} else {
mPhotoViewAttacher.setAllowParentInterceptOnEdge(true);
}
});
}
@Override
public void onError() {
}
});
}
use of com.squareup.picasso.Callback in project kickmaterial by byoutline.
the class ProjectDetailsActivity method 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() {
// Ew!
Bitmap bitmap = ((BitmapDrawable) binding.projectPhotoIv.getDrawable()).getBitmap();
Palette palette = PaletteAndAplaTransformation.getPalette(bitmap);
binding.detailsContainer.setBackgroundColor(palette.getDarkVibrantColor(Color.BLACK));
supportStartPostponedEnterTransition();
}
@Override
public void onError() {
supportStartPostponedEnterTransition();
}
});
}
use of com.squareup.picasso.Callback in project cw-omnibus by commonsguy.
the class AbstractDragDropDemoActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
originalColors.put(R.id.outer_container, getResources().getColor(R.color.outer_normal));
originalColors.put(R.id.inner_container, getResources().getColor(R.color.inner_normal));
originalColors.put(R.id.thumbnail_large, getResources().getColor(R.color.image_normal));
dropTargetReadyColor = getResources().getColor(R.color.drop_target_ready);
ViewGroup dropFrame = (ViewGroup) findViewById(R.id.drop_frame);
getLayoutInflater().inflate(getDropFrameContentId(), dropFrame, true);
iv = (ImageView) findViewById(R.id.asset);
Picasso.with(this).load("file:///android_asset/FreedomTower-Morning.jpg").fit().centerCrop().into(iv, new Callback() {
@Override
public void onSuccess() {
iv.setOnLongClickListener(AbstractDragDropDemoActivity.this);
}
@Override
public void onError() {
// TODO
}
});
if (icicle != null) {
imageUri = icicle.getParcelable(STATE_IMAGE_URI);
if (imageUri != null) {
showThumbnail();
}
}
}
use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class EpisodeDetailsFragment method loadImage.
private void loadImage(String imagePath, boolean hideDetails) {
// immediately hide container if there is no image
if (TextUtils.isEmpty(imagePath)) {
mImageContainer.setVisibility(View.GONE);
return;
}
if (hideDetails) {
// show image placeholder
mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mEpisodeImage.setImageResource(R.drawable.ic_image_missing);
} else {
// try loading image
mImageContainer.setVisibility(View.VISIBLE);
ServiceUtils.loadWithPicasso(getActivity(), TvdbImageTools.fullSizeUrl(imagePath)).error(R.drawable.ic_image_missing).into(mEpisodeImage, new Callback() {
@Override
public void onSuccess() {
mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
@Override
public void onError() {
mEpisodeImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class FullscreenImageActivity method loadLargeImage.
private void loadLargeImage(boolean hasPreviewImage) {
String imagePath = getIntent().getStringExtra(EXTRA_IMAGE);
if (TextUtils.isEmpty(imagePath)) {
// set to null so picasso shows error drawable
imagePath = null;
}
RequestCreator requestCreator = ServiceUtils.loadWithPicasso(this, imagePath);
if (hasPreviewImage) {
// keep showing preview image if loading full image fails
requestCreator.noPlaceholder().into(photoView);
} else {
// no preview image? show error image instead if loading full image fails
requestCreator.error(R.drawable.ic_image_missing).into(photoView, new Callback() {
@Override
public void onSuccess() {
photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
@Override
public void onError() {
photoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
Aggregations