Android Open Source - RecyclingImageLoader Image File Cache






From Project

Back to project page RecyclingImageLoader.

License

The source code is released under:

Apache License

If you think the Android project RecyclingImageLoader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright 2013 hellosky ye/* www. jav a 2  s . com*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.hellosky.recyclingimageloader.util;

import java.io.File;

import android.content.Context;

public class ImageFileCache {
  
  private File cacheDir;  
    
    public ImageFileCache(Context context) {  
        //check SDCard and create file diretory
        if (android.os.Environment.getExternalStorageState().equals(  
                android.os.Environment.MEDIA_MOUNTED))  
            cacheDir = new File(  
                    android.os.Environment.getExternalStorageDirectory(),  
                    "iLazyList");  
        else  
            cacheDir = context.getCacheDir();  
        if (!cacheDir.exists())  
            cacheDir.mkdirs();  
    }  
  
    public File getFile(String url) {  
        String filename = String.valueOf(url.hashCode());  
        File f = new File(cacheDir, filename);  
        return f;  
  
    }  
  
    public void clear() {  
        File[] files = cacheDir.listFiles();  
        if (files == null)  
            return;  
        for (File f : files)  
            f.delete();  
    }  
}




Java Source Code List

com.hellosky.recyclingimageloader.ImageDetailActivity.java
com.hellosky.recyclingimageloader.ImageDetailFragment.java
com.hellosky.recyclingimageloader.ImageGridActivity.java
com.hellosky.recyclingimageloader.ImageGridFragment.java
com.hellosky.recyclingimageloader.Images.java
com.hellosky.recyclingimageloader.SampleActivity.java
com.hellosky.recyclingimageloader.util.ImageFileCache.java
com.hellosky.recyclingimageloader.util.ImageLoader.java
com.hellosky.recyclingimageloader.util.ImageMemoryCache.java
com.hellosky.recyclingimageloader.util.RecyclingBitmapDrawable.java
com.hellosky.recyclingimageloader.util.Utils.java