Skip to content

Instantly share code, notes, and snippets.

@d-schmidt
Created October 14, 2016 21:13
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 d-schmidt/f3524a17e4e1ae5d17a9eadb0dfc799d to your computer and use it in GitHub Desktop.
Save d-schmidt/f3524a17e4e1ae5d17a9eadb0dfc799d to your computer and use it in GitHub Desktop.
a simple wrapper around android.os.Bundle to fluently build bundles
package pw.dschmidt.helper;
import android.os.Bundle;
public class Bundler {
private Bundle bundle;
private Bundler(int capacity) {
this.bundle = new Bundle(capacity);
}
public static Bundle single(String key, String value) {
Bundle bundle = new Bundle(1);
bundle.putString(key, value);
return bundle;
}
public static Bundler create(int capacity) {
return new Bundler(capacity);
}
public Bundle get() {
return bundle;
}
public Bundler put(String key, String value) {
bundle.putString(key, value);
return this;
}
public Bundler put(String key, double value) {
bundle.putDouble(key, value);
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment