Created
October 8, 2013 18:36
-
-
Save brianbowden/6889382 to your computer and use it in GitHub Desktop.
Bundler
This file contains hidden or 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
| import android.os.Bundle; | |
| public class Bundler { | |
| private Bundle bundle; | |
| public Bundler() { | |
| bundle = new Bundle(); | |
| } | |
| // Bundle convenience methods | |
| public static Bundle getBundle(String key, String value) { | |
| return Bundler.getInstance().put(key, value).bundle(); | |
| } | |
| public static Bundle getBundle(String key, int value) { | |
| return Bundler.getInstance().put(key, value).bundle(); | |
| } | |
| public static Bundle getBundle(String key, boolean value) { | |
| return Bundler.getInstance().put(key, value).bundle(); | |
| } | |
| // Builder methods | |
| public static Bundler getInstance() { | |
| return new Bundler(); | |
| } | |
| public Bundler put(String key, String value) { | |
| bundle.putString(key, value); | |
| return this; | |
| } | |
| public Bundler put(String key, int value) { | |
| bundle.putInt(key, value); | |
| return this; | |
| } | |
| public Bundler put(String key, boolean value) { | |
| bundle.putBoolean(key, value); | |
| return this; | |
| } | |
| public Bundle bundle() { | |
| return bundle; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment