UsageExamplePicassoBuilderRequestHandler.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:android-tutorials-picasso 作者:
@Override
public Result load(Request request, int networkPolicy) throws IOException {
    // do whatever is necessary here to load the image
    // important: you can only return a Result object
    // the constructor takes either a Bitmap or InputStream object, nothing else!

    // get the key for the requested image
    // if the schema is "eatfoody://cupcake", it'd return "cupcake"
    String imageKey = request.uri.getHost();

    Bitmap bitmap;
    if (imageKey.contentEquals("cupcake")) {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.cupcake);
    }
    else if (imageKey.contentEquals("full_cake")) {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.full_cake);
    }
    else {
        // fallback image
        bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    }

    // return the result with the bitmap and the source info
    return new Result(bitmap, Picasso.LoadedFrom.DISK);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号