Skip to content

Instantly share code, notes, and snippets.

@brk3
Created March 16, 2012 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brk3/2050745 to your computer and use it in GitHub Desktop.
Save brk3/2050745 to your computer and use it in GitHub Desktop.
De-Serializing Android Paths (http://stackoverflow.com/a/6643686/663370)
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);
}
@AndroPlus
Copy link

Hi, i am developing a scratch and guess game. Is it possible to store serialized path objects in Sqlite db ?.
Later i want to redraw whenever i want. Is it possible ?

@abdullahriaz95
Copy link

Hi AndroPlus

Did you find a way to store serialized paths in db?
I little help would be great.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment