* AndroidAssetManager will avoid registering loaders if the class isn't in the classpath similar to DesktopAssetManager

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9203 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent 1aed2068be
commit df212d358f
  1. 51
      engine/src/android/com/jme3/asset/AndroidAssetManager.java

@ -37,6 +37,7 @@ import com.jme3.audio.plugins.AndroidAudioLoader;
import com.jme3.texture.Texture;
import com.jme3.texture.plugins.AndroidImageLoader;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
@ -58,6 +59,14 @@ public class AndroidAssetManager extends DesktopAssetManager {
this(null);
}
private void registerLoaderSafe(Class<? extends AssetLoader> loaderClass, String ... extensions) {
try {
registerLoader(loaderClass, extensions);
} catch (Exception e){
logger.log(Level.WARNING, "Failed to load AssetLoader", e);
}
}
/**
* AndroidAssetManager constructor
* If URL == null then a default list of locators and loaders for android is set
@ -67,25 +76,29 @@ public class AndroidAssetManager extends DesktopAssetManager {
System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
// Set Default Android config
this.registerLocator("", AndroidLocator.class);
this.registerLocator("", ClasspathLocator.class);
this.registerLoader(AndroidImageLoader.class, "jpg", "bmp", "gif", "png", "jpeg");
this.registerLoader(AndroidAudioLoader.class, "ogg", "mp3", "wav");
this.registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3m");
this.registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3md");
this.registerLoader(com.jme3.font.plugins.BitmapFontLoader.class, "fnt");
this.registerLoader(com.jme3.texture.plugins.DDSLoader.class, "dds");
this.registerLoader(com.jme3.texture.plugins.PFMLoader.class, "pfm");
this.registerLoader(com.jme3.texture.plugins.HDRLoader.class, "hdr");
this.registerLoader(com.jme3.texture.plugins.TGALoader.class, "tga");
this.registerLoader(com.jme3.export.binary.BinaryImporter.class, "j3o");
this.registerLoader(com.jme3.scene.plugins.OBJLoader.class, "obj");
this.registerLoader(com.jme3.scene.plugins.MTLLoader.class, "mtl");
this.registerLoader(com.jme3.scene.plugins.ogre.MeshLoader.class, "meshxml", "mesh.xml");
this.registerLoader(com.jme3.scene.plugins.ogre.SkeletonLoader.class, "skeletonxml", "skeleton.xml");
this.registerLoader(com.jme3.scene.plugins.ogre.MaterialLoader.class, "material");
this.registerLoader(com.jme3.scene.plugins.ogre.SceneLoader.class, "scene");
this.registerLoader(com.jme3.shader.plugins.GLSLLoader.class, "vert", "frag", "glsl", "glsllib");
registerLocator("", AndroidLocator.class);
registerLocator("", ClasspathLocator.class);
registerLoader(AndroidImageLoader.class, "jpg", "bmp", "gif", "png", "jpeg");
registerLoader(AndroidAudioLoader.class, "ogg", "mp3", "wav");
registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3m");
registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3md");
registerLoader(com.jme3.shader.plugins.GLSLLoader.class, "vert", "frag", "glsl", "glsllib");
registerLoader(com.jme3.export.binary.BinaryImporter.class, "j3o");
registerLoader(com.jme3.font.plugins.BitmapFontLoader.class, "fnt");
// Less common loaders (especially on Android)
registerLoaderSafe(com.jme3.texture.plugins.DDSLoader.class, "dds");
registerLoaderSafe(com.jme3.texture.plugins.PFMLoader.class, "pfm");
registerLoaderSafe(com.jme3.texture.plugins.HDRLoader.class, "hdr");
registerLoaderSafe(com.jme3.texture.plugins.TGALoader.class, "tga");
registerLoaderSafe(com.jme3.scene.plugins.OBJLoader.class, "obj");
registerLoaderSafe(com.jme3.scene.plugins.MTLLoader.class, "mtl");
registerLoaderSafe(com.jme3.scene.plugins.ogre.MeshLoader.class, "mesh.xml");
registerLoaderSafe(com.jme3.scene.plugins.ogre.SkeletonLoader.class, "skeleton.xml");
registerLoaderSafe(com.jme3.scene.plugins.ogre.MaterialLoader.class, "material");
registerLoaderSafe(com.jme3.scene.plugins.ogre.SceneLoader.class, "scene");
logger.info("AndroidAssetManager created.");
}

Loading…
Cancel
Save