MCPcopy Index your code
hub / github.com/beplaya/Wagon

github.com/beplaya/Wagon @v1.10

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.10 ↗ · + Follow
93 symbols 200 edges 20 files 2 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Wagon

A no fuss method of passing extras between Android Activities and saving/loading preferences using annotations.

How To Use:

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'.

News:

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).

Examples: ([See wiki] (https://github.com/beplaya/Wagon/wiki))

Annotate which fields you'd like to put in the wagon:


    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;
    //...
}

Pack your wagon and start the next activity:

    //...
    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);
    }
    //...

Unpack your wagon:

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());
    }
    //...
}

CrateExample class used above

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;
    }
    //...

}

Nesting crates

You may nest crates within other crates without limit. Simply annotate each Object field in the class as @Crate.
There is no reason to use a WoodBox within a Crate. Any field within a Crate is already considered a WoodBox.
E.G.
    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;
    }
    //...
}

SharedPreferences

Just like extras, Wagon can pass annotated fields to SharedPreferences:
    ...
    @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));
    ...

Core symbols most depended-on inside this repo

pack
called by 10
app/src/com/aj/wagon/Wagon.java
getKey
called by 8
app/src/com/aj/wagon/Wagon.java
unpack
called by 7
app/src/com/aj/wagon/Wagon.java
getEditor
called by 6
app/src/com/aj/wagon/PreferenceCollector.java
isAPackableField
called by 4
app/src/com/aj/wagon/Wagon.java
updateView
called by 2
samples/WagonSample/src/com/aj/wagon/sample/MainActivity.java
unpack
called by 2
samples/WagonSample/src/com/aj/wagon/sample/OtherActivity.java
unpackBox
called by 2
app/src/com/aj/wagon/Wagon.java

Shape

Method 75
Class 18

Languages

Java100%

Modules by API surface

app/src/com/aj/wagon/Wagon.java9 symbols
app/src/com/aj/wagon/PreferenceCollector.java9 symbols
units/src/com/aj/wagon/WagonTests.java7 symbols
samples/WagonSample/src/com/aj/wagon/sample/MainActivity.java7 symbols
app/src/com/aj/wagon/PreferenceExtractor.java7 symbols
app/src/com/aj/wagon/ExtrasExtractor.java7 symbols
app/src/com/aj/wagon/ExtrasCollector.java7 symbols
app/src/com/aj/wagon/Extractor.java7 symbols
app/src/com/aj/wagon/Collector.java7 symbols
units/src/com/aj/wagon/WagonPreferenceTests.java5 symbols
samples/WagonSample/src/com/aj/wagon/sample/OtherActivity.java4 symbols
units/src/com/aj/wagon/testobjects/NestedCrateHolder.java3 symbols

For agents

$ claude mcp add Wagon \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact