List of usage examples for android.os Bundle putDouble
public void putDouble(@Nullable String key, double value)
From source file:org.sufficientlysecure.keychain.ui.ViewKeySecurityTokenFragment.java
public static ViewKeySecurityTokenFragment newInstance(long masterKeyId, byte[] fingerprints, String userId, byte[] aid, double version) { ViewKeySecurityTokenFragment frag = new ViewKeySecurityTokenFragment(); Bundle args = new Bundle(); args.putLong(ARG_MASTER_KEY_ID, masterKeyId); args.putByteArray(ARG_FINGERPRINT, fingerprints); args.putString(ARG_USER_ID, userId); args.putByteArray(ARG_CARD_AID, aid); args.putDouble(ARG_CARD_VERSION, version); frag.setArguments(args);//from ww w . j a v a 2s . co m return frag; }
From source file:mx.itesm.logistics.crew_tracking.fragment.ShopListFragment.java
public static ShopListFragment newInstance(float latitude, float longitude) { Bundle arguments = new Bundle(); arguments.putDouble(EXTRA_LATITUDE, latitude); arguments.putDouble(EXTRA_LONGITUDE, longitude); ShopListFragment fragment = new ShopListFragment(); fragment.setArguments(arguments);//from www . j a v a 2 s .c om return fragment; }
From source file:it.cosenonjaviste.mv2m.ArgumentManager.java
public static Bundle writeArgument(Bundle bundle, Object argument) { if (argument != null) { if (argument instanceof Integer) { bundle.putInt(ARGUMENT, (Integer) argument); } else if (argument instanceof Float) { bundle.putFloat(ARGUMENT, (Float) argument); } else if (argument instanceof Double) { bundle.putDouble(ARGUMENT, (Double) argument); } else if (argument instanceof Long) { bundle.putLong(ARGUMENT, (Long) argument); } else if (argument instanceof Parcelable) { bundle.putParcelable(ARGUMENT, (Parcelable) argument); } else if (argument instanceof String) { bundle.putString(ARGUMENT, (String) argument); } else if (argument instanceof Serializable) { bundle.putSerializable(ARGUMENT, (Serializable) argument); } else {//from w ww . jav a2 s.c om throw new RuntimeException( "Invalid argument of class " + argument.getClass() + ", it can't be stored in a bundle"); } } return bundle; }
From source file:Main.java
@SuppressWarnings("unchecked") public static Bundle addMapToBundle(HashMap<String, ?> map, Bundle bundle) { for (String key : map.keySet()) { Object value = map.get(key); if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Integer) { bundle.putInt(key, (Integer) value); } else if (value instanceof Double) { bundle.putDouble(key, ((Double) value)); } else if (value instanceof Boolean) { bundle.putBoolean(key, (Boolean) value); } else if (value instanceof HashMap) { bundle.putBundle(key, addMapToBundle((HashMap<String, Object>) value, new Bundle())); } else if (value instanceof ArrayList) { putArray(key, (ArrayList) value, bundle); }/*from ww w .j a v a 2s . c o m*/ } return bundle; }
From source file:Main.java
/** * /*w w w . j a v a 2s .co m*/ * @param bundle * @param key * @param object */ private static void putBundleObject(Bundle bundle, String key, Object object) { if (bundle != null && object != null && !TextUtils.isEmpty(key)) { if (object instanceof String) { bundle.putString(key, (String) object); } else if (object instanceof Boolean) { bundle.putBoolean(key, (Boolean) object); } else if (object instanceof Double) { bundle.putDouble(key, (Double) object); } else if (object instanceof Float) { Float value = (Float) object; bundle.putDouble(key, (double) value); } else if (object instanceof Integer) { bundle.putInt(key, (Integer) object); } else if (object instanceof Long) { bundle.putLong(key, (Long) object); } else if (object instanceof JSONObject) { object = parseBundle((JSONObject) object); bundle.putBundle(key, (Bundle) object); } else if (object instanceof JSONArray) { int elementQuantity = ((JSONArray) object).length(); Bundle subBundle = new Bundle(elementQuantity); for (int i = 0; i < elementQuantity; i++) { Object subObject = getArrayValue((JSONArray) object, i, null); if (subObject != null) { putBundleObject(subBundle, key, subObject); } } } } }
From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.SR167TollRatesFragment.java
/** * Returns a view for the toll trip provided by the tripItem. * A tripItem holds information about the trip destination and toll rate * * @param tripItem/*from w ww. j a v a 2s.com*/ * @param context * @return */ public static View makeTripView(TollTripEntity tripItem, TollRateSignEntity sign, Context context) { Typeface tfb = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf"); LayoutInflater li = LayoutInflater.from(context); View cv = li.inflate(R.layout.trip_view, null); cv.findViewById(R.id.title).setVisibility(View.GONE); ((TextView) cv.findViewById(R.id.subtitle)).setText("Show on map"); ((TextView) cv.findViewById(R.id.subtitle)) .setTextColor(context.getResources().getColor(R.color.primary_default)); cv.findViewById(R.id.subtitle).setOnClickListener(v -> { Bundle b = new Bundle(); b.putDouble("startLat", sign.getStartLatitude()); b.putDouble("startLong", sign.getStartLongitude()); b.putDouble("endLat", tripItem.getEndLatitude()); b.putDouble("endLong", tripItem.getEndLongitude()); b.putString("title", sign.getLocationName()); b.putString("text", String.format("Travel as far as %s.", tripItem.getEndLocationName())); Intent intent = new Intent(context, TollRatesRouteActivity.class); intent.putExtras(b); context.startActivity(intent); }); ((TextView) cv.findViewById(R.id.content)).setText("Carpools and motorcycles free"); // set updated label ((TextView) cv.findViewById(R.id.updated)) .setText(ParserUtils.relativeTime(tripItem.getUpdated(), "MMMM d, yyyy h:mm a", false)); // set toll TextView currentTimeTextView = cv.findViewById(R.id.current_value); currentTimeTextView.setTypeface(tfb); currentTimeTextView.setText(String.format(Locale.US, "$%.2f", tripItem.getTollRate() / 100)); // set message if there is one if (!tripItem.getMessage().equals("null")) { currentTimeTextView.setText(tripItem.getMessage()); } return cv; }
From source file:org.godotengine.godot.Utils.java
public static void putGodotValue(Bundle bundle, String key, Object value) { if (value instanceof Boolean) { bundle.putBoolean(key, (Boolean) value); } else if (value instanceof Integer) { bundle.putInt(key, (Integer) value); } else if (value instanceof Double) { bundle.putDouble(key, (Double) value); } else if (value instanceof String) { bundle.putString(key, (String) value); } else {// w ww . j a v a 2 s .c om if (value != null) { bundle.putString(key, value.toString()); } } }
From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.I405TollRatesFragment.java
/** * Returns a view for the toll trip provided by the tripItem. * A tripItem holds information about the trip destination and toll rate * * @param tripItem/* w ww.j av a 2 s . com*/ * @param context * @return */ public static View makeTripView(TollTripEntity tripItem, TollRateSignEntity sign, Context context) { Typeface tfb = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf"); LayoutInflater li = LayoutInflater.from(context); View cv = li.inflate(R.layout.trip_view, null); // set end location label ((TextView) cv.findViewById(R.id.title)).setText("to ".concat(tripItem.getEndLocationName())); ((TextView) cv.findViewById(R.id.subtitle)).setText("Show on map"); ((TextView) cv.findViewById(R.id.subtitle)) .setTextColor(context.getResources().getColor(R.color.primary_default)); cv.findViewById(R.id.subtitle).setOnClickListener(v -> { Bundle b = new Bundle(); b.putDouble("startLat", sign.getStartLatitude()); b.putDouble("startLong", sign.getStartLongitude()); b.putDouble("endLat", tripItem.getEndLatitude()); b.putDouble("endLong", tripItem.getEndLongitude()); b.putString("title", sign.getLocationName()); b.putString("text", String.format("Travel as far as %s.", tripItem.getEndLocationName())); Intent intent = new Intent(context, TollRatesRouteActivity.class); intent.putExtras(b); context.startActivity(intent); }); cv.findViewById(R.id.content).setVisibility(View.GONE); // set updated label ((TextView) cv.findViewById(R.id.updated)) .setText(ParserUtils.relativeTime(tripItem.getUpdated(), "MMMM d, yyyy h:mm a", false)); // set toll TextView currentTimeTextView = cv.findViewById(R.id.current_value); currentTimeTextView.setTypeface(tfb); currentTimeTextView.setText(String.format(Locale.US, "$%.2f", tripItem.getTollRate() / 100)); // set message if there is one if (!tripItem.getMessage().equals("null")) { currentTimeTextView.setText(tripItem.getMessage()); } return cv; }
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; }/* w w w .ja v 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: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 w w . j a v a 2 s. c o m*/ } } return intent.putExtras(bundle); }