Android Open Source - PictureBookReader File Cache






From Project

Back to project page PictureBookReader.

License

The source code is released under:

GNU General Public License

If you think the Android project PictureBookReader 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

package net.uyghurdev.avaroid.picturebookreader;
//  w  w  w. j av  a 2s.c  o m
import java.io.File;

import android.content.Context;

public class FileCache {
  private File cacheDir;

  public FileCache(Context context) {
    // Find the dir to save cached images
    if (android.os.Environment.getExternalStorageState().equals(
        android.os.Environment.MEDIA_MOUNTED))
      cacheDir = new File(
          android.os.Environment.getExternalStorageDirectory(),
          Configs.SDPathIm);
    else
      cacheDir = context.getCacheDir();
    // cacheDir = new File(Configs.ThumbFolder);
    if (!cacheDir.exists())
      cacheDir.mkdirs();
  }

  public File getFile(String url) {
    // I identify images by hashcode. Not a perfect solution, good for the
    // demo.
    String filename;
    // if(url.contains(".")){
    // filename=String.valueOf(url.hashCode()) +
    // url.substring(url.lastIndexOf('.'));
    // }else{
    filename = String.valueOf(url.hashCode());
    // }
    File f = new File(cacheDir, filename);
    return f;

  }

  public void clear() {
    // File[] files=cacheDir.listFiles();
    // for(File f:files)
    // f.delete();
  }
}




Java Source Code List

net.uyghurdev.avaroid.picturebookreader.About.java
net.uyghurdev.avaroid.picturebookreader.BookText.java
net.uyghurdev.avaroid.picturebookreader.Book.java
net.uyghurdev.avaroid.picturebookreader.BookmarkData.java
net.uyghurdev.avaroid.picturebookreader.Configs.java
net.uyghurdev.avaroid.picturebookreader.CurlMesh.java
net.uyghurdev.avaroid.picturebookreader.CurlPage.java
net.uyghurdev.avaroid.picturebookreader.CurlRenderer.java
net.uyghurdev.avaroid.picturebookreader.CurlView.java
net.uyghurdev.avaroid.picturebookreader.DecompressReader.java
net.uyghurdev.avaroid.picturebookreader.Decompresser.java
net.uyghurdev.avaroid.picturebookreader.DownloadFile.java
net.uyghurdev.avaroid.picturebookreader.FileCache.java
net.uyghurdev.avaroid.picturebookreader.GetOnlineBookInfo.java
net.uyghurdev.avaroid.picturebookreader.ImageLoader.java
net.uyghurdev.avaroid.picturebookreader.JSONManager.java
net.uyghurdev.avaroid.picturebookreader.LocalBook.java
net.uyghurdev.avaroid.picturebookreader.MemoryCache.java
net.uyghurdev.avaroid.picturebookreader.NetWorkOperator.java
net.uyghurdev.avaroid.picturebookreader.OnlineBookAdapter.java
net.uyghurdev.avaroid.picturebookreader.OnlineBooks.java
net.uyghurdev.avaroid.picturebookreader.OnlineGBookAdapter.java
net.uyghurdev.avaroid.picturebookreader.PlayOrder1.java
net.uyghurdev.avaroid.picturebookreader.ReadBook.java
net.uyghurdev.avaroid.picturebookreader.RecentBooksAdapter.java
net.uyghurdev.avaroid.picturebookreader.RecentGBooksAdapter.java
net.uyghurdev.avaroid.picturebookreader.Splash.java
net.uyghurdev.avaroid.picturebookreader.Utils.java
net.uyghurdev.avaroid.picturebookreader.XMLContent.java
net.uyghurdev.avaroid.picturebookreader.XMLHandler.java