Created
October 14, 2016 21:13
-
-
Save d-schmidt/f3524a17e4e1ae5d17a9eadb0dfc799d to your computer and use it in GitHub Desktop.
a simple wrapper around android.os.Bundle to fluently build bundles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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