com.squareup.picasso.NetworkPolicy Java Examples
The following examples show how to use
com.squareup.picasso.NetworkPolicy.
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: PullImageController.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
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).invalidate(request); PicassoProvider.getInstance(context, false) .load(request).networkPolicy(NetworkPolicy.NO_CACHE) .memoryPolicy(MemoryPolicy.NO_CACHE).fetch(); } else { PicassoProvider.getInstance(context, false) .load(request).fetch(); } } }
Example #2
Source File: ColorizeFaceActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #3
Source File: MakeupProductFragment.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #4
Source File: OwnProductFragment.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #5
Source File: FavouriteProductFragment.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #6
Source File: ProfileActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #7
Source File: MainActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #8
Source File: ProductDetailActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); } }
Example #9
Source File: PhotoActivity.java From ratebeer with GNU General Public License v3.0 | 6 votes |
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); } }
Example #10
Source File: ProductRecommentationActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
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); } }); }
Example #11
Source File: InterpretationAdapter.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } } }
Example #12
Source File: InterpretationAdapter.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } }
Example #13
Source File: FullScreenImageFragment.java From PhotoDiscovery with Apache License 2.0 | 6 votes |
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); } } }); }
Example #14
Source File: DashboardItemAdapter.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } } }
Example #15
Source File: DashboardItemAdapter.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } }
Example #16
Source File: ProfileActivity.java From FaceT with Mozilla Public License 2.0 | 5 votes |
private void setupUserData() { mDatabaseUsers.child(mAuth.getCurrentUser().getUid()).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue() != null) { Log.i("dataSnapshot.getValue()", dataSnapshot.getValue().toString()); final User user_data = dataSnapshot.getValue(User.class); Log.e(user_data.getName(), "User data is null!"); mOwnNameField.setText(user_data.getName()); profile_email.setText(user_data.getEmail()); Picasso.with(getApplicationContext()).load(user_data.getImage()).networkPolicy(NetworkPolicy.OFFLINE).into(profilePic, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(getApplicationContext()) .load(user_data.getImage()) .centerCrop() .fit() .into(profilePic); } }); } } @Override public void onCancelled(DatabaseError databaseError) { } }); }
Example #17
Source File: MockRequestHandler.java From u2020 with Apache License 2.0 | 5 votes |
@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); }
Example #18
Source File: ImageViewFragment.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { mImageView = (ImageView) view; mAttacher = new PhotoViewAttacher(mImageView); mAttacher.update(); PicassoProvider.getInstance(getActivity().getApplicationContext(), false) .load(getImageUrl()) .networkPolicy(NetworkPolicy.NO_STORE, NetworkPolicy.OFFLINE) .memoryPolicy(MemoryPolicy.NO_STORE) .placeholder(R.mipmap.ic_stub_dashboard_item) .into(mImageView); }
Example #19
Source File: MockRequestHandler.java From u2020-mvp with Apache License 2.0 | 5 votes |
@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); }
Example #20
Source File: OtheruserProfileActivity.java From FaceT with Mozilla Public License 2.0 | 5 votes |
private void getUserData() { mDatabaseUsers.child(userId).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue() != null) { Log.i("dataSnapshot.getValue()", dataSnapshot.getValue().toString()); final User user_data = dataSnapshot.getValue(User.class); Log.e(user_data.getName(), "User data is null!"); otheruser_profile_username.setText(user_data.getName()); otheruser_profile_email.setText(mAuth.getCurrentUser().getEmail()); otheruser_aboutme.setText(user_data.getAboutMe()); Picasso.with(getApplicationContext()).load(user_data.getImage()).networkPolicy(NetworkPolicy.OFFLINE).into(otheruser_profile_picture, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(getApplicationContext()) .load(user_data.getImage()) .centerCrop() .fit() .into(otheruser_profile_picture); } }); } } @Override public void onCancelled(DatabaseError databaseError) { } }); }
Example #21
Source File: Images.java From ratebeer with GNU General Public License v3.0 | 5 votes |
public RequestCreator loadUser(String username, boolean highResolution) { RequestCreator request = Picasso.with(context).load(highResolution ? ImageUrls.getUserPhotoHighResUrl(username) : ImageUrls.getUserPhotoUrl(username)); if (Session.get().inDataSaverMode() && ConnectivityHelper.current(context) != ConnectivityHelper.ConnectivityType.Wifi) request.networkPolicy(NetworkPolicy.OFFLINE); return request; }
Example #22
Source File: Images.java From ratebeer with GNU General Public License v3.0 | 5 votes |
public RequestCreator loadBrewery(long breweryId, boolean highResolution) { RequestCreator request = Picasso.with(context).load(highResolution ? ImageUrls.getBreweryPhotoHighResUrl(breweryId) : ImageUrls .getBreweryPhotoUrl(breweryId)); if (Session.get().inDataSaverMode() && ConnectivityHelper.current(context) != ConnectivityHelper.ConnectivityType.Wifi) request.networkPolicy(NetworkPolicy.OFFLINE); return request; }
Example #23
Source File: Images.java From ratebeer with GNU General Public License v3.0 | 5 votes |
public RequestCreator loadBeer(long beerId, boolean highResolution) { RequestCreator request = Picasso.with(context).load(highResolution ? ImageUrls.getBeerPhotoHighResUrl(beerId) : ImageUrls.getBeerPhotoUrl(beerId)); if (Session.get().inDataSaverMode() && ConnectivityHelper.current(context) != ConnectivityHelper.ConnectivityType.Wifi) request.networkPolicy(NetworkPolicy.OFFLINE); return request; }
Example #24
Source File: GalleryRecyclerViewAdapter.java From PhotoDiscovery with Apache License 2.0 | 5 votes |
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); } } }); }
Example #25
Source File: FullScreenImageFragment.java From PhotoDiscovery with Apache License 2.0 | 5 votes |
@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; }
Example #26
Source File: MainActivity.java From Simple-Blog-App with MIT License | 5 votes |
public void setImage(final Context ctx, final String IMAGE) { final ImageView post_image = mView.findViewById(R.id.post_image); Picasso.with(ctx) .load(IMAGE) .networkPolicy(NetworkPolicy.OFFLINE) .into(post_image, new Callback() { @Override public void onSuccess() { } @Override public void onError() { //if error occured try again by getting the image from online Picasso.with(ctx) .load(IMAGE) .error(R.drawable.ic_broken_image) .into(post_image, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Toast.makeText(ctx, "failed to load image !", Toast.LENGTH_SHORT).show(); } }); } }); }
Example #27
Source File: ProfileActivity.java From FaceT with Mozilla Public License 2.0 | 4 votes |
private void getUserData() { mDatabaseUsers.child(mAuth.getCurrentUser().getUid()).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue() != null) { Log.i("dataSnapshot.getValue()", dataSnapshot.getValue().toString()); final User user_data = dataSnapshot.getValue(User.class); Log.e(user_data.getName(), "User data is null!"); mOwnNameField.setText(user_data.getName()); profile_email.setText(mAuth.getCurrentUser().getEmail()); profile_aboutme.setText(user_data.getAboutMe()); //set up title SpannableString s = new SpannableString(user_data.getName()); s.setSpan(new TypefaceSpan(ProfileActivity.this, FontManager.CUSTOM_FONT), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getSupportActionBar().setTitle(s); toolbar_title.setText(s); Picasso.with(getApplicationContext()).load(user_data.getImage()).networkPolicy(NetworkPolicy.OFFLINE).into(profilePic, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(getApplicationContext()) .load(user_data.getImage()) .centerCrop() .fit() .into(profilePic); } }); } } @Override public void onCancelled(DatabaseError databaseError) { } }); }
Example #28
Source File: MainActivity.java From FaceT with Mozilla Public License 2.0 | 4 votes |
private void setupNavHeader() { View header = view.getHeaderView(0); final TextView usernameHeader = (TextView) header.findViewById(R.id.username_header); final TextView emailHeader = (TextView) header.findViewById(R.id.email_header); final CircleImageView headerphoto = (CircleImageView) header.findViewById(R.id.profile_image); headerphoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent accountIntent = new Intent(MainActivity.this, ProfileActivity.class); accountIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(accountIntent); } }); if (mAuth.getCurrentUser() != null) { mDatabaseUsers.child(mAuth.getCurrentUser().getUid()).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { final User user_data = dataSnapshot.getValue(User.class); if (user_data != null) { Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT); usernameHeader.setTypeface(fontType); emailHeader.setTypeface(fontType); usernameHeader.setText(user_data.getName()); if (user_data.getEmail() != null && user_data.getEmail().length() > 0) emailHeader.setText(user_data.getEmail()); else if (user_data.getEmail() == null || user_data.getEmail().length() == 0) emailHeader.setText(mAuth.getCurrentUser().getEmail()); Picasso.with(getApplicationContext()).load(user_data.getImage()).networkPolicy(NetworkPolicy.OFFLINE).into(headerphoto, new Callback() { @Override public void onSuccess() { } @Override public void onError() { Picasso.with(getApplicationContext()) .load(user_data.getImage()) .centerCrop() .fit() .into(headerphoto); } }); } } @Override public void onCancelled(DatabaseError databaseError) { } }); } }
Example #29
Source File: PicassoUtils.java From PlayTogether with Apache License 2.0 | 4 votes |
/** * 展示指定大小的图片 * * @param context * @param uri * @param imageView * @param width * @param height */ public static void displaySpecSizeImage(final Context context, final Uri uri, final ImageView imageView, final int width, final int height, final OnLoadPicListener listener) { Picasso.with(context) .load(uri) .resize(width, height) .placeholder(R.mipmap.pictures_no) .networkPolicy(NetworkPolicy.OFFLINE) .into(imageView, new Callback() { @Override public void onSuccess() { if (listener != null) { listener.onSuccess(); } } @Override public void onError() { //Try again online if cache failed Picasso.with(context) .load(uri) .centerInside() .resize(width, height) .placeholder(R.mipmap.pictures_no) .error(R.mipmap.pictures_no) .into(imageView, new Callback() { @Override public void onSuccess() { if (listener != null) { listener.onSuccess(); } } @Override public void onError() { listener.onError(); Logger.e("can not find image"); } }); } }); }
Example #30
Source File: PicassoUtils.java From PlayTogether with Apache License 2.0 | 4 votes |
/** * 展示自适应imageview的图片 * * @param context * @param uri * @param imageView * @param callback */ public static void displayFitImage(final Context context, final Uri uri, final ImageView imageView, final Callback callback) { Picasso.with(context) .load(uri) .fit() .placeholder(R.mipmap.pictures_no) .networkPolicy(NetworkPolicy.OFFLINE) .into(imageView, new Callback() { @Override public void onSuccess() { } @Override public void onError() { // Logger.e("down load.."); //Try again online if cache failed Picasso.with(context) .load(uri) .fit() .placeholder(R.mipmap.pictures_no) .error(R.mipmap.pictures_no) .into(imageView, callback == null ? new Callback() { @Override public void onSuccess() { } @Override public void onError() { Logger.e("can not find image"); } } : callback); } }); }