List of usage examples for android.os Bundle putDouble
public void putDouble(@Nullable String key, double value)
From source file:com.plusub.lib.service.BaseRequestService.java
/** * ??/*from w w w . j av a 2 s. c o m*/ * <p>Title: transmitParams * <p>Description: * @param map * @return */ private Bundle transmitParams(Map map) { String keys; if (map != null && map.size() > 0) { Bundle bd = new Bundle(); for (Object key : map.keySet()) { //String if (key instanceof String) { keys = (String) key; // Object obj = map.get(key); if (obj instanceof String) { bd.putString(keys, (String) obj); } else if (obj instanceof Integer) { bd.putInt(keys, (Integer) obj); } else if (obj instanceof Boolean) { bd.putBoolean(keys, (Boolean) obj); } else if (obj instanceof Serializable) { bd.putSerializable(keys, (Serializable) obj); } else if (obj instanceof Character) { bd.putChar(keys, (Character) obj); } else if (obj instanceof Double) { bd.putDouble(keys, (Double) obj); } else if (obj instanceof Float) { bd.putFloat(keys, (Float) obj); } else { Logger.e("[MainService] : unknow map values type ! keys:" + keys); } } } return bd; } return null; }
From source file:org.croudtrip.fragments.offer.OfferTripFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); tv_destination.setOnItemClickListener(mAutocompleteClickListener); tv_destination.setThreshold(0);/*from w ww . j a va 2 s . c om*/ LatLngBounds bounds = null; if (locationUpdater.getLastLocation() != null) { bounds = LatLngBounds.builder().include(new LatLng(locationUpdater.getLastLocation().getLatitude(), locationUpdater.getLastLocation().getLongitude())).build(); } adapter = new PlaceAutocompleteAdapter(getActivity(), android.R.layout.simple_list_item_1, bounds, null); tv_destination.setAdapter(adapter); adapter.setGoogleApiClient(googleApiClient); tv_destination.clearFocus(); tv_destination.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { tv_destination.showDropDown(); } } }); try { List<org.croudtrip.db.Place> savedPlaces = dbHelper.getPlaceDao().queryForAll(); ArrayList<PlaceAutocompleteAdapter.PlaceAutocomplete> history = new ArrayList<>(); for (int i = savedPlaces.size() - 1; i >= 0; i--) { if (history.size() == 5) { break; } PlaceAutocompleteAdapter.PlaceAutocomplete a = adapter.new PlaceAutocomplete( savedPlaces.get(i).getId(), savedPlaces.get(i).getDescription()); history.add(a); } adapter.setHistory(history); } catch (SQLException e) { e.printStackTrace(); } // insert the last known location as soon as it is known ReactiveLocationProvider locationProvider = new ReactiveLocationProvider(getActivity()); Subscription subscription = locationProvider.getLastKnownLocation().observeOn(Schedulers.io()) .subscribe(new Action1<Location>() { @Override public void call(Location location) { LatLngBounds bounds = LatLngBounds.builder() .include(new LatLng(location.getLatitude(), location.getLongitude())).build(); adapter.setBounds(bounds); } }); subscriptions.add(subscription); SharedPreferences prefs = getActivity().getSharedPreferences(Constants.SHARED_PREF_FILE_PREFERENCES, Context.MODE_PRIVATE); // get max diversion from shared preferences and update textview as well as the slider int savedMaxDiversion = prefs.getInt(Constants.SHARED_PREF_KEY_DIVERSION, 3); tv_diversion.setText(getString(R.string.offer_max_diversion) + " " + savedMaxDiversion); slider_diversion.setValue(savedMaxDiversion); // get price per km from shared preferences and update textview as well as the slider int savedPrice = prefs.getInt(Constants.SHARED_PREF_KEY_PRICE, 26); tv_price.setText(getString(R.string.price) + " " + savedPrice); slider_price.setValue(savedPrice); // restore previous address String address = prefs.getString(SHARED_PREF_KEY_ADDRESS, ""); String resolvedAddress = prefs.getString(SHARED_PREF_KEY_RESOLVED_ADDRESS, ""); tv_destination.setText(address); tv_address.setText(resolvedAddress); tv_destination.setSelectAllOnFocus(true); slider_diversion.setOnValueChangedListener(new Slider.OnValueChangedListener() { @Override public void onValueChanged(int i) { tv_diversion.setText(getString(R.string.offer_max_diversion) + " " + i); } }); slider_price.setOnValueChangedListener(new Slider.OnValueChangedListener() { @Override public void onValueChanged(int i) { tv_price.setText(getString(R.string.price) + " " + i); } }); if (locationUpdater == null) Timber.d("Location Updater is null"); //Get default car's type from server and set the button text accordingly Subscription Vsubscription = vehicleResource.getVehicle(VehicleManager.getDefaultVehicleId(getActivity())) .compose(new DefaultTransformer<Vehicle>()).subscribe(new Action1<Vehicle>() { @Override public void call(Vehicle vehicle) { if (vehicle != null) { if (vehicle.getType() != null) myCar.setText(vehicle.getType()); } else myCar.setText("My Cars"); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { //Response response = ((RetrofitError) throwable).getResponse(); Timber.e("Failed to fetch with error:\n" + throwable.getMessage()); } }); subscriptions.add(Vsubscription); myCar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Get a list of user vehicles and add it to the ArrayList Subscription vListSubscription = vehicleResource.getVehicles() .compose(new DefaultTransformer<List<Vehicle>>()).subscribe(new Action1<List<Vehicle>>() { @Override public void call(List<Vehicle> vehicles) { carArrayList.clear(); carIdsArray.clear(); if (vehicles.size() > 0) { for (int i = 0; i < vehicles.size(); i++) { carArrayList.add(vehicles.get(i).getType()); carIdsArray.add((int) vehicles.get(i).getId()); Timber.i("Added " + carArrayList.get(i) + " with id: " + (int) vehicles.get(i).getId()); numberOfCars = vehicles.size(); } myCarSelectDialogFragment.show(getFragmentManager(), "Car Select"); } else showCarPlateDialog(); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { Response response = ((RetrofitError) throwable).getResponse(); if (response != null && response.getStatus() == 401) { // Not Authorized } else { Timber.e("error" + throwable.getMessage()); } Timber.e("Couldn't get data" + throwable.getMessage()); } }); subscriptions.add(vListSubscription); //((MaterialNavigationDrawer) getActivity()).setFragmentChild(new VehicleSelectionFragment(), "Select a car as default"); //showCarSelectionDialog(); } }); // By clicking on the offer-trip-button the driver makes his choice public btn_offer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveState(); org.croudtrip.db.Place tempPlace = lastSelected; lastSelected = null; Location currentLocation; if (specifiedLocation == null) { currentLocation = locationUpdater.getLastLocation(); if (currentLocation == null) { Toast.makeText(getActivity().getApplicationContext(), R.string.offer_trip_no_location, Toast.LENGTH_SHORT).show(); AlertDialog.Builder adb = new AlertDialog.Builder(getActivity()); adb.setTitle(getResources().getString(R.string.enable_gps_title)); adb.setMessage(getResources().getString(R.string.gpd_not_available)); adb.setPositiveButton(getResources().getString(R.string.redirect_to_placepicker), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { try { PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder(); Intent intent = intentBuilder .build(getActivity().getApplicationContext()); startActivityForResult(intent, REQUEST_PLACE_PICKER); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } return; } }); adb.show(); return; } } else { currentLocation = specifiedLocation; specifiedLocation = null; } // get destination from string LatLng destination = null; try { List<Address> addresses = null; if (tv_address.getText() == null || tv_address.getText().equals("")) { addresses = geocoder.getFromLocationName(tv_destination.getText().toString(), 1); } else { addresses = geocoder.getFromLocationName(tv_address.getText().toString(), 1); } if (addresses != null && addresses.size() > 0) destination = new LatLng(addresses.get(0).getLatitude(), addresses.get(0).getLongitude()); } catch (IOException e) { Timber.d("Destination Extraction: " + e.getMessage()); Toast.makeText(getActivity().getApplicationContext(), R.string.offer_trip_no_destination, Toast.LENGTH_SHORT).show(); return; } // no destination received if (destination == null) { Toast.makeText(getActivity().getApplicationContext(), R.string.offer_trip_no_destination, Toast.LENGTH_SHORT).show(); return; } try { if (tempPlace != null) { dbHelper.getPlaceDao().delete(tempPlace); dbHelper.getPlaceDao().create(tempPlace); } else { tempPlace = new org.croudtrip.db.Place(); tempPlace.setId(tv_destination.getText().toString()); tempPlace.setDescription(tv_destination.getText().toString()); dbHelper.getPlaceDao().delete(tempPlace); dbHelper.getPlaceDao().create(tempPlace); } } catch (SQLException e) { e.printStackTrace(); } if (VehicleManager.getDefaultVehicleId(getActivity()) == -3) { //Get a list of user vehicles and add it to the ArrayList Subscription vListSubscription = vehicleResource.getVehicles() .compose(new DefaultTransformer<List<Vehicle>>()) .subscribe(new Action1<List<Vehicle>>() { @Override public void call(List<Vehicle> vehicles) { carArrayList.clear(); carIdsArray.clear(); if (vehicles.size() > 0) { for (int i = 0; i < vehicles.size(); i++) { carArrayList.add(vehicles.get(i).getType()); carIdsArray.add((int) vehicles.get(i).getId()); Timber.i("Added " + carArrayList.get(i) + " with id: " + (int) vehicles.get(i).getId()); numberOfCars = vehicles.size(); } myCarSelectDialogFragment.show(getFragmentManager(), "Car Select"); } else showCarPlateDialog(); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { Response response = ((RetrofitError) throwable).getResponse(); if (response != null && response.getStatus() == 401) { // Not Authorized } else { Timber.e("error" + throwable.getMessage()); } Timber.e("Couldn't get data" + throwable.getMessage()); } }); subscriptions.add(vListSubscription); } else { if (currentLocation == null) { return; } // Start the My Trip view for the driver final Bundle b = new Bundle(); b.putString(MyTripDriverFragment.ARG_ACTION, MyTripDriverFragment.ACTION_CREATE); b.putInt("maxDiversion", Integer.valueOf(slider_diversion.getValue() + "")); b.putInt("pricePerKilometer", Integer.valueOf(slider_price.getValue() + "")); b.putDouble("fromLat", currentLocation.getLatitude()); b.putDouble("fromLng", currentLocation.getLongitude()); b.putDouble("toLat", destination.latitude); b.putDouble("toLng", destination.longitude); final MyTripDriverFragment myTripDriverFragment = new MyTripDriverFragment(); b.putLong("vehicle_id", VehicleManager.getDefaultVehicleId(getActivity())); myTripDriverFragment.setArguments(b); // Change "Offer Trip" to "My Trip" in navigation drawer MaterialNavigationDrawer drawer = ((MaterialNavigationDrawer) getActivity()); MaterialSection section = drawer.getSectionByTitle(getString(R.string.menu_offer_trip)); section.setTitle(getString(R.string.menu_my_trip)); // The next fragment shows the "My Trip screen" drawer.setFragment(myTripDriverFragment, getString(R.string.menu_my_trip)); Toast.makeText(getActivity().getApplicationContext(), R.string.offer_trip, Toast.LENGTH_SHORT) .show(); } } }); // if there is currently no position available disable the offer trip button if (locationUpdater.getLastLocation() == null && specifiedLocation == null) { btn_offer.setEnabled(false); loadLocationLayout.setVisibility(View.VISIBLE); Subscription sub = locationProvider.getLastKnownLocation() /* JUST FOR TESTING!!! .observeOn( Schedulers.newThread() ) .subscribeOn(Schedulers.newThread()) .flatMap(new Func1<Location, Observable<Location>>() { @Override public Observable<Location> call(Location location) { try { Thread.sleep(4000); } catch (InterruptedException e) { e.printStackTrace(); } return Observable.just(location); } })*/ .compose(new DefaultTransformer<Location>()).subscribe(new Action1<Location>() { @Override public void call(Location location) { if (location == null) return; locationUpdater.setLastLocation(location); btn_offer.setEnabled(true); loadLocationLayout.setVisibility(View.GONE); } }); subscriptions.add(sub); } }
From source file:org.florescu.android.rangeseekbar.RangeSeekBar.java
/** * Overridden to save instance state when device orientation changes. This method is called automatically if you assign an id to the RangeSeekBar widget using the {@link #setId(int)} method. Other members of this class than the normalized min and max values don't need to be saved. *///w w w . ja va 2 s . com @Override protected Parcelable onSaveInstanceState() { final Bundle bundle = new Bundle(); bundle.putParcelable("SUPER", super.onSaveInstanceState()); bundle.putDouble("MIN", normalizedMinValue); bundle.putDouble("MAX", normalizedMaxValue); return bundle; }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
@Rpc(description = "Get list of constants (static final fields) for a class") public Bundle getConstants( @RpcParameter(name = "classname", description = "Class to get constants from") String classname) throws Exception { Bundle result = new Bundle(); int flags = Modifier.FINAL | Modifier.PUBLIC | Modifier.STATIC; Class<?> clazz = Class.forName(classname); for (Field field : clazz.getFields()) { if ((field.getModifiers() & flags) == flags) { Class<?> type = field.getType(); String name = field.getName(); if (type == int.class) { result.putInt(name, field.getInt(null)); } else if (type == long.class) { result.putLong(name, field.getLong(null)); } else if (type == double.class) { result.putDouble(name, field.getDouble(null)); } else if (type == char.class) { result.putChar(name, field.getChar(null)); } else if (type instanceof Object) { result.putString(name, field.get(null).toString()); }/*from ww w . ja va 2s . com*/ } } return result; }
From source file:qr.cloud.qrpedia.MessageViewerActivity.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { savedInstanceState.putBoolean(getString(R.string.key_location_tab_visited), mLocationTabEnabled); savedInstanceState.putString(getString(R.string.key_product_details), mProductDetails); if (mLocation != null) { savedInstanceState.putDouble(QRCloudUtils.DATABASE_PROP_LATITUDE, mLocation.getLatitude()); savedInstanceState.putDouble(QRCloudUtils.DATABASE_PROP_LONGITUDE, mLocation.getLongitude()); }/*from w ww.j a va 2 s . c o m*/ savedInstanceState.putLong(getString(R.string.key_location_request_time), mManualLocationRequestTime); super.onSaveInstanceState(savedInstanceState); }
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
@Override protected void onSaveInstanceState(Bundle save) { super.onSaveInstanceState(save); save.putLong(INSTANCE_TRACK, mTrackId); save.putDouble(INSTANCE_SPEED, mAverageSpeed); save.putInt(INSTANCE_ZOOM, this.mMapView.getZoomLevel()); GeoPoint point = this.mMapView.getMapCenter(); save.putInt(INSTANCE_E6LAT, point.getLatitudeE6()); save.putInt(INSTANCE_E6LONG, point.getLongitudeE6()); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addGeofence(CallbackContext callbackContext, JSONObject config) { try {/*from www.j a v a 2 s .c o m*/ String identifier = config.getString("identifier"); final Bundle event = new Bundle(); event.putString("name", BackgroundGeolocationService.ACTION_ADD_GEOFENCE); event.putBoolean("request", true); event.putFloat("radius", (float) config.getLong("radius")); event.putDouble("latitude", config.getDouble("latitude")); event.putDouble("longitude", config.getDouble("longitude")); event.putString("identifier", identifier); if (config.has("notifyOnEntry")) { event.putBoolean("notifyOnEntry", config.getBoolean("notifyOnEntry")); } if (config.has("notifyOnExit")) { event.putBoolean("notifyOnExit", config.getBoolean("notifyOnExit")); } if (config.has("notifyOnDwell")) { event.putBoolean("notifyOnDwell", config.getBoolean("notifyOnDwell")); } if (config.has("loiteringDelay")) { event.putInt("loiteringDelay", config.getInt("loiteringDelay")); } addGeofenceCallbacks.put(identifier, callbackContext); postEvent(event); } catch (JSONException e) { e.printStackTrace(); callbackContext.error(e.getMessage()); } }
From source file:fr.cph.chicago.core.activity.BusBoundActivity.java
@Override public final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); App.checkBusData(this); if (!this.isFinishing()) { setContentView(R.layout.activity_bus_bound); ButterKnife.bind(this); if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) { final Bundle extras = getIntent().getExtras(); busRouteId = extras.getString(bundleBusRouteId); busRouteName = extras.getString(bundleBusRouteName); bound = extras.getString(bundleBusBound); boundTitle = extras.getString(bundleBusBoundTitle); }/*from w w w . j a va 2 s . co m*/ busBoundAdapter = new BusBoundAdapter(); setListAdapter(busBoundAdapter); getListView().setOnItemClickListener((adapterView, view, position, id) -> { final BusStop busStop = (BusStop) busBoundAdapter.getItem(position); final Intent intent = new Intent(getApplicationContext(), BusActivity.class); final Bundle extras = new Bundle(); extras.putInt(bundleBusStopId, busStop.getId()); extras.putString(bundleBusStopName, busStop.getName()); extras.putString(bundleBusRouteId, busRouteId); extras.putString(bundleBusRouteName, busRouteName); extras.putString(bundleBusBound, bound); extras.putString(bundleBusBoundTitle, boundTitle); extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude()); extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude()); intent.putExtras(extras); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }); filter.addTextChangedListener(new TextWatcher() { private List<BusStop> busStopsFiltered; @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { busStopsFiltered = new ArrayList<>(); } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { if (busStops != null) { Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s)) .forEach(busStopsFiltered::add); } } @Override public void afterTextChanged(final Editable s) { busBoundAdapter.update(busStopsFiltered); busBoundAdapter.notifyDataSetChanged(); } }); Util.setWindowsColor(this, toolbar, TrainLine.NA); toolbar.setTitle(busRouteId + " - " + boundTitle); toolbar.setNavigationIcon(arrowBackWhite); toolbar.setOnClickListener(v -> finish()); ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound) .subscribe(onNext -> { busStops = onNext; busBoundAdapter.update(onNext); busBoundAdapter.notifyDataSetChanged(); }, onError -> { Log.e(TAG, onError.getMessage(), onError); Util.showOopsSomethingWentWrong(getListView()); }); Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus, BUSES_STOP_URL, 0); // Preventing keyboard from moving background when showing up getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } }
From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.d(TAG, "onSaveInstanceState: executing"); outState.putBoolean(Extra.MAP_HEIGHT_FULL, mHeightFull); IGeoPoint current_location = mMapView.getMapCenter(); int zoomlevel = mMapView.getZoomLevel(); outState.putInt(Extra.ZOOM_LEVEL, zoomlevel); outState.putInt(Extra.LATITUDE, current_location.getLatitudeE6()); outState.putInt(Extra.LONGITUDE, current_location.getLongitudeE6()); GeoPoint selectedPOI = markItemOverlay.getLocation(); if (selectedPOI != null) { outState.putDouble(Extra.SELECTED_LATITUDE, selectedPOI.getLatitude()); outState.putDouble(Extra.SELECTED_LONGITUDE, selectedPOI.getLongitude()); }/*ww w. jav a2s . c o m*/ }
From source file:com.zuzhili.bussiness.helper.CCPHelper.java
/** * ?SDK????/*w w w .ja v a2 s . c om*/ * @param amplitude ??? */ @Override public void onRecordingAmplitude(double amplitude) { Bundle b = new Bundle(); b.putDouble(Device.VOICE_AMPLITUDE, amplitude); sendTarget(WHAT_ON_AMPLITUDE, b); }