Java Code Examples for com.squareup.picasso.RequestCreator#memoryPolicy()
The following examples show how to use
com.squareup.picasso.RequestCreator#memoryPolicy() .
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: PicturePresenter.java From AndroidDemo with MIT License | 4 votes |
public void loadImageView() { iPictureView.clearImageView(); boolean cache = iPictureView.getCache(); boolean disk = iPictureView.getDisk(); boolean transformation = iPictureView.getTransformation(); Picasso picasso = Picasso.with(context.get()); picasso.setIndicatorsEnabled(true); picasso.setLoggingEnabled(true); String path = "https://avatars2.githubusercontent.com/u/9563634?s=400&u=6c9844a5ee91e0385888cbd5708af59f4062d651&v=4"; RequestCreator requestCreator = picasso.load(path) .config(Bitmap.Config.RGB_565) .placeholder(R.drawable.ic_empty_zhihu) .error(R.drawable.ic_failed) .fit(); if (!cache) { requestCreator.memoryPolicy(MemoryPolicy.NO_CACHE); } if (!disk) { requestCreator.networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE); } if (transformation) { final Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(0xffcccccc); paint.setStyle(Paint.Style.FILL); final float round = Tools.dip2pxf(context.get(), 8); requestCreator.transform(new Transformation() { @Override public Bitmap transform(Bitmap source) { Bitmap src = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight()); Canvas canvas = new Canvas(src); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { float r = source.getWidth() / 4 * 3; canvas.drawCircle(source.getWidth() / 2, source.getHeight() / 2, r, paint); } else { canvas.drawRoundRect(round, round, source.getWidth() - round, source.getHeight() - round, round, round, paint); } canvas.drawBitmap(source, 0, 0, paint); if (!source.isRecycled()) { source.recycle(); } return src; } @Override public String key() { return "PicassoTransformation"; } }); } requestCreator.into(iPictureView.getTarget(), new Callback() { @Override public void onSuccess() { iPictureView.showToast("success"); } @Override public void onError() { iPictureView.showToast("error"); } }); }
Example 2
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 3
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); // } } }); }