简体   繁体   English

毕加索库如何在占位符/错误上使用转换

[英]Picasso library how to use transformation on placeholder/error

This is the code i use to display an image with picasso 这是我用来显示毕加索图像的代码

My problem is that when an album art can't be loaded, i use placeholder or error in picasso, but both don't use the transform option to also blur the image. 我的问题是,当无法加载专辑封面时,我在毕加索中使用占位符或错误,但是两者都不使用transform选项来模糊图像。 The image is only blurred when an album art is found. 仅当找到专辑封面时,图像才会模糊。

private void loadAlbumArt(){

    Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
    Uri albumArtUri = ContentUris.withAppendedId(sArtworkUri, songList.get(songIndex).getAlbumID());

    int[] myImageList = new int[]{R.drawable.image1, R.drawable.image2, R.drawable.image3,
            R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7 };

    Random random = new Random();
    int randomNumber = random.nextInt(myImageList.length);


    Picasso.with(getApplicationContext())
            .load(albumArtUri)
            .placeholder(myImageList[randomNumber])
            .transform(new BlurTransformation(getApplicationContext()))
            .noFade()
            .into(mAlbumArtLarge);

    Picasso.with(getApplicationContext())
            .load(albumArtUri)
            .placeholder(myImageList[randomNumber])
            .into(mAlbumArt);

}

Picasso does not allow placeholder and error resource transformations. 毕加索不允许进行占位符和错误资源转换。 See the answers here . 这里查看答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM