
Put the wagon_x.xx.jar in the Android 'libs' folder of your project. If 'libs' doesn't exist, create it at the same level as 'src'.
Wagon 1.10: Save/Load preferences released
Wagon 1.05 beta: preferences save and load requires preference=true attribute.
Wagon 1.04 beta released:
..Save and load WoodBoxes and Crates as SharedPreferences "SP" with wagon.pack(SP)/unpack(SP).
public class MainActivity extends Activity {
// All fields in crates will be copied to
// another instance in the next activity
@Crate(key = "theCrate")
public CrateExample crateExample = new CrateExample();
@WoodBox(key = "theString")
public String sTRING = "I'm a string";
@WoodBox(key = "theList")
public ArrayList<String> lIST;
//...
}
//...
private void startNextAcitivity() {
Wagon<MainActivity> wagon = new Wagon<MainActivity>(this.getClass(), this);//this==MainActivity
Intent intent = new Intent(getApplicationContext(), OtherActivity.class);
wagon.pack(intent);
startActivity(intent);
}
//...
public class OtherActivity extends Activity {
//The crate from the last activity
//will be copied into this crate instance
//with the same field values
@Crate(key = "theCrate")
public CrateExample crateExample = new CrateExample();
@WoodBox(key = "theList")
public ArrayList<String> lIST = new ArrayList<String>();
@WoodBox(key = "theString")
public String sTRING = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Wagon<OtherActivity> wagon = new Wagon<OtherActivity>(this.getClass(), this);
wagon.unpack(getIntent());
}
//...
}
public class CrateExample {
public ArrayList<String> theListInCrate;
public String theStringInCrate;
public int numberInt;
public CrateExample() {
this(new ArrayList<String>(), "", 0);
}
public CrateExample(ArrayList<String> l, String s, int number) {
this.theListInCrate = l;
this.theStringInCrate = s;
this.numberInt = number;
}
//...
}
public class MainActivity extends Activity {
@WoodBox(key = "aBox")
public void float value = 42;
@Crate(key = "aCrate")
public CrateExample crateExample;
//...
public class CrateExample {
//No need to annotate as WoodBox. Already considered one.
public void int number = 77;
//No need to annotate as WoodBox. Already considered one.
public ArrayList<String> theListInCrate;
@Crate(key = "aNestedCrate")
public NestedCrateExample nestedCrate;
//...
}
public class NestedCrateExample {
//No need to annotate as WoodBox. Already considered one.
public float theFloat;
//No need to annotate as WoodBox. Already considered one.
public long theLong;
public NestedCrateExample() {
}
public NestedCrateExample(float f, long l) {
this.theFloat = f;
this.theLong = l;
}
//...
}
...
@Crate(key = "myPreferenceCrate", preference = true)
public CrateExample crate;
@WoodBox(key = "myPreferenceString", preference = true)
public String value;
...
wagon.pack(getSharedPreferences(PREFERENCES_NAME, MODE_PRIVATE));
...
wagon.unpack(getSharedPreferences(PREFERENCES_NAME, MODE_PRIVATE));
...
$ claude mcp add Wagon \
-- python -m otcore.mcp_server <graph>