Skip to main content

Persistence

An extremely simple API to make MeepMeep reopen the window right where you closed it.

Basic usage:

public static void main(String[] args) {
MeepMeep meepMeep = new MeepMeep(...);

// Create a persistence object linked to the MeepMeep instance
MeepMeepPersistence persistence = new MeepMeepPersistence(meepMeep);

// Restore the settings from the persistence object to the MeepMeep instance
persistence.restore();
}

MeepMeepPersistence methods

Construction

Constructs the persistence object without restoring anything

Params
  • meepMeep: MeepMeep - The MeepMeep instance to restore
  • saveInterval: Long - How often to autosave the window's position (note: leaving it default is fine)
    - Defaults to: 1000L
  • defaultFilePath: String - The file path where the window state should be stored (also recommend leaving default)
    - Defaults to: ./meepmeep.properties
  • tip

    You should gitignore your 'meepmeep.properties' file!

    Assuming you leave the path default, you can just find your root-level .gitignore file, and add meepmeep.properties to it!

    (Make sure your folder view is in Project view, not Android (as seen near top left))

    meepMeepPersistence.restore()

    Where the magic happens, and really all you need. Restores the MeepMeep window's state, thereby reopening it in the same place it was closed

    public static void main(String[] args) {
    // 14361 was here
    MeepMeep meepMeep = new MeepMeep(...);

    // Restores the previous window state of the meepMeep instance
    new MeepMeepPersistence(meepMeep)
    .restore();
    }

    meepMeepPersistence.save()

    Saves the current MeepMeep window state to the given file path. Not sure why you'd ever do this, but have fun!

    Params
  • path: String - The file path where the window state should be stored
    - Defaults to: defaultFilePath
    public static void main(String[] args) {
    MeepMeep meepMeep = new MeepMeep(...);

    // Saves the window state to ./random_file.properties
    new MeepMeepPersistence(meepMeep)
    .save("./random_file.properties");
    }

    meepMeepPersistence.load()

    Loads in the stored MeepMeep window state into MeepMeepPersistence. Note that .restore() still needs to be called after loading in a save file

    Params
  • path: String - The file path where the window state should be stored
    - Defaults to: defaultFilePath
    public static void main(String[] args) {
    MeepMeep meepMeep = new MeepMeep(...);

    // Loads in some window state from ./random_file.properties
    new MeepMeepPersistence(meepMeep)
    .load("./random_file.properties");
    }

    'Shorthand' usage

    Since the other utilities use the MeepMeepUtil class, you can also create a persistence class from that too

    MeepMeepUtil utils = new MeepMeepUtil(meepMeep);

    // utils.persistence() takes in the same params the constructor does (except for the meepMeep)
    // you can now use this like normal
    MeepMeepPersistence persistence = utils.persistence();