// Path: src/com/blochstech/bitcoincardterminal/Utils/ResourceHolder.java
// public class ResourceHolder {
// 	//private Object lockKey; Usually as key in hashmap or unnecessary.
// 	private Object holder;
// 	private Thread holdingThread;
// 	
// 	//public Object LockKey(){ return lockKey; } //The value or resource being locked upon.
// 	public Object Holder(){ return holder; } //The object with access (only for extra restrictive cases).
// 	public Thread HoldingThread(){ return holdingThread; } //The thread that has the lock, re-entry should generally be allowed.
// 	
// 	public ResourceHolder(Object holder, Thread holdingThread){
// 		//this.lockKey = lockKey;
// 		this.holder = holder;
// 		this.holdingThread = holdingThread;
// 	}
// 	public ResourceHolder(Object holder){
// 		//this.lockKey = lockKey;
// 		this.holder = holder;
// 		this.holdingThread = Thread.currentThread();
// 	}
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/SyntacticSugar.java
// public class SyntacticSugar {
// 	@SuppressWarnings("unchecked")
// 	public static <T> T castAs(Object castee){
// 		try{
// 			return (T) castee;
// 		}catch(Exception ex){
// 			return null;
// 		}
// 	}
// 	
// 	public static boolean EqualWithinMargin(Double value1, Double value2, Double margin){
// 		return value1 * (1+margin) >= value2 && value2 * (1+margin) >= value1;
// 	}
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/Tags.java
// public class Tags {
// 	//Set this to false when building to Google Play app store.
// 	public static final boolean DEBUG = false;
// 	
// 	public static final String APP_TAG = "BitcoinCardTerminal";
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import android.os.Environment;
import android.util.Log;
import com.blochstech.bitcoincardterminal.Utils.ResourceHolder;
import com.blochstech.bitcoincardterminal.Utils.SyntacticSugar;
import com.blochstech.bitcoincardterminal.Utils.Tags;
	        {
	        	dir.mkdirs();
	        }
	        if(!dir.exists())
	        	throw new Exception("Getting directory failed. Path: " + FileCachePath);
	        
	        File file = new File(FileCachePath);
	        if(file == null || !file.exists())
		        SaveFileValue(initialValue);
		}catch(Exception ex)
		{
			throw ex;
		}
    }
	
	private T GetFileValue() throws Exception //Use generics and Xml serilization in the future save any value
    {
        boolean fail = true;
        long startTry = System.currentTimeMillis();
        while (fail) {
            fail = false;
            try
            {
            	File file = new File(FileCachePath);
            	FileInputStream fis = new FileInputStream(file);
				ObjectInputStream ois = new ObjectInputStream(fis);
            	Object readObj = ois.readObject();
            	ois.close();
            	fis.close();
            	
// Path: src/com/blochstech/bitcoincardterminal/Utils/ResourceHolder.java
// public class ResourceHolder {
// 	//private Object lockKey; Usually as key in hashmap or unnecessary.
// 	private Object holder;
// 	private Thread holdingThread;
// 	
// 	//public Object LockKey(){ return lockKey; } //The value or resource being locked upon.
// 	public Object Holder(){ return holder; } //The object with access (only for extra restrictive cases).
// 	public Thread HoldingThread(){ return holdingThread; } //The thread that has the lock, re-entry should generally be allowed.
// 	
// 	public ResourceHolder(Object holder, Thread holdingThread){
// 		//this.lockKey = lockKey;
// 		this.holder = holder;
// 		this.holdingThread = holdingThread;
// 	}
// 	public ResourceHolder(Object holder){
// 		//this.lockKey = lockKey;
// 		this.holder = holder;
// 		this.holdingThread = Thread.currentThread();
// 	}
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/SyntacticSugar.java
// public class SyntacticSugar {
// 	@SuppressWarnings("unchecked")
// 	public static <T> T castAs(Object castee){
// 		try{
// 			return (T) castee;
// 		}catch(Exception ex){
// 			return null;
// 		}
// 	}
// 	
// 	public static boolean EqualWithinMargin(Double value1, Double value2, Double margin){
// 		return value1 * (1+margin) >= value2 && value2 * (1+margin) >= value1;
// 	}
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/Tags.java
// public class Tags {
// 	//Set this to false when building to Google Play app store.
// 	public static final boolean DEBUG = false;
// 	
// 	public static final String APP_TAG = "BitcoinCardTerminal";
// }


// Path: src/com/blochstech/bitcoincardterminal/DataLayer/GenericFileCache.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import android.os.Environment;
import android.util.Log;
import com.blochstech.bitcoincardterminal.Utils.ResourceHolder;
import com.blochstech.bitcoincardterminal.Utils.SyntacticSugar;
import com.blochstech.bitcoincardterminal.Utils.Tags;

	        {
	        	dir.mkdirs();
	        }
	        if(!dir.exists())
	        	throw new Exception("Getting directory failed. Path: " + FileCachePath);
	        
	        File file = new File(FileCachePath);
	        if(file == null || !file.exists())
		        SaveFileValue(initialValue);
		}catch(Exception ex)
		{
			throw ex;
		}
    }
	
	private T GetFileValue() throws Exception //Use generics and Xml serilization in the future save any value
    {
        boolean fail = true;
        long startTry = System.currentTimeMillis();
        while (fail) {
            fail = false;
            try
            {
            	File file = new File(FileCachePath);
            	FileInputStream fis = new FileInputStream(file);
				ObjectInputStream ois = new ObjectInputStream(fis);
            	Object readObj = ois.readObject();
            	ois.close();
            	fis.close();
            	
            	return SyntacticSugar.<T>castAs(readObj);