private Drawable requestRepositoryImage(final String source)
            throws IOException {
        if (TextUtils.isEmpty(source)) {
            return null;
        }

        Uri uri = Uri.parse(source);
        if (!HOST_DEFAULT.equals(uri.getHost())) {
            return null;
        }

        List<String> segments = uri.getPathSegments();
        if (segments.size() < 5) {
            return null;
        }

        String prefix = segments.get(2);
        // Two types of urls supported:
        // github.com/github/android/raw/master/app/res/drawable-xhdpi/app_icon.png
        // github.com/github/android/blob/master/app/res/drawable-xhdpi/app_icon.png?raw=true
        if (!("raw".equals(prefix) || ("blob".equals(prefix) && !TextUtils
                .isEmpty(uri.getQueryParameter("raw"))))) {
            return null;
        }

        String owner = segments.get(0);
        if (TextUtils.isEmpty(owner)) {
            return null;
        }
        String name = segments.get(1);
        if (TextUtils.isEmpty(name)) {
            return null;
        }
        String branch = segments.get(3);
        if (TextUtils.isEmpty(branch)) {
            return null;
        }

        StringBuilder path = new StringBuilder(segments.get(4));
        for (int i = 5; i < segments.size(); i++) {
            String segment = segments.get(i);
            if (!TextUtils.isEmpty(segment)) {
                path.append('/').append(segment);
            }
        }

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

        Content contents = ServiceGenerator.createService(context, RepositoryContentService.class)
                .getContents(owner, name, path.toString(), branch)
                .blockingGet()
                .body();

        if (contents.content() != null) {
            byte[] content = Base64.decode(contents.content(), DEFAULT);
            Bitmap bitmap = ImageUtils.getBitmap(content, width, MAX_VALUE);
            if (bitmap == null) {
                return loading.getDrawable(source);
            }
            BitmapDrawable drawable = new BitmapDrawable(
                    context.getResources(), bitmap);
            drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
            return drawable;
        } else {
            return null;
        }
    }
Request an image using the contents API if the source URI is a path to a
file already in the repository

@param source
@return
@throws IOException
app/src/main/java/com/github/pockethub/android/util/HttpImageGetter.java