Example usage for android.os Bundle putFloat

List of usage examples for android.os Bundle putFloat

Introduction

In this page you can find the example usage for android.os Bundle putFloat.

Prototype

@Override
public void putFloat(@Nullable String key, float value) 

Source Link

Document

Inserts a float value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.sun.inject.Injector.java

public static final void putBundleValue(Bundle outState, String name, Object value) {
    if (value instanceof Boolean) {
        outState.putBoolean(name, (Boolean) value);
    } else if (value instanceof String) {
        outState.putString(name, (String) value);
    } else if (value instanceof Integer) {
        outState.putInt(name, (Integer) value);
    } else if (value instanceof Parcelable) {
        outState.putParcelable(name, (Parcelable) value);
    } else if (value instanceof Float) {
        outState.putFloat(name, (Float) value);
    } else if (value instanceof Double) {
        outState.putDouble(name, (Double) value);
    }//from w w  w. ja va  2 s .  c  o m
}

From source file:Main.java

public static Intent mapToIntent(Context context, Class<?> clazz, Map<String, Object> map) {
    Intent intent = new Intent(context, clazz);
    Bundle bundle = new Bundle();
    if (map != null && map.size() > 0) {
        for (String key : map.keySet()) {
            if (map.get(key) instanceof String) {
                bundle.putString(key, (String) map.get(key));
            } else if (map.get(key) instanceof Integer) {
                bundle.putInt(key, (Integer) map.get(key));
            } else if (map.get(key) instanceof Boolean) {
                bundle.putBoolean(key, (Boolean) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Long) {
                bundle.putLong(key, (Long) map.get(key));
            } else if (map.get(key) instanceof Float) {
                bundle.putFloat(key, (Float) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Serializable) {
                bundle.putSerializable(key, (Serializable) map.get(key));
            } else if (map.get(key) instanceof Parcelable) {
                bundle.putParcelable(key, (Parcelable) map.get(key));
            }//from  w ww.j a  v  a  2  s .  c  o  m
        }
    }
    return intent.putExtras(bundle);
}

From source file:org.blanco.tests.viewpager.PlainColorFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putFloat(PLAIN_COLOR_FRAG_ARG_ALPHA, clock.getAlpha());
    super.onSaveInstanceState(outState);
}

From source file:de.j4velin.picturechooser.Main.java

void imageSelected(final String imgPath) {
    if (getIntent().getBooleanExtra("crop", false)) {
        Bundle b = new Bundle();
        b.putString("imgPath", imgPath);
        b.putFloat("aspect",
                getIntent().getIntExtra("aspectX", 0) / (float) getIntent().getIntExtra("aspectY", 1));
        Fragment f = new CropFragment();
        f.setArguments(b);// www  . java  2s  .c  om
        getSupportFragmentManager().beginTransaction().replace(android.R.id.content, f).addToBackStack(null)
                .commit();
    } else {
        returnResult(imgPath);
    }
}

From source file:io.forward.MainActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putFloat(INTENT_EXTRA_HEADING, plotter.getHeading());
    savedInstanceState.putFloat(INTENT_EXTRA_LATITUDE, plotter.getLat());
    savedInstanceState.putFloat(INTENT_EXTRA_LONGITUDE, plotter.getLon());
    savedInstanceState.putFloat(INTENT_EXTRA_SPEED_IN_KNOTS, gpsReceiver.getSpeedInKnots());

    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.scooter1556.sms.android.utils.MediaUtils.java

public static MediaDescriptionCompat getMediaDescription(@NonNull MediaElement element) {
    String mediaId = getMediaIDFromMediaElement(element);

    if (mediaId == null) {
        return null;
    }//from w  w  w  . j av  a2s .  c  o m

    Bundle extras = new Bundle();
    if (element.getYear() != null) {
        extras.putShort("Year", element.getYear());
    }
    if (element.getDuration() != null) {
        extras.putDouble("Duration", element.getDuration());
    }
    if (element.getTrackNumber() != null) {
        extras.putShort("TrackNumber", element.getTrackNumber());
    }
    if (element.getDiscNumber() != null) {
        extras.putShort("DiscNumber", element.getDiscNumber());
    }
    if (element.getDiscSubtitle() != null) {
        extras.putString("DiscSubtitle", element.getDiscSubtitle());
    }
    if (element.getGenre() != null) {
        extras.putString("Genre", element.getGenre());
    }
    if (element.getRating() != null) {
        extras.putFloat("Rating", element.getRating());
    }
    if (element.getCertificate() != null) {
        extras.putString("Certificate", element.getCertificate());
    }
    if (element.getTagline() != null) {
        extras.putString("Tagline", element.getTagline());
    }

    MediaDescriptionCompat description = new MediaDescriptionCompat.Builder().setMediaId(mediaId)
            .setTitle(element.getTitle() == null ? "" : element.getTitle()).setSubtitle(getSubtitle(element))
            .setDescription(element.getDescription() == null ? "" : element.getDescription()).setExtras(extras)
            .setIconUri(
                    Uri.parse(RESTService.getInstance().getAddress() + "/image/" + element.getID() + "/cover"))
            .build();

    return description;
}

From source file:se.toxbee.sleepfighter.challenge.shake.ShakeChallenge.java

@Override
public Bundle savedState() {
    Bundle state = new Bundle();
    state.putFloat(KEY_PROGRESS_FLOAT, this.progress);
    return state;
}

From source file:com.andryr.guitartuner.TunerActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putFloat(STATE_NEEDLE_POS, mNeedleView.getTipPos());
    outState.putInt(STATE_PITCH_INDEX, mPitchIndex);
    outState.putFloat(STATE_LAST_FREQ, mLastFreq);
    super.onSaveInstanceState(outState);
}

From source file:com.googlecode.android_scripting.facade.AndroidFacade.java

private static void putNestedJSONObject(JSONObject jsonObject, Bundle bundle) throws JSONException {
    JSONArray names = jsonObject.names();
    for (int i = 0; i < names.length(); i++) {
        String name = names.getString(i);
        Object data = jsonObject.get(name);
        if (data == null) {
            continue;
        }//w w w  .  jav a  2 s.c  om
        if (data instanceof Integer) {
            bundle.putInt(name, ((Integer) data).intValue());
        }
        if (data instanceof Float) {
            bundle.putFloat(name, ((Float) data).floatValue());
        }
        if (data instanceof Double) {
            bundle.putDouble(name, ((Double) data).doubleValue());
        }
        if (data instanceof Long) {
            bundle.putLong(name, ((Long) data).longValue());
        }
        if (data instanceof String) {
            bundle.putString(name, (String) data);
        }
        if (data instanceof Boolean) {
            bundle.putBoolean(name, ((Boolean) data).booleanValue());
        }
        // Nested JSONObject
        if (data instanceof JSONObject) {
            Bundle nestedBundle = new Bundle();
            bundle.putBundle(name, nestedBundle);
            putNestedJSONObject((JSONObject) data, nestedBundle);
        }
        // Nested JSONArray. Doesn't support mixed types in single array
        if (data instanceof JSONArray) {
            // Empty array. No way to tell what type of data to pass on, so skipping
            if (((JSONArray) data).length() == 0) {
                Log.e("Empty array not supported in nested JSONObject, skipping");
                continue;
            }
            // Integer
            if (((JSONArray) data).get(0) instanceof Integer) {
                int[] integerArrayData = new int[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    integerArrayData[j] = ((JSONArray) data).getInt(j);
                }
                bundle.putIntArray(name, integerArrayData);
            }
            // Double
            if (((JSONArray) data).get(0) instanceof Double) {
                double[] doubleArrayData = new double[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    doubleArrayData[j] = ((JSONArray) data).getDouble(j);
                }
                bundle.putDoubleArray(name, doubleArrayData);
            }
            // Long
            if (((JSONArray) data).get(0) instanceof Long) {
                long[] longArrayData = new long[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    longArrayData[j] = ((JSONArray) data).getLong(j);
                }
                bundle.putLongArray(name, longArrayData);
            }
            // String
            if (((JSONArray) data).get(0) instanceof String) {
                String[] stringArrayData = new String[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    stringArrayData[j] = ((JSONArray) data).getString(j);
                }
                bundle.putStringArray(name, stringArrayData);
            }
            // Boolean
            if (((JSONArray) data).get(0) instanceof Boolean) {
                boolean[] booleanArrayData = new boolean[((JSONArray) data).length()];
                for (int j = 0; j < ((JSONArray) data).length(); ++j) {
                    booleanArrayData[j] = ((JSONArray) data).getBoolean(j);
                }
                bundle.putBooleanArray(name, booleanArrayData);
            }
        }
    }
}

From source file:com.prey.json.actions.Geofencing.java

public void start(Context ctx, List<ActionResult> lista, JSONObject parameters) {

    try {/*from   www  . j  ava2  s .  c o m*/

        String origin = parameters.getString("origin");
        String[] centralPoints = origin.split(",");
        String longitude = centralPoints[0];
        String latitude = centralPoints[1];
        String radius = parameters.getString("radius");

        Bundle bundle = new Bundle();
        bundle.putDouble("longitude", Double.parseDouble(longitude));
        bundle.putDouble("latitude", Double.parseDouble(latitude));
        bundle.putFloat("radius", Float.parseFloat(radius));
        bundle.putInt("type", ProxAlertActivity.START);

        Intent popup = new Intent(ctx, ProxAlertActivity.class);
        popup.putExtras(bundle);
        popup.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        ctx.startActivity(popup);

        PreyLogger.i("Finish Geofencing start");

    } catch (JSONException e) {
        PreyLogger.e("Error en json:" + e.getMessage(), e);
        PreyWebServices.getInstance().sendNotifyActionResultPreyHttp(ctx,
                UtilJson.makeMapParam("start", "geofence", "failed", e.getMessage()));
    }

}