Code example for File

Methods: createTempFile

0
    } 
 
    public Drawable getDrawable(String source) {
        File output = null;
        try { 
            output = File.createTempFile("image", ".jpg", dir);
            InputStream is = fetch(source);
            if (is != null) {
                boolean success = FileUtils.save(output, is);
                if (success) {
                    Bitmap bitmap = ImageUtils.getBitmap(output, width, Integer.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 loading.getDrawable(source);