use of com.squareup.picasso.Callback in project glimmr by brk3.
the class PhotoViewerFragment method displayImage.
private void displayImage() {
if (BuildConfig.DEBUG)
Log.d(TAG, "displayImage()");
/* Fetch the main image */
if (mBasePhoto != null) {
String urlToFetch = getLargestUrlAvailable(mBasePhoto);
Picasso.with(mActivity).load(urlToFetch).into(mImageView, new Callback() {
@Override
public void onSuccess() {
mAttacher.update();
mProgress.setVisibility(View.INVISIBLE);
}
@Override
public void onError() {
Log.e(TAG, "displayImage -> Picasso -> onError");
}
});
/* Set the photo title and author text. If sw600dp then the parent
* activity will handle adding them to the actionbar instead */
if (!mActivity.getResources().getBoolean(R.bool.sw600dp)) {
String photoTitle = mBasePhoto.getTitle();
if (photoTitle == null || photoTitle.length() == 0) {
photoTitle = mActivity.getString(R.string.untitled);
}
String authorText = String.format("%s %s", mActivity.getString(R.string.by), mBasePhoto.getOwner().getUsername());
mTextViewTitle.setText(photoTitle);
mTextViewAuthor.setText(authorText);
}
} else {
Log.e(getLogTag(), "displayImage: mBasePhoto is null");
}
}
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 InstaMaterial by frogermcs.
the class PublishActivity method loadThumbnailPhoto.
private void loadThumbnailPhoto() {
ivPhoto.setScaleX(0);
ivPhoto.setScaleY(0);
Picasso.with(this).load(photoUri).centerCrop().resize(photoSize, photoSize).into(ivPhoto, new Callback() {
@Override
public void onSuccess() {
ivPhoto.animate().scaleX(1.f).scaleY(1.f).setInterpolator(new OvershootInterpolator()).setDuration(400).setStartDelay(200).start();
}
@Override
public void onError() {
}
});
}
use of com.squareup.picasso.Callback in project Reader by TheKeeperOfPie.
the class ActivityMain method loadHeaderFromFile.
private void loadHeaderFromFile() {
picasso.invalidate(getFileStreamPath(AppSettings.HEADER_FILE_NAME));
scrollHeaderVertical.post(new Runnable() {
@Override
public void run() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(getFileStreamPath(AppSettings.HEADER_FILE_NAME).getAbsolutePath(), options);
/*
Determine which length is longer and scale image appropriately
*/
float ratioHeader = (float) scrollHeaderVertical.getWidth() / scrollHeaderVertical.getHeight();
float ratioImage = (float) options.outWidth / options.outHeight;
int targetWidth = 0;
int targetHeight = 0;
if (ratioImage > ratioHeader) {
targetHeight = scrollHeaderVertical.getHeight();
} else {
targetWidth = scrollHeaderVertical.getWidth();
}
final int finalTargetWidth = targetWidth;
final int finalTargetHeight = targetHeight;
imageHeader.post(() -> picasso.load(getFileStreamPath(AppSettings.HEADER_FILE_NAME)).noPlaceholder().resize(finalTargetWidth, finalTargetHeight).into(imageHeader, new Callback() {
@Override
public void onSuccess() {
Log.d(TAG, "loadHeaderFromFile onSuccess");
imageHeader.setAlpha(1f);
textAccountName.setTextColor(Color.WHITE);
textAccountName.setShadowLayer(3, 0, 0, Color.BLACK);
textAccountInfo.setTextColor(Color.WHITE);
textAccountInfo.setShadowLayer(3, 0, 0, Color.BLACK);
buttonAccounts.clearColorFilter();
imageHeader.post(() -> {
scrollHeaderVertical.scrollTo(0, imageHeader.getHeight() / 2 - scrollHeaderVertical.getHeight() / 2);
scrollHeaderHorizontal.scrollTo(0, imageHeader.getWidth() / 2 - scrollHeaderHorizontal.getWidth() / 2);
});
}
@Override
public void onError() {
imageHeader.setAlpha(1f);
}
}));
}
});
}
Aggregations