Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

VirtualViewApplication.ImageTarget.onBitmapLoaded中mImageBase可能为空 #68

Open
Rysle opened this issue May 17, 2018 · 0 comments
Open

Comments

@Rysle
Copy link

Rysle commented May 17, 2018

private static class ImageTarget implements Target {

    ImageBase mImageBase;

    Listener mListener;

    public ImageTarget(ImageBase imageBase) {
        mImageBase = imageBase;
    }

    public ImageTarget(Listener listener) {
        mListener = listener;
    }

    @Override
    public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
        mImageBase.setBitmap(bitmap, true); <<<<<<<<<----------- HERE
        if (mListener != null) {
            mListener.onImageLoadSuccess(bitmap);
        }
        Log.d("VirtualViewApplication", "onBitmapLoaded " + from);
    }

    ...
}

使用的地方:
VirtualViewApplication.onCreate()

        sVafContext.setImageLoaderAdapter(new IImageLoaderAdapter() {

            private List<ImageTarget> cache = new ArrayList<ImageTarget>();

            @Override
            public void getBitmap(String uri, int reqWidth, int reqHeight, final Listener lis) {
                RequestCreator requestCreator = Picasso.with(VirtualViewApplication.this).load(uri);
                Log.d("VirtualViewApplication", "getBitmap request width height " + reqHeight + " " + reqWidth);
                if (reqHeight > 0 || reqWidth > 0) {
                    requestCreator.resize(reqWidth, reqHeight);
                }
                ImageTarget imageTarget = new ImageTarget(lis);  <<<<<<<<<----------- HERE
                cache.add(imageTarget);
                requestCreator.into(imageTarget);
            }
        });
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant