public I arg(String key, double value) { args.putDouble(key, value); return (I) this; }
public static boolean putJSONValueInBundle(Bundle bundle, String key, Object value) { if (value == null) { bundle.remove(key); } else if (value instanceof Boolean) { bundle.putBoolean(key, (boolean) value); } else if (value instanceof boolean[]) { bundle.putBooleanArray(key, (boolean[]) value); } else if (value instanceof Double) { bundle.putDouble(key, (double) value); } else if (value instanceof double[]) { bundle.putDoubleArray(key, (double[]) value); } else if (value instanceof Integer) { bundle.putInt(key, (int) value); } else if (value instanceof int[]) { bundle.putIntArray(key, (int[]) value); } else if (value instanceof Long) { bundle.putLong(key, (long) value); } else if (value instanceof long[]) { bundle.putLongArray(key, (long[]) value); } else if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof JSONArray) { bundle.putString(key, value.toString()); } else if (value instanceof JSONObject) { bundle.putString(key, value.toString()); } else { return false; } return true; }
@Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); // Save UI state changes to the savedInstanceState. // This bundle will be passed to onCreate if the process is // killed and restarted. savedInstanceState.putBoolean("MyBoolean", true); savedInstanceState.putDouble("myDouble", 1.9); savedInstanceState.putInt("MyInt", 1); savedInstanceState.putString("MyString", "Welcome back to Android"); // etc. }
bundle.putDouble(key, json.getDouble(JSON_VALUE)); } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) { JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
/** * Inserts a double value into the mapping of this Bundle, replacing * any existing value for the given key. * * @param key a String, or null * @param value a double */ public Bundler putDouble(String key, double value) { bundle.putDouble(key, value); return this; }
when(bundle.getFloat(anyString(), anyFloat())).thenAnswer(getOrDefault); doAnswer(put).when(bundle).putDouble(anyString(), anyDouble()); when(bundle.getDouble(anyString())).thenAnswer(get); when(bundle.getDouble(anyString(), anyDouble())).thenAnswer(getOrDefault);
/** * Inserts a double value into the mapping of this Bundle, replacing * any existing value for the given key. * * @param key a String, or null * @param value a double */ public Bundler putDouble(String key, double value) { bundle.putDouble(key, value); return this; }
/** * Sets a double value in the object. * @param key The key for the value. * @param value The value. * @return The builder. */ public E putDouble(final String key, final double value) { this.bundle.putDouble(key, value); return (E)this; }
public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { bundle.putDouble(key, (Double) value); }
public BundleBuilder putDouble(String key, double value) { bundle.putDouble(key, value); return this; }
/** * Inserts a double value into the mapping of the underlying Bundle, replacing any existing value * for the given key. * * @param key a String, or null * @param value a double * @return this bundler instance to chain method calls */ public Bundler put(String key, double value) { delegate.putDouble(key, value); return this; }
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putDouble(INITIAL_TEMPO_KEY, initialTempo); outState.putDouble(INITIAL_PITCH_KEY, initialPitch); outState.putDouble(TEMPO_KEY, getCurrentTempo()); outState.putDouble(PITCH_KEY, getCurrentPitch()); outState.putDouble(STEP_SIZE_KEY, getCurrentStepSize()); }
private static void putDouble(String key, Bundle bundle) { bundle.putDouble(key, random.nextDouble()); }
private void logEvent() { final String eventName = this.mapping.getEventName(); final Bundle parameters = CodelessMatcher.getParameters( mapping, rootView.get(), hostView.get() ); if (parameters.containsKey(AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM)) { String value = parameters.getString(AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM); parameters.putDouble( AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM, AppEventUtility.normalizePrice(value)); } parameters.putString(Constants.IS_CODELESS_EVENT_KEY, "1"); final Bundle params = parameters; FacebookSdk.getExecutor().execute(new Runnable() { @Override public void run() { final Context context = FacebookSdk.getApplicationContext(); final AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context); appEventsLogger.logEvent(eventName, params); } }); }
private void logEvent() { if (null == mapping) { return; } final String eventName = mapping.getEventName(); final Bundle parameters = CodelessMatcher.getParameters( mapping, rootView.get(), hostView.get() ); if (parameters.containsKey(AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM)) { String value = parameters.getString(AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM); parameters.putDouble( AppEventsConstants.EVENT_PARAM_VALUE_TO_SUM, AppEventUtility.normalizePrice(value)); } parameters.putString(Constants.IS_CODELESS_EVENT_KEY, "1"); final Bundle params = parameters; FacebookSdk.getExecutor().execute(new Runnable() { @Override public void run() { final Context context = FacebookSdk.getApplicationContext(); final AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context); appEventsLogger.logEvent(eventName, params); } }); }
@Test public void shouldValidateSyncExtras() { Bundle bundle = new Bundle(); bundle.putString("foo", "strings"); bundle.putLong("long", 10L); bundle.putDouble("double", 10.0d); bundle.putFloat("float", 10.0f); bundle.putInt("int", 10); bundle.putParcelable("account", a); ContentResolver.validateSyncExtrasBundle(bundle); }
@Test public void getDouble() { bundle.putDouble("foo", 5); assertThat(bundle.getDouble("foo")).isEqualTo(5.0); assertThat(bundle.getDouble("bar")).isEqualTo(0.0); assertThat(bundle.getDouble("bar", 7)).isEqualTo(7.0); }
b.putInt("intValue", 7); b.putLong("longValue", 5000000000l); b.putDouble("doubleValue", 3.14); b.putString("stringValue", "hello world"); b.putStringArray("stringArrayValue", new String[] {"first", "second"});
Intent yourInent = new Intent(thisActivity.this, nextActivity.class); Bundle b = new Bundle(); b.putDouble("key", doubleVal); yourIntent.putExtras(b); startActivity(yourIntent);
/** * 附加到Intent的Extra */ public DefaultUriRequest putExtra(String name, double value) { extra().putDouble(name, value); return this; }