Java Code Examples for com.squareup.picasso.RequestCreator#placeholder()
The following examples show how to use
com.squareup.picasso.RequestCreator#placeholder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PicassoLoaderProcessor.java From ImageLoaderProcessor with Apache License 2.0 | 6 votes |
private RequestCreator loadOptions(RequestCreator requestCreator) { if (options == null) { return requestCreator; } if (options.targetHeight > 0 && options.targetWidth > 0) { requestCreator.resize(options.targetWidth, options.targetHeight); } if (options.isCenterInside) { requestCreator.centerInside(); } else if (options.isCenterCrop) { requestCreator.centerCrop(); } if (options.config != null) { requestCreator.config(options.config); } if (options.errorResId != 0) { requestCreator.error(options.errorResId); } if (options.placeholderResId != 0) { requestCreator.placeholder(options.placeholderResId); } if (options.bitmapAngle != 0) { requestCreator.transform(new PicassoTransformation(options.bitmapAngle)); } return requestCreator; }
Example 2
Source File: mImage.java From intra42 with Apache License 2.0 | 6 votes |
public static void setPicasso(Uri url, ImageView imageView, @DrawableRes int placeHolder) { Picasso picasso = Picasso.get(); if (BuildConfig.DEBUG) picasso.setLoggingEnabled(true); RequestCreator requestCreator = picasso.load(url); if (placeHolder != 0) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { requestCreator.placeholder(placeHolder); requestCreator.error(placeHolder); } else { Drawable drawable = ContextCompat.getDrawable(imageView.getContext(), placeHolder); requestCreator.placeholder(drawable); requestCreator.error(drawable); } } requestCreator.into(imageView); }
Example 3
Source File: ImageLoader.java From Contacts with MIT License | 6 votes |
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); requestCreator.into(imageView, listener); }
Example 4
Source File: ImageLoader.java From Klyph with MIT License | 6 votes |
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); requestCreator.into(imageView, listener); }
Example 5
Source File: FantasyFragment.java From catnut with MIT License | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { boolean fitXY = getArguments().getBoolean(FIT_XY); if (getActivity() instanceof HelloActivity) { if (!((HelloActivity) getActivity()).isNetworkAvailable()) { if (fitXY) { Toast.makeText(getActivity(), R.string.network_unavailable, Toast.LENGTH_SHORT).show(); mFantasy.setImageResource(R.drawable.default_fantasy); return; // 没有网络,直接结束第一张fantasy } } } RequestCreator creator = Picasso.with(getActivity()).load(mUrl); if (fitXY) { creator.placeholder(R.drawable.default_fantasy); } creator.error(R.drawable.error) .into(target); }
Example 6
Source File: ImageLoader.java From KlyphMessenger with MIT License | 6 votes |
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); requestCreator.into(imageView, listener); }
Example 7
Source File: PicassoImageLoader.java From Game-of-Thrones with Apache License 2.0 | 5 votes |
@Override public void show() { RequestCreator creator = Picasso.with(imageView != null ? imageView.getContext() : context) .load(url); if (transformation != null) { creator.transform(transformation); } if (placeholder != null) { creator.placeholder(placeholder); } if (with > 0 && height > 0) { creator.resize(with, height); } if (centerCrop) { creator.centerCrop(); } if (fit) { creator.fit(); } if (target != null) { creator.into(target); } else { creator.into(imageView); } }
Example 8
Source File: ImageHelper.java From AndroidPicker with MIT License | 5 votes |
@Override public void display(String urlOrPath, ImageView view, int width, int height) { LogUtils.verbose("Image>>>" + urlOrPath); if (null == context) { context = view.getContext(); } RequestCreator creator = Picasso.with(context).load(urlOrPath); creator.placeholder(PLACEHOLDER_LOADING); creator.error(PLACEHOLDER_FAILURE); creator.config(urlOrPath.endsWith(".png") ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); if (width > 0 && height > 0) { creator.resize(width, height); } creator.into(view); }
Example 9
Source File: ImageLoader.java From Contacts with MIT License | 5 votes |
public static void display(ImageView imageView, Uri uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { /*if (uri == null || uri.length() == 0) uri = FAKE_URI; //uri = Uri.encode(uri, ALLOWED_URI_CHARS);*/ Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); LayoutParams params = imageView.getLayoutParams(); if (params.width > 0 && params.height > 0) { requestCreator.resize(params.width, params.height, true); } requestCreator.inSampleSize(true); requestCreator.into(imageView, listener); }
Example 10
Source File: ImageLoader.java From Contacts with MIT License | 5 votes |
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; uri = Uri.encode(uri, ALLOWED_URI_CHARS); Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); LayoutParams params = imageView.getLayoutParams(); if (params.width > 0 && params.height > 0) { requestCreator.resize(params.width, params.height, true); } requestCreator.inSampleSize(true); requestCreator.into(imageView, listener); }
Example 11
Source File: ImageLoader.java From Klyph with MIT License | 5 votes |
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; /*uri = uri.replace("�", URLEncoder.encode("�")); uri = uri.replace("�", URLEncoder.encode("�")); uri = uri.replace("'", URLEncoder.encode("'")); uri = uri.replace("�", URLEncoder.encode("�"));*/ uri = Uri.encode(uri, ALLOWED_URI_CHARS); Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); LayoutParams params = imageView.getLayoutParams(); if (params.width > 0 && params.height > 0) { requestCreator.resize(params.width, params.height, true); } requestCreator.inSampleSize(true); requestCreator.into(imageView, listener); }
Example 12
Source File: ImageLoader.java From KlyphMessenger with MIT License | 5 votes |
public static void display(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) { if (uri == null || uri.length() == 0) uri = FAKE_URI; /*uri = uri.replace("�", URLEncoder.encode("�")); uri = uri.replace("�", URLEncoder.encode("�")); uri = uri.replace("'", URLEncoder.encode("'")); uri = uri.replace("�", URLEncoder.encode("�"));*/ uri = Uri.encode(uri, ALLOWED_URI_CHARS); Picasso picasso = Picasso.with(imageView.getContext()); RequestCreator requestCreator = picasso.load(uri); if (stubImage != 0) { requestCreator.placeholder(stubImage); requestCreator.error(stubImage); } if (!(fadeIn && FADE_ENABLED)) requestCreator.noFade(); LayoutParams params = imageView.getLayoutParams(); if (params.width > 0 && params.height > 0) { requestCreator.resize(params.width, params.height, true); } requestCreator.inSampleSize(true); requestCreator.into(imageView, listener); }
Example 13
Source File: CompactSliderView.java From LoyalNativeSlider with MIT License | 4 votes |
private void bindEventAndShow( @NonNull final ImageView targetImageView, @NonNull final String mURI ) { // mLoadListener.onStart(me); final Picasso p = Picasso.with(mContext); final RequestCreator mreq = p.load(mURI); if (getEmpty() != 0) { mreq.placeholder(getEmpty()); } if (getError() != 0) { mreq.error(getError()); } if (mImageLocalStorageEnable) { mreq.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE); } switch (mScaleType) { case Fit: mreq.fit(); break; case CenterCrop: mreq.fit().centerCrop(); break; case CenterInside: mreq.fit().centerInside(); break; } mreq.into(targetImageView, new Callback() { @Override public void onSuccess() { // if (v.findViewById(R.id.ns_loading_progress) != null) { // hideoutView(v.findViewById(R.id.ns_loading_progress)); // } if (mLongClickSaveImage && fmg != null) { targetImageView.setOnLongClickListener(new View.OnLongClickListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onLongClick(View v) { prepare_request_save_image = mreq; final saveImageDialog saveImageDial = new saveImageDialog(); saveImageDial.show(fmg.get(), "DESC_SAVE_IM"); return false; } }); } } @Override public void onError() { //if (mLoadListener != null) { // mLoadListener.onEnd(false, me); // } } }); }
Example 14
Source File: CompactFrameSliderView.java From LoyalNativeSlider with MIT License | 4 votes |
protected void bindCompatPicasso(String mURI, final MiniSliderFrame Fr) { final Picasso p = Picasso.with(mContext); final RequestCreator mreq = p.load(mURI); if (getEmpty() != 0) { mreq.placeholder(getEmpty()); } if (getError() != 0) { mreq.error(getError()); } if (mImageLocalStorageEnable) { mreq.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE); } switch (mScaleType) { case Fit: mreq.fit(); break; case CenterCrop: mreq.fit().centerCrop(); break; case CenterInside: mreq.fit().centerInside(); break; } mreq.into(Fr.getImageTarget(), new Callback() { @Override public void onSuccess() { hideoutView(Fr.getLoadingBar()); if (mLongClickSaveImage && fmg != null) { Fr.getTouch().setOnLongClickListener(new View.OnLongClickListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onLongClick(View v) { prepare_request_save_image = mreq; final saveImageDialog saveImageDial = new saveImageDialog(); saveImageDial.show(fmg.get(), "DESC_SAVE_IM"); return false; } }); } } @Override public void onError() { //if (mLoadListener != null) { // mLoadListener.onEnd(false, me); // } } }); }
Example 15
Source File: PicassoImageLoader.java From Nox with Apache License 2.0 | 4 votes |
private RequestCreator applyPlaceholder(RequestCreator bitmapRequest) { if (placeholderId != null) { bitmapRequest.placeholder(placeholderId); } return bitmapRequest; }