Class ImageFetcher


  • public class ImageFetcher
    extends java.lang.Object

    Package Starting Point



    • Method Detail

      • initService

        public static void initService​(Context context,
                                       IInFlightCallback inFlightCallback,
                                       InFlight inFlight)
        Initialize a ImageFetcher object and return the object with the IInFlightCallback.
        Parameters:
        context - : provide a Context to initialize the object.
        inFlightCallback - : IInFlightCallback will be used to return the instance or providing the error message.
        inFlight - : provide an InFlight instance to initialize
      • getImageByImageInfo

        public RequestImage getImageByImageInfo​(ImageInfo imageInfo,
                                                ImageFetcher.onImageReceivedListener onImageReceivedListener)
        Fetch a RequestImage object with methods to request media image specified by a Image Uri.
        Parameters:
        imageInfo -
        onImageReceivedListener - ImageFetcher.onImageReceivedListener - this callback will be invoked in the context of calling thread.
        Returns:
        RequestImage - which provide methods to execute asynchronously, cancel the request.
        Example:
         mInflight = new InFlight();
         mInflight.initService(activity,
                InFlightServices.IMAGE_FETCHER_SERVICE,
                serviceInstanceId, inflightCallbackListener);
         

        public void onInitServiceComplete(Object arg0,String serviceName) { if(serviceName.equals(InFlightServices.IMAGE_FETCHER_SERVICE.getServiceName())) { mMetadata = (Metadata) arg0; RequestMediaMetaImage request = mMetadata.getImageByImageInfo( editTextUri.getText().toString(), new ImageFetcher.onImageReceivedListener() { @Override public void onImageReceived(final Bitmap bitmap,Request request) { String log = "onImageReceived() : request time: " + (System.currentTimeMillis() - timeStamp) + ", image size: (" + bitmap.getWidth() + ", " + bitmap.getHeight() + ")"; Log.v(TAG, log); updateLogs(log); imageViewBitmap.setImageBitmap(bitmap); } }); if (request != null) { request.executeAsync(); timeStamp = System.currentTimeMillis(); } else { Toast.makeText(MetadataTestActivity.this, "request is null", Toast.LENGTH_LONG).show(); } } }