Example usage for com.badlogic.gdx.files FileHandle lastModified

List of usage examples for com.badlogic.gdx.files FileHandle lastModified

Introduction

In this page you can find the example usage for com.badlogic.gdx.files FileHandle lastModified.

Prototype

public long lastModified() 

Source Link

Document

Returns the last modified time in milliseconds for this file.

Usage

From source file:com.agateau.pixelwheels.tools.MapScreenshotGenerator.java

License:Apache License

private static boolean isOutdated(FileHandle dst, FileHandle src) {
    return dst.lastModified() < src.lastModified();
}

From source file:com.esotericsoftware.spine.SkeletonViewer.java

License:Open Source License

void loadSkeleton(FileHandle skeletonFile, boolean reload) {
    if (skeletonFile == null)
        return;/*from   www.ja  v  a2  s  . c o m*/

    // A regular texture atlas would normally usually be used. This returns a white image for images not found in the atlas.
    Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
    pixmap.setColor(new Color(1, 1, 1, 0.33f));
    pixmap.fill();
    final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
    pixmap.dispose();

    String atlasFileName = skeletonFile.nameWithoutExtension();
    if (atlasFileName.endsWith(".json"))
        atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension();
    FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas");
    if (!atlasFile.exists())
        atlasFile = skeletonFile.sibling(atlasFileName + ".atlas.txt");
    TextureAtlasData data = !atlasFile.exists() ? null
            : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
    TextureAtlas atlas = new TextureAtlas(data) {
        public AtlasRegion findRegion(String name) {
            AtlasRegion region = super.findRegion(name);
            return region != null ? region : fake;
        }
    };

    try {
        String extension = skeletonFile.extension();
        if (extension.equalsIgnoreCase("json") || extension.equalsIgnoreCase("txt")) {
            SkeletonJson json = new SkeletonJson(atlas);
            json.setScale(ui.scaleSlider.getValue());
            skeletonData = json.readSkeletonData(skeletonFile);
        } else {
            SkeletonBinary binary = new SkeletonBinary(atlas);
            binary.setScale(ui.scaleSlider.getValue());
            skeletonData = binary.readSkeletonData(skeletonFile);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        ui.toast("Error loading skeleton: " + skeletonFile.name());
        lastModifiedCheck = 5;
        return;
    }

    skeleton = new Skeleton(skeletonData);
    skeleton.setToSetupPose();
    skeleton = new Skeleton(skeleton);
    skeleton.updateWorldTransform();

    state = new AnimationState(new AnimationStateData(skeletonData));

    this.skeletonFile = skeletonFile;
    Preferences prefs = Gdx.app.getPreferences("spine-skeletontest");
    prefs.putString("lastFile", skeletonFile.path());
    prefs.flush();
    lastModified = skeletonFile.lastModified();
    lastModifiedCheck = checkModifiedInterval;

    // Populate UI.

    ui.skeletonLabel.setText(skeletonFile.name());
    {
        Array<String> items = new Array();
        for (Skin skin : skeletonData.getSkins())
            items.add(skin.getName());
        ui.skinList.setItems(items);
    }
    {
        Array<String> items = new Array();
        for (Animation animation : skeletonData.getAnimations())
            items.add(animation.getName());
        ui.animationList.setItems(items);
    }

    // Configure skeleton from UI.

    skeleton.setSkin(ui.skinList.getSelected());
    state.setAnimation(0, ui.animationList.getSelected(), ui.loopCheckbox.isChecked());

    if (reload)
        ui.toast("Reloaded.");
}

From source file:com.kotcrab.vis.ui.widget.file.internal.FileHandleMetadata.java

License:Apache License

private FileHandleMetadata(FileHandle file) {
    this.name = file.name();
    this.directory = file.isDirectory();
    this.lastModified = file.lastModified();
    this.length = file.length();
    this.readableFileSize = FileUtils.readableFileSize(length);
}

From source file:es.eucm.ead.editor.control.workers.LoadFiles.java

License:Open Source License

@Override
protected boolean step() {
    if (projectPaths == null || projectPaths.size == 0) {
        return true;
    }/*w  w  w . j  a v  a2  s  .  co  m*/
    FileHandle file = projectPaths.removeIndex(0);
    if (ProjectUtils.isSupportedImage(file)) {
        String name = file.name();
        FileHandle thumbnail = thumbnailsFolder.child(name);
        String thumbnailPath = thumbnail.path();
        if (!thumbnail.exists() || thumbnail.lastModified() < file.lastModified()) {
            controller.getPlatform().getImageUtils().scale(file, thumbnail);
        }
        result(file.path(), file.nameWithoutExtension(), thumbnailPath);
    }
    return projectPaths.size == 0;
}