@Override public void displayImage(Context context, String path, FixImageView imageView, Drawable defaultDrawable, Bitmap.Config config, boolean resize, boolean isGif, int width, int height, int rotate) { RequestCreator creator = Picasso.with(context) .load(new File(path)) .placeholder(defaultDrawable) .error(defaultDrawable) .rotate(rotate) .networkPolicy(NetworkPolicy.NO_STORE) .config(config) .tag(context); if (resize) { creator = creator.resize(width, height) .centerCrop(); } creator.into(imageView); }
public void setimg(final Context ctx, final String postimag) { final ImageView postimage = (ImageView)view.findViewById(R.id.postimage); Picasso.with(ctx).load(postimag).networkPolicy(NetworkPolicy.OFFLINE).into(postimage, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(ctx).load(postimag).into(postimage); } }); }
private void loadImage(final ImageView imageView, final String url, final NetworkPolicy networkPolicy) { Picasso.with(context) .load(url) .placeholder(circularLoaderDrawable) .networkPolicy(networkPolicy) .into(imageView, new com.squareup.picasso.Callback() { @Override public void onSuccess() { // circularLoaderDrawable.clearAnimation(); } @Override public void onError() { if (!networkPolicy.equals(NetworkPolicy.OFFLINE)) { circularLoaderDrawable.setError(); } else { loadImage(imageView, url, NetworkPolicy.NO_CACHE); } } }); }
@Override public Response load(Uri uri, int networkPolicy) throws IOException { CacheControl.Builder builder = new CacheControl.Builder(); if (networkPolicy != 0) { if (NetworkPolicy.isOfflineOnly(networkPolicy)) { builder.onlyIfCached(); } else { if (!NetworkPolicy.shouldReadFromDiskCache(networkPolicy)) { builder.noCache(); } if (!NetworkPolicy.shouldWriteToDiskCache(networkPolicy)) { builder.noStore(); } } } Request request = new Request.Builder() .cacheControl(builder.build()) .url(uri.toString()) .build(); okhttp3.Response response = mClient.newCall(request).execute(); return new Response(response.body().byteStream(), false, response.body().contentLength()); }
@Override public void showDetails(Application application) { textViewName.setText(application.name.label); textViewSummary.setText(application.summary.label); if(picasso !=null && application.images.size()>0 && !application.images.get(0).label.isEmpty()){ final String imagePath = application.images.get(0).label; picasso.load(imagePath) .networkPolicy(NetworkPolicy.OFFLINE) .into(mImageViewIcon, new Callback() { @Override public void onSuccess() { } @Override public void onError() { // Try to get image online picasso.load(imagePath).into(mImageViewIcon); } }); } }
@Override public Response load(Uri uri, int networkPolicy) throws IOException { CacheControl.Builder builder = new CacheControl.Builder(); if (networkPolicy != 0) { if (NetworkPolicy.isOfflineOnly(networkPolicy)) { builder.onlyIfCached(); } else { if (!NetworkPolicy.shouldReadFromDiskCache(networkPolicy)) { builder.noCache(); } if (!NetworkPolicy.shouldWriteToDiskCache(networkPolicy)) { builder.noStore(); } } } Request request = new Request.Builder() .cacheControl(builder.build()) .url(uri.toString()) .build(); okhttp3.Response response = mClient.newCall(request).execute(); return new Response(response.body().byteStream(),response.cacheResponse()!=null,response.body().contentLength()); }
@Override public void callNextCycle(String lastImagePath) { if(!TextUtils.isEmpty(lastImagePath)) currentFramePicasso.invalidate(lastImagePath); if(beanImages != null && beanImages.size() > 0) beanImages.remove(0); //because targets are also running sequential, in case of parallel need to shift it to respective class if(targets != null && targets.size() > 0) targets.remove(0); if(beanImages.size() == 0) return; BeanImage beanImage = beanImages.get(0); if(Utils.isLocalPath(beanImage.getImageLink())){ Utils.logVerbose("LADING AS : "+"local image " + beanImage.getImageLink()); new UnframedLocalTask(this).execute(beanImage); } else { Utils.logVerbose("LADING AS : "+"server image " + beanImage.getImageLink()); UnframedPicassoTargetNew target = new UnframedPicassoTargetNew(this, beanImage); targets.add(target); currentFramePicasso.load(beanImage.getImageLink()).memoryPolicy(MemoryPolicy.NO_STORE) .networkPolicy(NetworkPolicy.NO_STORE) .noPlaceholder() .transform(new ScaleTransformation(frameModel.getMaxContainerWidth(), frameModel.getMaxContainerHeight(), totalImages, beanImage.getImageLink(), beanImage, this)) .into(target); } }
private void showPhoto(boolean refresh) { // Load high res photo into the single image view ImageView photoImage = (ImageView) findViewById(R.id.photo_image); String url = null; if (getIntent().hasExtra("userName")) { url = ImageUrls.getUserPhotoHighResUrl(getIntent().getStringExtra("userName")); } else if (getIntent().hasExtra("beerId")) { url = ImageUrls.getBeerPhotoHighResUrl(getIntent().getLongExtra("beerId", 0)); } if (refresh) { Picasso.with(this).invalidate(url); Picasso.with(this).load(url).networkPolicy(NetworkPolicy.NO_CACHE).into(photoImage); } else { Picasso.with(this).load(url).into(photoImage); } }
public void setImage(final Context ctx, final String image) { final ImageView favourite_post_image = (ImageView) mFavouriteProductView.findViewById(R.id.favourite_product_image); Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(favourite_post_image, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(ctx) .load(image) .fit() .centerCrop() .into(favourite_post_image); } }); }
public void setImage(final Context ctx, final String image) { final ImageView own_post_image = (ImageView) mOwnProductView.findViewById(R.id.own_product_image); Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(own_post_image, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(ctx) .load(image) .fit() .centerCrop() .into(own_post_image); } }); }
public void setImage(final Context ctx, final String image) { final ImageView makeup_apply_product_image = (ImageView) mView.findViewById(R.id.makeup_apply_product_image); Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(makeup_apply_product_image, new Callback() { @Override public void onSuccess() { Log.d(TAG, "image loading success !"); } @Override public void onError() { Log.d(TAG, "image loading error !"); Picasso.with(ctx) .load(image) .resize(100, 100) .centerCrop() .into(makeup_apply_product_image); } }); }
public void setImage(final Context ctx, final String image) { final ImageView makeup_product_image = (ImageView) mView.findViewById(R.id.makeup_product_image); Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(makeup_product_image, new Callback() { @Override public void onSuccess() { Log.d(TAG, "image loading success !"); } @Override public void onError() { Log.d(TAG, "image loading error !"); Picasso.with(ctx) .load(image) .resize(100, 100) .centerCrop() .into(makeup_product_image); } }); }
public void setImage(final Context ctx, final String image) { final ImageView post_image = (ImageView) mView.findViewById(R.id.product_image); Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(post_image, new Callback() { @Override public void onSuccess() { Log.d(TAG, "image loading success !"); } @Override public void onError() { Log.d(TAG, "image loading error !"); Picasso.with(ctx) .load(image) .resize(100, 100) .centerCrop() .into(post_image); } }); }
public void setImage(final Context ctx, final String image) { final ImageView product_image = (ImageView) mView.findViewById(R.id.product_image); Picasso.with(ctx).load(image).networkPolicy(NetworkPolicy.OFFLINE).into(product_image, new Callback() { @Override public void onSuccess() { Log.d(TAG, "image loading success !"); } @Override public void onError() { Log.d(TAG, "image loading error !"); Picasso.with(ctx) .load(image) .resize(90, 90) .centerCrop() .into(product_image); } }); }
public void setUserImage(final Context ctx, final String userImage) { if (userImage != null && userImage.length() > 0) { Log.d(TAG + "userImage", userImage); Picasso.with(ctx).load(userImage).networkPolicy(NetworkPolicy.OFFLINE).into(user_image, new Callback() { @Override public void onSuccess() { Log.d(TAG, "image loading success !"); } @Override public void onError() { Log.d(TAG, "image loading error !"); Picasso.with(ctx) .load(userImage) .resize(50, 50) .centerCrop() .into(user_image); } }); } }
@Override public void loadImage(final ImageView imageView, final String imageUrl, Drawable drawable, final boolean offlineCacheOnError) { if(canLoad(imageUrl)) { Picasso.with(imageView.getContext()).load(imageUrl).placeholder(drawable) .into(imageView, new Callback() { @Override public void onSuccess() { } @Override public void onError() { if(offlineCacheOnError) { Picasso.with(imageView.getContext()) .load(imageUrl) .networkPolicy(NetworkPolicy.OFFLINE) .into(imageView); } } }); } else { imageView.setImageDrawable(drawable); } }
@Override public void display(Context context, String path, ImageView imageView, Drawable defaultDrawable, Bitmap.Config config, boolean resize, int width, int height) { RequestCreator creator = Picasso.with(context) .load(new File(path)) .placeholder(defaultDrawable) .error(defaultDrawable) // .rotate(rotate) .networkPolicy(NetworkPolicy.NO_STORE) .config(config) .tag(context); if (resize) { creator = creator.resize(width, height); } creator.into(imageView); }
@Override public void displayCenterCrop(Context context, String path, ImageView imageView, Drawable defaultDrawable, Bitmap.Config config, boolean resize, int width, int height) { RequestCreator creator = Picasso.with(context) .load(new File(path)) .placeholder(defaultDrawable) .error(defaultDrawable) // .rotate(rotate) .networkPolicy(NetworkPolicy.NO_STORE) .config(config) .tag(context); if (resize) { creator = creator.resize(width, height); } creator.centerCrop(); creator.into(imageView); }
private void downloadImages(DhisController.ImageNetworkPolicy imageNetworkPolicy, final List<String> requestUrlList, final Context context) { for (int i = 0; i < requestUrlList.size(); i++) { final String request = requestUrlList.get(i); if (imageNetworkPolicy == DhisController.ImageNetworkPolicy.NO_CACHE) { PicassoProvider.getInstance(context, false) .load(request).networkPolicy(NetworkPolicy.NO_CACHE) .memoryPolicy(MemoryPolicy.NO_CACHE).fetch(); } else { PicassoProvider.getInstance(context, false) .load(request).fetch(); } } }
public void bind(String request, Interpretation item){ if (request != null) { this.request = request; this.item = item; imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); if (request.contains("maps")){ showMapImage(modeWithBaseMap); }else{ modeButton.setVisibility(View.GONE); mImageLoader.load(request) .networkPolicy(NetworkPolicy.OFFLINE) .placeholder(R.mipmap.ic_stub_dashboard_item) .into(imageView); } } }
private void showMapImage(boolean modeWithBaseMap) { modeButton.setVisibility(View.VISIBLE); modeButton.setSelected(modeWithBaseMap); if (modeWithBaseMap){ Log.d(this.getClass().getSimpleName(), "Loading transform map: " + request); mImageLoader.load(request) .networkPolicy(NetworkPolicy.OFFLINE) .placeholder(R.mipmap.ic_stub_dashboard_item) .transform( new BaseMapLayerDhisTransformation(rootView.getContext(), item.getDataMap())) .into(imageView); }else{ Log.d(this.getClass().getSimpleName(), "Loading transform map: " + request); mImageLoader.load(request) .networkPolicy(NetworkPolicy.OFFLINE) .placeholder(R.mipmap.ic_stub_dashboard_item) .into(imageView); } }
public void bind(String request, DashboardItem item){ if (request != null) { this.request = request; this.item = item; imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); if (request.contains("maps")){ showMapImage(modeWithBaseMap); }else{ modeButton.setVisibility(View.GONE); mImageLoader.load(request) .networkPolicy(NetworkPolicy.OFFLINE) .placeholder(R.mipmap.ic_stub_dashboard_item) .into(imageView); } } }
@Override public void addImageToContent(String link) { final ImageView view = (ImageView) getActivity().getLayoutInflater().inflate(R.layout.article_content_img_item, mContentLayout, false); mContentLayout.addView(view); view.setTag(link); final ImageListener l = new ImageListener(view, link); view.setOnClickListener(l); RequestCreator r = Picasso.with(getActivity()).load(link).placeholder(R.drawable.default_content_image_loading); if (PreferenceHelper.getInstance().inSafeDataMode()) { l.setLoadCacheForFirst(true); r.networkPolicy(NetworkPolicy.OFFLINE); } r.into(view, l); }
@Nullable public static Bitmap fromCache (Context context, String url) { RequestCreator creator = buildPicasso(context, url) .networkPolicy(NetworkPolicy.OFFLINE, NetworkPolicy.OFFLINE) .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE); try { return creator.get(); } catch (IOException e) { e.printStackTrace(); return null; } }
public static void loadImagePreviewFromCache(Context context, SearchResultContainer container, int imageSize, Target target){ Picasso.with(context) .load(container.getFirstThumbnailLink()) .resize(imageSize, imageSize) .transform(new CircleTransform()) .networkPolicy(NetworkPolicy.OFFLINE) .into(target); }
@Override public Result load(Request request, int networkPolicy) throws IOException { String imagePath = request.uri.getPath().substring(1); // Grab only the path sans leading slash. // Check the disk cache for the image. A non-null return value indicates a hit. boolean cacheHit = emulatedDiskCache.get(imagePath) != null; // If there's a hit, grab the image stream and return it. if (cacheHit) { return new Result(loadBitmap(imagePath), Picasso.LoadedFrom.DISK); } // If we are not allowed to hit the network and the cache missed return a big fat nothing. if (NetworkPolicy.isOfflineOnly(networkPolicy)) { return null; } // If we got this far there was a cache miss and hitting the network is required. See if we need // to fake an network error. if (behavior.calculateIsFailure()) { SystemClock.sleep(behavior.calculateDelay(MILLISECONDS)); throw new IOException("Fake network error!"); } // We aren't throwing a network error so fake a round trip delay. SystemClock.sleep(behavior.calculateDelay(MILLISECONDS)); // Since we cache missed put it in the LRU. AssetFileDescriptor fileDescriptor = assetManager.openFd(imagePath); long size = fileDescriptor.getLength(); fileDescriptor.close(); emulatedDiskCache.put(imagePath, size); // Grab the image stream and return it. return new Result(loadBitmap(imagePath), Picasso.LoadedFrom.NETWORK); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_detail, container, false); ButterKnife.bind(this, rootView); Photo photo = Parcels.unwrap(getArguments().getParcelable(ARG_GALLERY_PHOTO)); circularLoaderDrawable = new CircularLoaderDrawable(); circularLoaderDrawable.animate(); Log.d(getClass().getSimpleName(), " photo.getUrl() " + photo.getUrl()); loadImage(imageView, photo.getUrl(), NetworkPolicy.OFFLINE); return rootView; }
private void loadImage(final ViewHolder holder, final int position, final NetworkPolicy networkPolicy) { final WeakReference<CircularLoaderDrawable> xx = new WeakReference<>(holder.getCircularLoaderDrawable()); Picasso.with(holder.getImageView().getContext()) .load(photoList.get(position).getUrl()) .resize(mColumnWidth, (int) (photoList.get(position).getAspectRatio() * mColumnWidth)) .placeholder(xx.get()) .noFade() .networkPolicy(networkPolicy) .into(holder.getImageView(), new com.squareup.picasso.Callback() { @Override public void onSuccess() { // xx.get().clearAnimation(); // AnimationUtils.fadeIn(holder.getImageView()); } @Override public void onError() { if (!networkPolicy.equals(NetworkPolicy.OFFLINE)) { holder.getCircularLoaderDrawable().setError(); } else { loadImage(holder, position, NetworkPolicy.NO_CACHE); } } }); }
@Override public RequestCreator fetchImageStrip(String url) { if (!AIRPLANE_MODE) { return mPicasso.load(url); } else { return mPicasso.load(url) .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) .networkPolicy(NetworkPolicy.NO_CACHE); } }
@Override public RequestCreator fetchImageStrip(@NonNull Long id) { if (id == null) { throw new IllegalArgumentException(); } File file = getImageCacheForStrip(id); return mPicasso .load(file) .networkPolicy(NetworkPolicy.OFFLINE, NetworkPolicy.NO_STORE); }