Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.webimageloader;
  
  import java.io.File;
  import java.util.EnumSet;
  
  import android.net.Uri;
  
Class describing a specific request including transformations to be applied.

Author(s):
Alexander Blom <alexanderblom.se>
 
 public class Request {
     public enum Flag {
        
Flag which makes the request ignore any possibly cached bitmaps
 
         IGNORE_CACHE,
        
Flag which makes the request don't save its result to cache
 
         NO_CACHE,
        
Flag for skipping the disk cache, both for retrieval and storing, useful for images already fetched from disk.
 
         SKIP_DISK_CACHE
     }
 
     private String url;
     private Transformation transformation;
     private EnumSet<Flagflags = EnumSet.noneOf(Flag.class);

    
Create a request for a resource in /res. Note that this sets the SKIP_DISK_CACHE to skip disk cache

Parameters:
c the context to use
resId the resource if
Returns:
a request for this resource
 
     public static Request forResource(Context cint resId) {
         String url = createUrl(.c.getPackageName(), String.valueOf(resId));
         return new Request(url).addFlag(.);
     }

    
Create a request for an asset in /assets. Note that this sets the SKIP_DISK_CACHE to skip disk cache

Parameters:
path the path of this asset
Returns:
a request for this asset
 
     public static Request forAsset(String path) {
         String url = createUrl(."/android_asset/"path);
         return new Request(url).addFlag(.);
     }

    
Create a request for this file on the local file system. Note that this sets the SKIP_DISK_CACHE to skip disk cache

Parameters:
file path to the file
Returns:
a request for this file
 
     public static Request forFile(File file) {
         String url = Uri.fromFile(file).toString();
         return new Request(url).addFlag(.);
     }

    
Constructor for a specific url

Parameters:
url the url
 
     public Request(String url) {
         this. = url;
     }

    
Constructor for a specific url and transformation

Parameters:
url the url
transformation the transformation
 
     public Request(String urlTransformation transformation) {
         this. = url;
         this. = transformation;
     }
 
     public String getUrl() {
        return ;
    }
    public Transformation getTransformation() {
        return ;
    }

    
Create a new request with an added transformation

Deprecated:
Use setTransformation(com.webimageloader.transformation.Transformation) instead
Parameters:
transformation the transformation to apply
Returns:
the new request
    @Deprecated
    public Request withTransformation(Transformation transformation) {
        return new Request(transformation);
    }

    
Set the transformation of this request

Parameters:
transformation the transformation to apply
Returns:
this request
    public Request setTransformation(Transformation transformation) {
        this. = transformation;
        return this;
    }

    
Add a flag to this request

Parameters:
flag the flag to be added
Returns:
this request
    public Request addFlag(Flag flag) {
        .add(flag);
        return this;
    }

    
Add multiple flags to this request

Parameters:
flags the flags to be added
Returns:
this request
    public Request addFlags(EnumSet<Flagflags) {
        this..addAll(flags);
        return this;
    }
        return new LoaderRequest();
    }
    private static String createUrl(String schemeString authorityString path) {
        return scheme + "://" + authority + "/" + path;
    }
New to GrepCode? Check out our FAQ X