use of com.squareup.picasso.Callback in project Hummingbird-for-Android by xiprox.
the class FavoriteAnimeAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = inflater.inflate(R.layout.item_favorite_grid, null);
FavoriteAnime fav = mItems.get(position);
final ImageView mCover = (ImageView) rootView.findViewById(R.id.item_favorite_cover);
final TextView mTitle = (TextView) rootView.findViewById(R.id.item_favorite_title);
ViewFlipper mFlipper = (ViewFlipper) rootView.findViewById(R.id.item_favorite_flipper);
Picasso.with(context).load(fav.getCoverImage()).into(mCover, new Callback() {
@Override
public void onSuccess() {
int darkMutedColor;
Bitmap bitmap = ((BitmapDrawable) mCover.getDrawable()).getBitmap();
darkMutedColor = Palette.generate(bitmap).getDarkMutedSwatch().getRgb();
mTitle.setBackgroundDrawable(new ColorDrawable(darkMutedColor));
}
@Override
public void onError() {
}
});
mTitle.setText(fav.getTitle());
if (mFlipper.getDisplayedChild() == 0)
mFlipper.showNext();
return rootView;
}
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;
}
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() {
}
});
}
Aggregations