Skip to content

Instantly share code, notes, and snippets.

@leruaa
Last active August 29, 2015 14:00
Show Gist options
  • Save leruaa/be1f27db68391b5463c6 to your computer and use it in GitHub Desktop.
Save leruaa/be1f27db68391b5463c6 to your computer and use it in GitHub Desktop.
A FileHandleResolver implementation witch tests if requested file exists in a path starting with an additional folder. This can be useful when using android flavors.
import com.badlogic.gdx.assets.loaders.FileHandleResolver;
import com.badlogic.gdx.files.FileHandle;
public class DualFileHandleResolver implements FileHandleResolver {
private FileHandleResolver baseResolver;
private String additionalAssetsPath;
public DualFileHandleResolver(FileHandleResolver baseResolver, String additionalAssetsPath) {
this.baseResolver = baseResolver;
this.additionalAssetsPath = additionalAssetsPath;
}
@Override
public FileHandle resolve(String fileName) {
FileHandle handle = baseResolver.resolve(String.format("%s/%s", additionalAssetsPath, fileName));
return handle.exists() ? handle : baseResolver.resolve(fileName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment