本文整理匯總了Java中com.squareup.picasso.NetworkPolicy類的典型用法代碼示例。如果您正苦於以下問題:Java NetworkPolicy類的具體用法?Java NetworkPolicy怎麽用?Java NetworkPolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NetworkPolicy類屬於com.squareup.picasso包,在下文中一共展示了NetworkPolicy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: displayImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
@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);
}
示例2: setimg
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例3: setimg
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例4: loadImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
}
});
}
示例5: load
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
@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());
}
示例6: showDetails
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
@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);
}
});
}
}
示例7: load
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
@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());
}
示例8: callNextCycle
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
@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);
}
}
示例9: showPhoto
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
}
示例10: setImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例11: setImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例12: setImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例13: setImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例14: setImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}
示例15: setImage
import com.squareup.picasso.NetworkPolicy; //導入依賴的package包/類
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);
}
});
}