當前位置: 首頁>>代碼示例>>Java>>正文


Java NetworkPolicy類代碼示例

本文整理匯總了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);
}
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:17,代碼來源:PicassoImageLoader.java

示例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);

        }
    });


}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:19,代碼來源:Drishti.java

示例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);

        }
    });


}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:18,代碼來源:Announcements.java

示例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);
          }
        }
      });
}
 
開發者ID:tarek360,項目名稱:PhotoDiscovery,代碼行數:23,代碼來源:FullScreenImageFragment.java

示例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());
}
 
開發者ID:Jay-Y,項目名稱:yApp,代碼行數:23,代碼來源:HttpFactory.java

示例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);
                    }
                });
    }
}
 
開發者ID:adhamenaya,項目名稱:AppsFeed,代碼行數:26,代碼來源:DetailsActivity.java

示例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());
}
 
開發者ID:Art2Cat,項目名稱:MoonlightNote,代碼行數:24,代碼來源:OkHttpDownloader.java

示例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);
    }
}
 
開發者ID:deepaktwr,項目名稱:BitFrames,代碼行數:26,代碼來源:ImageShading.java

示例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);
	}
}
 
開發者ID:erickok,項目名稱:ratebeer,代碼行數:17,代碼來源:PhotoActivity.java

示例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);
        }
    });

}
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:20,代碼來源:FavouriteProductFragment.java

示例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);
        }
    });

}
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:20,代碼來源:OwnProductFragment.java

示例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);
        }
    });
}
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:20,代碼來源:MakeupProductFragment.java

示例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);
        }
    });
}
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:20,代碼來源:ColorizeFaceActivity.java

示例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);
        }
    });
}
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:20,代碼來源:ProductRecommentationActivity.java

示例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);
        }
    });
}
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:20,代碼來源:ProfileActivity.java


注:本文中的com.squareup.picasso.NetworkPolicy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。