use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class FullscreenImageActivity method setupViews.
private void setupViews() {
photoView = (PhotoView) findViewById(R.id.fullscreen_content);
// try to immediately show cached preview image
String previewImagePath = getIntent().getStringExtra(EXTRA_PREVIEW_IMAGE);
if (!TextUtils.isEmpty(previewImagePath)) {
ServiceUtils.loadWithPicasso(this, previewImagePath).networkPolicy(NetworkPolicy.OFFLINE).into(photoView, new Callback() {
@Override
public void onSuccess() {
loadLargeImage(true);
}
@Override
public void onError() {
loadLargeImage(false);
}
});
} else {
loadLargeImage(false);
}
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
systemUiHider = SystemUiHider.getInstance(this, photoView, SystemUiHider.FLAG_FULLSCREEN);
systemUiHider.setup();
photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
@Override
public void onViewTap(View view, float x, float y) {
systemUiHider.toggle();
}
});
}
use of com.squareup.picasso.Callback in project SeriesGuide by UweTrottmann.
the class OverviewFragment method loadEpisodeImage.
private void loadEpisodeImage(String imagePath) {
if (TextUtils.isEmpty(imagePath)) {
imageEpisode.setImageDrawable(null);
return;
}
if (DisplaySettings.preventSpoilers(getContext())) {
// show image placeholder
imageEpisode.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageEpisode.setImageResource(R.drawable.ic_image_missing);
} else {
// try loading image
ServiceUtils.loadWithPicasso(getActivity(), TvdbImageTools.fullSizeUrl(imagePath)).error(R.drawable.ic_image_missing).into(imageEpisode, new Callback() {
@Override
public void onSuccess() {
imageEpisode.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
@Override
public void onError() {
imageEpisode.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
});
}
}
use of com.squareup.picasso.Callback in project UltimateAndroid by cymcsg.
the class BaseSliderView method bindEventAndShow.
/**
* When you want to implement your own slider view, please call this method in the end in `getView()` method
* @param v the whole view
* @param targetImageView where to place image
*/
protected void bindEventAndShow(final View v, ImageView targetImageView) {
final BaseSliderView me = this;
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnSliderClickListener != null) {
mOnSliderClickListener.onSliderClick(me);
}
}
});
if (targetImageView == null)
return;
mLoadListener.onStart(me);
Picasso p = Picasso.with(mContext);
RequestCreator rq = null;
if (mUrl != null) {
rq = p.load(mUrl);
} else if (mFile != null) {
rq = p.load(mFile);
} else if (mRes != 0) {
rq = p.load(mRes);
} else {
return;
}
if (rq == null) {
return;
}
if (getEmpty() != 0) {
rq.placeholder(getEmpty());
}
if (getError() != 0) {
rq.error(getError());
}
switch(mScaleType) {
case Fit:
rq.fit();
break;
case CenterCrop:
rq.fit().centerCrop();
break;
case CenterInside:
rq.fit().centerInside();
break;
}
rq.into(targetImageView, new Callback() {
@Override
public void onSuccess() {
if (v.findViewById(R.id.loading_bar) != null) {
v.findViewById(R.id.loading_bar).setVisibility(View.INVISIBLE);
}
}
@Override
public void onError() {
if (mLoadListener != null) {
mLoadListener.onEnd(false, me);
}
}
});
}
use of com.squareup.picasso.Callback in project boxing by Bilibili.
the class BoxingPicassoLoader method displayRaw.
@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, final IBoxingCallback callback) {
String path = "file://" + absPath;
Picasso.with(img.getContext()).load(path).transform(new BitmapTransform(1080, 720)).into(img, new Callback() {
@Override
public void onSuccess() {
if (callback != null) {
callback.onSuccess();
}
}
@Override
public void onError() {
if (callback != null) {
callback.onFail(null);
}
}
});
}
use of com.squareup.picasso.Callback in project Tusky by Vavassor.
the class ViewMediaFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_view_media, container, false);
ButterKnife.bind(this, rootView);
Bundle arguments = getArguments();
String url = arguments.getString("url");
attacher = new PhotoViewAttacher(photoView);
// Clicking outside the photo closes the viewer.
attacher.setOnOutsidePhotoTapListener(new OnOutsidePhotoTapListener() {
@Override
public void onOutsidePhotoTap(ImageView imageView) {
dismiss();
}
});
/* A vertical swipe motion also closes the viewer. This is especially useful when the photo
* mostly fills the screen so clicking outside is difficult. */
attacher.setOnSingleFlingListener(new OnSingleFlingListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (Math.abs(velocityY) > Math.abs(velocityX)) {
dismiss();
return true;
}
return false;
}
});
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
Picasso.with(getContext()).load(url).into(photoView, new Callback() {
@Override
public void onSuccess() {
rootView.findViewById(R.id.view_media_progress).setVisibility(View.GONE);
toolbar.setOnMenuItemClickListener(ViewMediaFragment.this);
toolbar.inflateMenu(R.menu.view_media_tooblar);
attacher.update();
}
@Override
public void onError() {
}
});
return rootView;
}
Aggregations