com.squareup.picasso.RequestHandler Java Examples

The following examples show how to use com.squareup.picasso.RequestHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageRequestHandler.java    From cathode with Apache License 2.0 6 votes vote down vote up
@Override public RequestHandler.Result load(Request request, int networkPolicy)
    throws IOException {
  final String baseUrl = getBaseUrl();
  if (TextUtils.isEmpty(baseUrl)) {
    return null;
  }

  String path = transform(request, request.uri);

  if (TextUtils.isEmpty(path)) {
    return null;
  }

  Downloader.Response response = downloader.load(Uri.parse(path), networkPolicy);
  if (response == null) {
    return null;
  }

  InputStream is = response.getInputStream();
  if (is == null) {
    return null;
  }

  return new RequestHandler.Result(is, Picasso.LoadedFrom.NETWORK);
}