public static Building factory(String buildingName, String path) { Log.d(TAG, "building factory: " + buildingName + ", " + path); Building retval = null; retval = Building.fromXml(path + "/" + buildingName + ".xml"); if (retval == null) retval = new EmptyBuilding(); retval.optimize(); return retval; }
private static Building loadFromXmlAndCache(String name, File cache) { Building retval = Building.fromXml(name); retval.areaChanged(1); retval.optimize(); try { Building.saveToCache(retval, cache); } catch (IOException e) { Log.e(TAG, "failed to save building to cache"); e.printStackTrace(); } return retval; }
private static Building tryToLoadFromCache(File cache) { Building retval = null; try { if (cache.exists()) { long timestamp = System.nanoTime(); Log.d(TAG, "started loading building from cache"); retval = Building.fromCache(cache); Log.d( TAG, "building loaded from cache in " + (double) (System.nanoTime() - timestamp) / Math.pow(10, 9)); } } catch (IOException e) { Log.e(TAG, "failed to load building from cache"); e.printStackTrace(); } catch (ClassNotFoundException e) { Log.e(TAG, "failed to load building from cache"); e.printStackTrace(); } return retval; }