-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #63 by saving state of Ultraghost when screen rotates.
Add a bunch of serialization code and some tests.
- Loading branch information
Showing
12 changed files
with
218 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
vograbulary-test/src/com/github/donkirkby/vograbulary/SerializableTools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.github.donkirkby.vograbulary; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.io.Serializable; | ||
|
||
public class SerializableTools { | ||
public static <T extends Serializable> byte[] serialize(T obj) | ||
throws IOException { | ||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); | ||
ObjectOutputStream objectStream = new ObjectOutputStream(byteStream); | ||
objectStream.writeObject(obj); | ||
objectStream.close(); | ||
return byteStream.toByteArray(); | ||
} | ||
|
||
public static <T extends Serializable> T deserialize( | ||
byte[] bytes, | ||
Class<T> clazz) | ||
throws IOException, ClassNotFoundException { | ||
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes); | ||
ObjectInputStream objectStream = new ObjectInputStream(byteStream); | ||
Object obj = objectStream.readObject(); | ||
return clazz.cast(obj); | ||
} | ||
} |
Oops, something went wrong.