public
Created

De-Serializing Android Paths (http://stackoverflow.com/a/6643686/663370)

  • Download Gist
gistfile1.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
private List<SerializablePath> mAddedFPPaths = new ArrayList<SerializablePath>();
 
public void loadState() {
try {
FileInputStream fis = mContext.openFileInput(STATE_DATA);
ObjectInputStream ois = new ObjectInputStream(fis);
 
try {
mAddedFPPaths = (ArrayList<SerializablePath>)ois.readObject();
 
for (SerializablePath p : mAddedFPPaths) {
p.loadPathPointsAsQuadTo();
}
} catch (ClassNotFoundException ce) {
// ...
}
ois.close();
} catch (IOException e) {
// ...
}
}
 
// Then in your draw function something like this..
 
for (SerializablePath p : mAddedFPPaths) {
mPaintFP.setColor(p.getColor());
mPaintFP.setStrokeWidth(p.getStrokeWidth());
mPaintFP.setXfermode(null);
fpCanvas.drawPath(p, mPaintFP);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.