Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Bundle parse(String params) {
- String[] arrParams = params.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
- Bundle bundle = new Bundle(arrParams.length);
- for (String s : arrParams) {
- String[] arr = s.split("\\s*=\\s*");
- if (arr.length == 2) {
- final String str = arr[1];
- final String key = arr[0].replaceAll("\\s+", "");
- if (TextUtils.isDigitsOnly(str)) {
- bundle.putInt(key, Integer.parseInt(str));
- continue;
- }
- if (Boolean.TRUE.toString().equals(str)) {
- bundle.putBoolean(key, true);
- continue;
- }
- if (Boolean.FALSE.toString().equals(str)) {
- bundle.putBoolean(key, false);
- continue;
- }
- bundle.putString(key, str);
- }
- }
- return bundle;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement