Created
June 20, 2012 19:27
-
-
Save Gowiem/2961698 to your computer and use it in GitHub Desktop.
FileManager class, which uses HashMaps as a Cache for [AutoUpdating]PreloadedFiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tapwalk.android.DataManagement; | |
import java.util.HashMap; | |
import java.util.Map; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Matt Gowie | |
* Date: 6/20/12 | |
* Time: 3:08 PM | |
*/ | |
public class FileManager { | |
private static Map<String, AutoUpdatingPreloadedFile> sAutoUpdatingFileManager | |
= new HashMap<String, AutoUpdatingPreloadedFile>(); | |
private static Map<String, PreloadedFile> sPreloadedFileManager | |
= new HashMap<String, PreloadedFile>(); | |
public static PreloadedFile preloadedFile(String filename){ | |
if(sPreloadedFileManager.containsKey(filename)){ // We have already created this file, get it from the cache | |
return sPreloadedFileManager.get(filename); | |
} else { // We have no yet created this file, create a new one. | |
PreloadedFile file = new PreloadedFile(filename); | |
sPreloadedFileManager.put(filename, file); | |
return file; | |
} | |
} | |
public static AutoUpdatingPreloadedFile autoUpdatingPreloadedFile(String filename, | |
String serverDirectoryUrl){ | |
if(sAutoUpdatingFileManager.containsKey(filename)){ // We have already created this file, get it from the cache | |
return sAutoUpdatingFileManager.get(filename); | |
} else { // We have no yet created this file, create a new one. | |
AutoUpdatingPreloadedFile file = new AutoUpdatingPreloadedFile(filename, serverDirectoryUrl); | |
sAutoUpdatingFileManager.put(filename, file); | |
return file; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment