本文整理汇总了Java中com.squareup.picasso.MemoryPolicy类的典型用法代码示例。如果您正苦于以下问题:Java MemoryPolicy类的具体用法?Java MemoryPolicy怎么用?Java MemoryPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryPolicy类属于com.squareup.picasso包,在下文中一共展示了MemoryPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindViewHolder
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final LocalPhoto photo = data.get(position);
holder.attachPhoto(photo);
PicassoInstance.with()
.load(LocalPhoto.buildUriForPicasso(photo.getImageId()))
.tag(TAG)
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.placeholder(R.drawable.background_gray)
.into(holder.photoImageView);
resolveSelectionVisibility(photo, holder);
resolveIndexText(photo, holder);
View.OnClickListener listener = v -> {
if (clickListener != null) {
clickListener.onPhotoClick(holder, photo);
}
};
holder.photoImageView.setOnClickListener(listener);
holder.selectedRoot.setOnClickListener(listener);
}
示例2: onBindViewHolder
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
@Override
public void onBindViewHolder(Holder holder, int position) {
final LocalImageAlbum album = data.get(position);
Uri uri = LocalPhoto.buildUriForPicasso(album.getCoverImageId());
PicassoInstance.with()
.load(uri)
.tag(PICASSO_TAG)
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.placeholder(R.drawable.background_gray)
.into(holder.image);
holder.title.setText(album.getName());
holder.subtitle.setText(holder.itemView.getContext().getString(R.string.photos_count, album.getPhotoCount()));
holder.itemView.setOnClickListener(v -> {
if(clickListener != null){
clickListener.onClick(album);
}
});
}
示例3: updateImage
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
/**
* Update image path text and image views.
*/
private void updateImage() {
mImagePathText.setText(TextUtils.isEmpty(mImagePath) ? "-" : mImagePath);
if (TextUtils.isEmpty(mImagePath)) {
// if there is no selected image, load image placeholder
Picasso.with(getActivity())
.load(R.drawable.image_placeholder)
.into(mImageView);
} else {
// It is important to be very careful loading this image because it can be
// high resolution, very heavy and cause application memory problems
// (there is no danger of out of memory thanks to picasso)
Picasso.with(getActivity())
.load(new File(mImagePath))
.placeholder(R.drawable.image_placeholder)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.resize(IMAGE_MAX_WIDTH_PX, IMAGE_MAX_HEIGHT_PX)
.centerInside()
.onlyScaleDown()
.into(mImageView);
}
}
示例4: onActivityResult
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.e("请求码和结果码",requestCode + ".........." + resultCode);
if (requestCode == SELECT_PIC && resultCode == RESULT_OK) {
Log.e("onActivityResult方法", "执行了");
ArrayList<String> resultList = data.getStringArrayListExtra("resultList");
String imagePath = resultList.get(0);
Picasso.with(this)
.load(new File(imagePath))
.memoryPolicy(MemoryPolicy.NO_CACHE)
.resize(800, 600)
.centerCrop()
.error(R.drawable.place_holder)
.into(imageview);
}
}
示例5: instantiateItem
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
final View itemView = mLayoutInflater.inflate(R.layout.layout_image_slider_item, container, false);
ImageView imageView = (ImageView) itemView.findViewById(R.id.img_pager_slider);
Picasso.with(App.getContext()).
load(getUrl(position)).
error(R.drawable.ic_broken_image).
memoryPolicy(MemoryPolicy.NO_CACHE).
into(imageView, new Callback() {
@Override
public void onSuccess() {
itemView.findViewById(R.id.pb_fullscreen_loading).setVisibility(View.GONE);
}
@Override
public void onError() {
}
});
container.addView(itemView);
return itemView;
}
示例6: display
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
/**
* 单图展示
*
* @param url
*/
@Override
public void display(String url) {
mIvContent.setVisibility(View.VISIBLE);
mViewPager.setVisibility(View.GONE);
int w = mIvContent.getMeasuredWidth() > 0 ? mIvContent.getMeasuredWidth() : 400;
int h = mIvContent.getMeasuredHeight() > 0 ? mIvContent.getMeasuredHeight() : 400;
// TODO 根据需要调整
url = (url.indexOf(AppConsts.AppConfig.PATH_HTTP) != -1 || url.indexOf(AppConsts.AppConfig.PATH_HTTPS) != -1) ? url : AppConsts.AppConfig.PATH_FILE + url;
Picasso.with(getContext())
.load(url)
.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE)
.config(Bitmap.Config.RGB_565)
.resize(w, h)
.placeholder(R.drawable.pic_load)
.error(R.drawable.pic_load_error)
.centerInside()
.into(mIvContent);
}
示例7: callNextCycle
import com.squareup.picasso.MemoryPolicy; //导入依赖的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);
}
}
示例8: getView
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
ActivityData actD = arrayList.get(position);
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
convertView = inflater.inflate(R.layout.grid_layout_item, parent, false);
TextView tv = (TextView) convertView.findViewById(R.id.myImageViewText);
TextView dv = (TextView) convertView.findViewById(R.id.myImageViewDate);
ImageView iv = (ImageView) convertView.findViewById(R.id.myImageView);
if(tv != null) {
tv.setText(actD.getTitle());
iv.setImageResource(R.drawable.placeholder);
Long time = new Long((actD.getStartTime().toString()));
dv.setText(readableTimeStamp(time));
Picasso.with(context)
.load(actD.getImageUrl())
.noFade()
.memoryPolicy(MemoryPolicy.NO_CACHE)
.into(iv);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
}
return convertView;
}
示例9: newRelativeLayout
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
protected ImageView newRelativeLayout(final bind mBind, int size) {
ImageView imview = new ImageView(getActivity());
imview.setLayoutParams(findBoxWidth(mBind, size));
getPicassoClient()
.load(mBind.image)
.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE)
.into(imview);
imview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trigger_link(mBind);
}
});
imview.setScaleType(ImageView.ScaleType.CENTER_CROP);
return imview;
}
示例10: updateImage
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
private void updateImage(){
Picasso.with(this)
.load(currentPicture.getUrl())
//Reduces memory usage by 50%, we likely won't use images after refresh.
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.into(imageView, new Callback() {
@Override
public void onSuccess() {
Log.d("Succeeded", "Loaded image");
hideProgress();
}
@Override
public void onError() {
Log.d("Failed", "Didn't load image");
hideProgress();
}
});
}
示例11: loadImageBitmapFromDisk
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
/**
* Just like the loadImageBitmapFromMemory() method, we first call fetch() to load the image in our caches.
* In order to make sure this image does not come from the memory cache, we specifically set the request to ignore the memory cache with .memoryPolicy().
* This should result in 99% of the cases that the image loads from the disk cache.
*/
private void loadImageBitmapFromDisk() {
Picasso.with(context).load(UsageExampleListView.eatFoodyImages[1]).fetch(new Callback() {
@Override
public void onSuccess() {
Picasso
.with(context)
.load(UsageExampleListView.eatFoodyImages[1])
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.into(imageViewFromDisk);
}
@Override
public void onError() {
}
});
}
示例12: downloadImages
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
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();
}
}
}
示例13: picassoImplementation
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
public static void picassoImplementation(String u, final ImageView target, Context context, final Runnable callback) {
Picasso.with(context)
.load(u)
.memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE)
.into(target, new Callback() {
@Override
public void onSuccess() {
callback.run();
}
@Override
public void onError() {
}
});
}
示例14: onImagePickedFromDevice
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
@Override
protected void onImagePickedFromDevice(Uri imageUri, int requestCode) {
if (requestCode == REQUEST_PICK_AVATAR) {
with(getContext())
.load(imageUri)
.resize(MAX_WIDTH, 0)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
setAvatarBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
showAlert("Error", "Failed to load image");
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
}
}
示例15: onBind
import com.squareup.picasso.MemoryPolicy; //导入依赖的package包/类
@Override
public void onBind(ImageView view, String url) {
Picasso.with(view.getContext())
.load(url)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.into(view);
}