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);
}
}
java类com.squareup.picasso.NetworkPolicy的实例源码
DashboardItemAdapter.java 文件源码
项目:dhis2-android-dashboard
阅读 27
收藏 0
点赞 0
评论 0
DetailsFragment.java 文件源码
项目:FxcnBeta
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
NetworkUtil.java 文件源码
项目:TPondof
阅读 30
收藏 0
点赞 0
评论 0
@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;
}
}
ImageLoaderHelper.java 文件源码
项目:DeepImagePreview-Project
阅读 20
收藏 0
点赞 0
评论 0
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);
}
MockRequestHandler.java 文件源码
项目:superglue
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
MockRequestHandler.java 文件源码
项目:superglue
阅读 17
收藏 0
点赞 0
评论 0
@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);
}
FullScreenImageFragment.java 文件源码
项目:PhotoDiscovery
阅读 20
收藏 0
点赞 0
评论 0
@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;
}
GalleryRecyclerViewAdapter.java 文件源码
项目:PhotoDiscovery
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
});
}
StripRemoteDataSource.java 文件源码
项目:commitstrip-reader
阅读 18
收藏 0
点赞 0
评论 0
@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);
}
}
StripImageCacheDataSource.java 文件源码
项目:commitstrip-reader
阅读 17
收藏 0
点赞 0
评论 0
@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);
}