Java Code Examples for android.os.Bundle.putBundle()

The following are Jave code examples for showing how to use putBundle() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: boohee_v5.6   File: a.java   View Source Code Vote up 6 votes
public Bundle e() {
    Bundle bundle = new Bundle();
    bundle.putString("ext_ele_name", this.a);
    bundle.putString("ext_ns", this.b);
    bundle.putString("ext_text", this.e);
    Bundle bundle2 = new Bundle();
    if (this.c != null && this.c.length > 0) {
        for (int i = 0; i < this.c.length; i++) {
            bundle2.putString(this.c[i], this.d[i]);
        }
    }
    bundle.putBundle("attributes", bundle2);
    if (this.f != null && this.f.size() > 0) {
        bundle.putParcelableArray("children", a(this.f));
    }
    return bundle;
}
 
Example 2
Project: syncplayer   File: UserListDialogFragment.java   View Source Code Vote up 6 votes
public static UserListDialogFragment newInstance(Stack<syncPlayClientInterface.userFileDetails> users) {
    final UserListDialogFragment fragment = new UserListDialogFragment();
    final Bundle args = new Bundle();
    if(users != null && users.size() > 0) {
        for (int i = 0; i < users.size(); i++) { //
            try {
                Bundle user = new Bundle();
                user.putString("username", users.get(i).getUsername());
                user.putLong("duration", users.get(i).getDuration());
                user.putLong("size", users.get(i).getSize());
                user.putString("filename", users.get(i).getFilename());
                args.putBundle(String.valueOf(i), user);
            } catch (ArrayIndexOutOfBoundsException outOfBounds) {
                //
            }
        }
        args.putInt(ARG_ITEM_COUNT, users.size());
        fragment.setArguments(args);
    } else {
        args.putInt(ARG_ITEM_COUNT, 1);
        fragment.setArguments(args);
    }
    return fragment;
}
 
Example 3
Project: boohee_v5.6   File: DialogFragment.java   View Source Code Vote up 6 votes
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (this.mDialog != null) {
        Bundle dialogState = this.mDialog.onSaveInstanceState();
        if (dialogState != null) {
            outState.putBundle(SAVED_DIALOG_STATE_TAG, dialogState);
        }
    }
    if (this.mStyle != 0) {
        outState.putInt(SAVED_STYLE, this.mStyle);
    }
    if (this.mTheme != 0) {
        outState.putInt(SAVED_THEME, this.mTheme);
    }
    if (!this.mCancelable) {
        outState.putBoolean(SAVED_CANCELABLE, this.mCancelable);
    }
    if (!this.mShowsDialog) {
        outState.putBoolean(SAVED_SHOWS_DIALOG, this.mShowsDialog);
    }
    if (this.mBackStackId != -1) {
        outState.putInt(SAVED_BACK_STACK_ID, this.mBackStackId);
    }
}
 
Example 4
Project: COB   File: PluginManager.java   View Source Code Vote up 5 votes
public Bundle onSaveInstanceState() {
    Bundle state = new Bundle();
    for (CordovaPlugin plugin : this.pluginMap.values()) {
        if (plugin != null) {
            Bundle pluginState = plugin.onSaveInstanceState();
            if(pluginState != null) {
                state.putBundle(plugin.getServiceName(), pluginState);
            }
        }
    }
    return state;
}
 
Example 5
Project: mobly-bundled-snippets   File: JsonSerializer.java   View Source Code Vote up 5 votes
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Bundle serializeBleScanResult(android.bluetooth.le.ScanResult scanResult) {
    Bundle result = new Bundle();
    result.putBundle("Device", serializeBluetoothDevice(scanResult.getDevice()));
    result.putInt("Rssi", scanResult.getRssi());
    result.putBundle("ScanRecord", serializeBleScanRecord(scanResult.getScanRecord()));
    result.putLong("TimestampNanos", scanResult.getTimestampNanos());
    return result;
}
 
Example 6
Project: GitHub   File: PresenterLifecycleDelegate.java   View Source Code Vote up 5 votes
/**
 * {@link android.app.Activity#onSaveInstanceState(Bundle)}, {@link android.app.Fragment#onSaveInstanceState(Bundle)}, {@link android.view.View#onSaveInstanceState()}.
 */
public Bundle onSaveInstanceState() {
    Bundle bundle = new Bundle();
    getPresenter();
    if (presenter != null) {
        Bundle presenterBundle = new Bundle();
        presenter.save(presenterBundle);
        bundle.putBundle(PRESENTER_KEY, presenterBundle);
        bundle.putString(PRESENTER_ID_KEY, PresenterStorage.INSTANCE.getId(presenter));
    }
    return bundle;
}
 
Example 7
Project: PlusGram   File: CustomTabsSession.java   View Source Code Vote up 5 votes
public boolean setToolbarItem(int id, @NonNull Bitmap icon, @NonNull String description) {
    Bundle bundle = new Bundle();
    bundle.putInt("android.support.customtabs.customaction.ID", id);
    bundle.putParcelable("android.support.customtabs.customaction.ICON", icon);
    bundle.putString("android.support.customtabs.customaction.DESCRIPTION", description);
    Bundle metaBundle = new Bundle();
    metaBundle.putBundle("android.support.customtabs.extra.ACTION_BUTTON_BUNDLE", bundle);

    try {
        return this.mService.updateVisuals(this.mCallback, metaBundle);
    } catch (RemoteException var7) {
        return false;
    }
}
 
Example 8
Project: QuizApp   File: AbstractQuizWizardModel.java   View Source Code Vote up 5 votes
public Bundle save() {
    Bundle bundle = new Bundle();
    for (QuizPage page : getCurrentPageSequence()) {
        bundle.putBundle(page.getKey(), page.getData());
    }
    return bundle;
}
 
Example 9
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
/**
 * Save the state of any managed dialogs.
 *
 * @param outState place to store the saved state.
 */
private void saveManagedDialogs(Bundle outState) {
    if (mManagedDialogs == null) {
        return;
    }

    final int numDialogs = mManagedDialogs.size();
    if (numDialogs == 0) {
        return;
    }

    Bundle dialogState = new Bundle();

    int[] ids = new int[mManagedDialogs.size()];

    // save each dialog's bundle, gather the ids
    for (int i = 0; i < numDialogs; i++) {
        final int key = mManagedDialogs.keyAt(i);
        ids[i] = key;
        final ManagedDialog md = mManagedDialogs.valueAt(i);
        dialogState.putBundle(savedDialogKeyFor(key), md.mDialog.onSaveInstanceState());
        if (md.mArgs != null) {
            dialogState.putBundle(savedDialogArgsKeyFor(key), md.mArgs);
        }
    }

    dialogState.putIntArray(SAVED_DIALOG_IDS_KEY, ids);
    outState.putBundle(SAVED_DIALOGS_TAG, dialogState);
}
 
Example 10
Project: keemob   File: PluginManager.java   View Source Code Vote up 5 votes
public Bundle onSaveInstanceState() {
    Bundle state = new Bundle();
    for (CordovaPlugin plugin : this.pluginMap.values()) {
        if (plugin != null) {
            Bundle pluginState = plugin.onSaveInstanceState();
            if(pluginState != null) {
                state.putBundle(plugin.getServiceName(), pluginState);
            }
        }
    }
    return state;
}
 
Example 11
Project: kognitivo   File: AppLinkData.java   View Source Code Vote up 5 votes
private static Bundle toBundle(JSONObject node) throws JSONException {
    Bundle bundle = new Bundle();
    @SuppressWarnings("unchecked")
    Iterator<String> fields = node.keys();
    while (fields.hasNext()) {
        String key = fields.next();
        Object value;
        value = node.get(key);

        if (value instanceof JSONObject) {
            bundle.putBundle(key, toBundle((JSONObject) value));
        } else if (value instanceof JSONArray) {
            JSONArray valueArr = (JSONArray) value;
            if (valueArr.length() == 0) {
                bundle.putStringArray(key, new String[0]);
            } else {
                Object firstNode = valueArr.get(0);
                if (firstNode instanceof JSONObject) {
                    Bundle[] bundles = new Bundle[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        bundles[i] = toBundle(valueArr.getJSONObject(i));
                    }
                    bundle.putParcelableArray(key, bundles);
                } else if (firstNode instanceof JSONArray) {
                    // we don't support nested arrays
                    throw new FacebookException("Nested arrays are not supported.");
                } else { // just use the string value
                    String[] arrValues = new String[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        arrValues[i] = valueArr.get(i).toString();
                    }
                    bundle.putStringArray(key, arrValues);
                }
            }
        } else {
            bundle.putString(key, value.toString());
        }
    }
    return bundle;
}
 
Example 12
Project: keemob   File: CordovaInterfaceImpl.java   View Source Code Vote up 5 votes
/**
 * Saves parameters for startActivityForResult().
 */
public void onSaveInstanceState(Bundle outState) {
    if (activityResultCallback != null) {
        String serviceName = activityResultCallback.getServiceName();
        outState.putString("callbackService", serviceName);
    }
    if(pluginManager != null){
        outState.putBundle("plugin", pluginManager.onSaveInstanceState());
    }

}
 
Example 13
Project: kognitivo   File: BundleJSONConverter.java   View Source Code Vote up 5 votes
public static Bundle convertToBundle(JSONObject jsonObject) throws JSONException {
    Bundle bundle = new Bundle();
    @SuppressWarnings("unchecked")
    Iterator<String> jsonIterator = jsonObject.keys();
    while (jsonIterator.hasNext()) {
        String key = jsonIterator.next();
        Object value = jsonObject.get(key);
        if (value == null || value == JSONObject.NULL) {
            // Null is not supported.
            continue;
        }

        // Special case JSONObject as it's one way, on the return it would be Bundle.
        if (value instanceof JSONObject) {
            bundle.putBundle(key, convertToBundle((JSONObject)value));
            continue;
        }

        Setter setter = SETTERS.get(value.getClass());
        if (setter == null) {
            throw new IllegalArgumentException("Unsupported type: " + value.getClass());
        }
        setter.setOnBundle(bundle, key, value);
    }

    return bundle;
}
 
Example 14
Project: orgzly-android   File: SimpleOneLinerDialog.java   View Source Code Vote up 5 votes
public static SimpleOneLinerDialog getInstance(
        int id,
        @StringRes int title,
        @StringRes int hint,
        @StringRes int positiveButtonText,
        @StringRes int negativeButtonText,
        String defaultValue,
        Bundle userData) {

    SimpleOneLinerDialog dialog = new SimpleOneLinerDialog();

    Bundle args = new Bundle();

    args.putInt(ARG_TITLE, title);

    if (hint != 0) {
        args.putInt(ARG_HINT, hint);
    }

    if (defaultValue != null) {
        args.putString(ARG_VALUE, defaultValue);
    }

    args.putInt(ARG_ID, id);

    if (userData != null) {
        args.putBundle(ARG_USER_DATA, userData);
    }

    args.putInt(ARG_POSITIVE_BUTTON_TEXT, positiveButtonText);
    args.putInt(ARG_NEGATIVE_BUTTON_TEXT, negativeButtonText);

    dialog.setArguments(args);

    return dialog;
}
 
Example 15
Project: RNLearn_Project1   File: Arguments.java   View Source Code Vote up 5 votes
/**
 * Convert a {@link WritableMap} to a {@link Bundle}.
 * @param readableMap the {@link WritableMap} to convert.
 * @return the converted {@link Bundle}.
 */
@Nullable
public static Bundle toBundle(@Nullable ReadableMap readableMap) {
  if (readableMap == null) {
    return null;
  }

  ReadableMapKeySetIterator iterator = readableMap.keySetIterator();

  Bundle bundle = new Bundle();
  while (iterator.hasNextKey()) {
    String key = iterator.nextKey();
    ReadableType readableType = readableMap.getType(key);
    switch (readableType) {
      case Null:
        bundle.putString(key, null);
        break;
      case Boolean:
        bundle.putBoolean(key, readableMap.getBoolean(key));
        break;
      case Number:
        // Can be int or double.
        bundle.putDouble(key, readableMap.getDouble(key));
        break;
      case String:
        bundle.putString(key, readableMap.getString(key));
        break;
      case Map:
        bundle.putBundle(key, toBundle(readableMap.getMap(key)));
        break;
      case Array:
        // TODO t8873322
        throw new UnsupportedOperationException("Arrays aren't supported yet.");
      default:
        throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
    }
  }

  return bundle;
}
 
Example 16
Project: rxbase-android   File: PresenterManager.java   View Source Code Vote up 5 votes
public void save(final @NonNull TfcBaseActivityPresenter activityPresenter,
                 final @NonNull Bundle envelope) {
    envelope.putString(PRESENTER_ID_KEY, findIdForPresenter(activityPresenter));

    final Bundle state = new Bundle();
    envelope.putBundle(PRESENTER_STATE_KEY, state);
}
 
Example 17
Project: Melophile   File: PlaylistActivity.java   View Source Code Vote up 4 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBundle(Constants.EXTRA_DATA,data);
}
 
Example 18
Project: GitHub   File: NucleusFragmentActivity.java   View Source Code Vote up 4 votes
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBundle(PRESENTER_STATE_KEY, presenterDelegate.onSaveInstanceState());
}
 
Example 19
Project: GitHub   File: NucleusFragmentActivity.java   View Source Code Vote up 4 votes
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBundle(PRESENTER_STATE_KEY, presenterDelegate.onSaveInstanceState());
}
 
Example 20
Project: AndroidActorModel   File: ServiceRegistration.java   View Source Code Vote up 3 votes
private Bundle onRegisterBundle() {

        Bundle bundle = new Bundle(2);

        bundle.putBundle(KEY_EXTRA_MESSENGERS,
                new MessengersBundleFromMap().apply(cache.messengers));

        bundle.putBundle(KEY_EXTRA_PENDING_MESSAGES,
                new PendingMessagesAsBundle().apply(cache.pendingMessages.messagesQueue));

        return bundle;
    }