java类com.squareup.picasso.MemoryPolicy的实例源码

LocalPhotosAdapter.java 文件源码 项目:Phoenix-for-VK 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
LocalPhotoAlbumsAdapter.java 文件源码 项目:Phoenix-for-VK 阅读 22 收藏 0 点赞 0 评论 0
@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);
        }
    });
}
EditDocCoverDialog.java 文件源码 项目:foco 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
PicturePickerActivity.java 文件源码 项目:MyRepository 阅读 26 收藏 0 点赞 0 评论 0
@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);

    }

}
ImageSliderAdapter.java 文件源码 项目:onliner_old 阅读 24 收藏 0 点赞 0 评论 0
@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;
}
ImageDetailPresenter.java 文件源码 项目:yApp 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 单图展示
 *
 * @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);
}
ImageShading.java 文件源码 项目:BitFrames 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }
}
ActivitiesAdapter.java 文件源码 项目:studdyDokky 阅读 32 收藏 0 点赞 0 评论 0
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;

}
template_automatic_ll.java 文件源码 项目:KickAssSlidingMenu 阅读 22 收藏 0 点赞 0 评论 0
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;
}
template_automatic_ll.java 文件源码 项目:KickAssSlidingMenu 阅读 31 收藏 0 点赞 0 评论 0
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;
}
MainActivity.java 文件源码 项目:NAPOD 阅读 20 收藏 0 点赞 0 评论 0
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();
                }
            });
}
UsageExampleLoggingAndStats.java 文件源码 项目:android-tutorials-picasso 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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() {

        }
    });
}
PullImageController.java 文件源码 项目:dhis2-android-dashboard 阅读 25 收藏 0 点赞 0 评论 0
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();
        }

    }
}
LoyalUtil.java 文件源码 项目:LoyalNativeSlider 阅读 25 收藏 0 点赞 0 评论 0
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() {

                }
            });
}
UserManagementFragment.java 文件源码 项目:getsocial-android-sdk 阅读 28 收藏 0 点赞 0 评论 0
@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) {

                    }
                });
    }
}
PicassoOnBind.java 文件源码 项目:Witch-Android 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void onBind(ImageView view, String url) {
    Picasso.with(view.getContext())
            .load(url)
            .memoryPolicy(MemoryPolicy.NO_CACHE)
            .into(view);
}
NetworkUtil.java 文件源码 项目:TPondof 阅读 27 收藏 0 点赞 0 评论 0
public static RequestCreator buildPicasso (Context context, String url) {
    return Picasso.with(context)
            .load(url)
            .placeholder(R.mipmap.ic_avatar)
            .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
            .error(R.mipmap.ic_avatar);
}
NetworkUtil.java 文件源码 项目:TPondof 阅读 29 收藏 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;
    }
}
CameraFragment.java 文件源码 项目:SjekkUT 阅读 27 收藏 0 点赞 0 评论 0
private void onPictureSaved(String photoPath) {
    mCapturedPhotoPath = photoPath;
    setAcceptPanelVisible();
    mCameraView.stop();
    Picasso.with(getContext())
            .load(new File(mCapturedPhotoPath))
            .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
            .placeholder(null)
            .into(mPreview);
}
PicassoImageLoader.java 文件源码 项目:GalleryFinal-master 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void displayImage(Activity activity, String path, GFImageView imageView, Drawable defaultDrawable, int width, int height) {
    Picasso.with(activity)
            .load(new File(path))
            .placeholder(defaultDrawable)
            .error(defaultDrawable)
            .config(mConfig)
            .resize(width, height)
            .centerInside()
            .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
            .into(imageView);
}
PicassoBinding.java 文件源码 项目:AndroidAgeraTutorial 阅读 22 收藏 0 点赞 0 评论 0
@BindingAdapter({"compressImageUrl"})
    public static void loadImageCompress(ImageView imageView, String url) {
        //large -> b middle
//        Picasso.Builder builder = new Picasso.Builder(imageView.getContext().getApplicationContext());
//        builder.listener(new Picasso.Listener() {
//            @Override
//            public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
//                exception.printStackTrace();
//                Log.e("Picasso Error", uri.toString());
//            }
//        });
        //recycle bitmap
//        Drawable drawable = imageView.getDrawable();
//        if (drawable instanceof BitmapDrawable) {
//            imageView.setImageDrawable(null);
//            Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
//            Log.d(TAG, "recycle bitmap, w:" + bitmap.getWidth() + ", h:" + bitmap.getHeight());
//            bitmap.recycle();
//        }
        Picasso.with(imageView.getContext().getApplicationContext())
                .load(url)
                .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
                .placeholder(R.drawable.ic_image_load_place_holder)
                .config(Bitmap.Config.RGB_565)
                .tag(PicassoOnScrollListener.TAG)
                .into(imageView);
    }
PicassoUtil.java 文件源码 项目:XiZiQuan 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 加载高清大图是不需要缓存时使用该方法不缓存改,
 * 减少对内存的消耗,可以加快对内存的回收,防止内存溢出
 *
 * @param context   context
 * @param url       url
 * @param imageView ImageView
 */
public static void downBigImage(Context context, String url, ImageView imageView) {
    Picasso.with(context).setIndicatorsEnabled(idDebug);
    Picasso.with(context)
            .load(url)
            .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
            .placeholder(R.mipmap.ic_launcher)  //图片占位符
            .error(R.mipmap.ic_launcher)    //图片加载失败是加载的图片
            .into(imageView);
}
StripRemoteDataSource.java 文件源码 项目:commitstrip-reader 阅读 28 收藏 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);
    }
}
ImageShading.java 文件源码 项目:BitFrames 阅读 26 收藏 0 点赞 0 评论 0
void mapUnframedImages(List<BeanImage> beanImages, List<UnframedPicassoTargetNew> targets){
    totalImages = beanImages.size();
    this.targets = targets;
    if(totalImages > frameModel.getMaxFrameCount() && frameModel.isShouldSortImages()){
        //sort image a/c to primary and secondary value
        Collections.sort(beanImages);
    }
    this.beanImages.addAll(beanImages);
    unframedImageCounter = 0;
    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);

    }
}
ImageUtils.java 文件源码 项目:Unificiency 阅读 29 收藏 0 点赞 0 评论 0
public static void downloadToImageView(Context context, String imageUrl, ImageView imageView){
  Picasso.with(context)
      .load(baseUrl + imageUrl)
      .memoryPolicy(MemoryPolicy.NO_CACHE)
      .networkPolicy(NetworkPolicy.NO_CACHE)
      .placeholder(R.drawable.placeholder)
      .error(R.drawable.error_loading)
      .into(imageView);
}
PicassoImageLoader.java 文件源码 项目:ImagePicker 阅读 27 收藏 0 点赞 0 评论 0
@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
    Picasso.with(activity)//
            .load(Uri.fromFile(new File(path)))//
            .placeholder(R.drawable.ic_default_image)//
            .error(R.drawable.ic_default_image)//
            .resize(width, height)//
            .centerInside()//
            .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)//
            .into(imageView);
}
PicassoImageLoader.java 文件源码 项目:ImagePicker 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
    Picasso.with(activity)//
            .load(Uri.fromFile(new File(path)))//
            .resize(width, height)//
            .centerInside()//
            .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)//
            .into(imageView);
}
AirportFragment.java 文件源码 项目:AirportCodes-Android 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void refreshView(final Airport airport)
{
    getActivity().supportInvalidateOptionsMenu();

    Picasso.with(getActivity())
            .load(airport.imageLarge)
            .networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE)
            .memoryPolicy(MemoryPolicy.NO_STORE, MemoryPolicy.NO_CACHE)
            .into(iv);

    tvCode.setText(airport.code);
    tvName.setText(airport.name);
    tvDescription.setText(applyMarkdown(airport.description));

    String location = airport.city;
    if(!TextUtils.isEmpty(airport.stateShort))
        location += ", " + airport.stateShort;
    location += " - " + airport.country;
    tvLocation.setText(location);

    String photoBy = "photo by ";
    SpannableStringBuilder imageCredit = new SpannableStringBuilder(photoBy);
    imageCredit.append(airport.imageCredit);
    imageCredit.setSpan(new StyleSpan(Typeface.BOLD), photoBy.length(), imageCredit.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    tvImageCredit.setText(imageCredit);
    tvImageCredit.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            IntentUtils.goToUrl(getActivity(), airport.imageCreditLink);
        }
    });

    getToolbar().setTitle(airport.code.toUpperCase());
    getToolbar().setSubtitle(airport.city);
}
UsageExampleLoggingAndStats.java 文件源码 项目:android-tutorials-picasso 阅读 24 收藏 0 点赞 0 评论 0
/**
 * This method forces the image to be loaded from the network by skipping the caches.
 */
private void loadImageBitmapFromNetwork() {
    Picasso
            .with(context)
            .load(UsageExampleListView.eatFoodyImages[2])
            .memoryPolicy(MemoryPolicy.NO_CACHE)
            .networkPolicy(NetworkPolicy.NO_CACHE)
            .into(imageViewFromNetwork);
}
ImageViewFragment.java 文件源码 项目:dhis2-android-dashboard 阅读 23 收藏 0 点赞 0 评论 0
@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);
}


问题


面经


文章

微信
公众号

扫码关注公众号