Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }