List of usage examples for android.os Bundle getDouble
public double getDouble(String key)
From source file:com.nextgis.maplibui.dialog.SelectZoomLevelsDialog.java
@NonNull @Override/*from w w w .j a v a 2 s. co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { if (null != savedInstanceState) { mLayerId = savedInstanceState.getInt(ConstantsUI.KEY_LAYER_ID); double dfMinX = savedInstanceState.getDouble(TileDownloadService.KEY_MINX); double dfMinY = savedInstanceState.getDouble(TileDownloadService.KEY_MINY); double dfMaxX = savedInstanceState.getDouble(TileDownloadService.KEY_MAXX); double dfMaxY = savedInstanceState.getDouble(TileDownloadService.KEY_MAXY); mEnvelope = new GeoEnvelope(dfMinX, dfMaxX, dfMinY, dfMaxY); } final Context context = getActivity(); View view = View.inflate(context, R.layout.dialog_select_zoom_levels, null); IGISApplication app = (IGISApplication) getActivity().getApplication(); final MapDrawable map = (MapDrawable) app.getMap(); final int left = (int) map.getZoomLevel() - 1; int right = (int) map.getZoomLevel() + 1; // Get the index value TextViews mTilesCount = (TextView) view.findViewById(R.id.tilesCount); final TextView leftIndexValue = (TextView) view.findViewById(R.id.leftIndexValue); final TextView rightIndexValue = (TextView) view.findViewById(R.id.rightIndexValue); // Get the RangeBar and set the display values of the indices final RangeBar rangebar = (RangeBar) view.findViewById(R.id.rangebar); rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() { @Override public void onIndexChangeListener(RangeBar rangeBar, final int leftThumbIndex, final int rightThumbIndex) { ControlHelper.setZoomText(getActivity(), leftIndexValue, R.string.min, leftThumbIndex); ControlHelper.setZoomText(getActivity(), rightIndexValue, R.string.max, rightThumbIndex); if (mCountTask != null) mCountTask.cancel(true); mTilesCount.setText(getString(R.string.counting).toLowerCase()); mCountTask = new CountTilesTask(map, leftThumbIndex, rightThumbIndex); mCountTask.execute(); } }); rangebar.setThumbIndices(left, right); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(String.format(getString(R.string.current_zoom), map.getZoomLevel())).setView(view) .setPositiveButton(R.string.start, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final int zoomFrom = rangebar.getLeftIndex(); final int zoomTo = rangebar.getRightIndex(); final int layerId = getLayerId(); final GeoEnvelope env = getEnvelope(); //start download service ILayer layer = map.getLayerById(layerId); if (null != layer) { Intent intent = new Intent(getActivity(), TileDownloadService.class); intent.setAction(TileDownloadService.ACTION_ADD_TASK); intent.putExtra(ConstantsUI.KEY_LAYER_ID, layerId); intent.putExtra(TileDownloadService.KEY_PATH, layer.getPath().getName()); intent.putExtra(TileDownloadService.KEY_ZOOM_FROM, zoomFrom); intent.putExtra(TileDownloadService.KEY_ZOOM_TO, zoomTo); intent.putExtra(TileDownloadService.KEY_MINX, env.getMinX()); intent.putExtra(TileDownloadService.KEY_MAXX, env.getMaxX()); intent.putExtra(TileDownloadService.KEY_MINY, env.getMinY()); intent.putExtra(TileDownloadService.KEY_MAXY, env.getMaxY()); getActivity().startService(intent); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); return dialog; }
From source file:org.wheelmap.android.fragment.EditPositionFragment.java
private void executeState(Bundle state) { if (state == null) { return;/*from w ww . j a va 2s . c o m*/ } mCrrLatitude = state.getDouble(Extra.LATITUDE); mCrrLongitude = state.getDouble(Extra.LONGITUDE); }
From source file:cl.smartcities.isci.transportinspector.fragments.ReportMapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); Bundle arguments = getArguments(); if (arguments != null) { //The splash screen got the user position and is in the bundle Double lat = arguments.getDouble("first_lat"); Double lon = arguments.getDouble("first_lon"); this.mapView.getController().setCenter(new GeoPoint(lat, lon)); currentPosition = new GeoPoint(lat, lon); }//from www .j av a2 s.c o m ToggleButton button = (ToggleButton) this.getActivity().findViewById(R.id.button); positionCenterToggleButton = new CenterLocationToggleButton(button, new CenterLocationToggleButton.OnToggleButtonCheck() { @Override public void onButtonCheck() { mapView.getController().setZoom(initialZoom); mapView.getController().setCenter(currentPosition); currentStrategy.onMapDisplacement(initialZoom, currentPosition.getLatitude(), currentPosition.getLongitude()); } }); Log.d(TAG, "End CreateView"); this.currentStrategy = new OnFootStrategy(this, this.mapView, this.currentPosition); this.stateMessage = new StateMessage((ImageView) getActivity().findViewById(R.id.streaming_icon), (TextView) getActivity().findViewById(R.id.state), (ImageView) getActivity().findViewById(R.id.state_icon)); this.currentIsOnFoot(); // registered to receive a message when an event is reported ServerConnectionController.addEventObserver(this); return view; }
From source file:com.esri.android.ecologicalmarineunitexplorer.map.MapFragment.java
@Override public final void onCreate(@NonNull final Bundle savedInstance) { super.onCreate(savedInstance); if (savedInstance != null) { // Populate data from data manager given the point double x = savedInstance.getDouble("X"); double y = savedInstance.getDouble("Y"); ;/*from ww w. j a v a2 s .c o m*/ if (savedInstance.containsKey("SR")) { String sr = savedInstance.getString("SR"); SpatialReference spatialReference = SpatialReference.create(sr); mSelectedPoint = new Point(x, y, spatialReference); } else { mSelectedPoint = new Point(x, y); } Log.i("MapFragment", "Reconstituting instance state in 'onCreate'"); showClickedLocation(mSelectedPoint); } // retain this fragment setRetainInstance(true); mPresenter.start(); }
From source file:com.reliqartz.firsttipcalc.gui.CalcFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mBillBeforeTip = savedInstanceState.getDouble(BILL_WITHOUT_TIP); mTipAmount = savedInstanceState.getDouble(CURRENT_TIP); mFinalBill = savedInstanceState.getDouble(TOTAL_BILL); }/* ww w . j a v a2 s . c om*/ }
From source file:com.facebook.internal.BundleJSONConverterTests.java
@SmallTest public void testSimpleValues() throws JSONException { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1st"); arrayList.add("2nd"); arrayList.add("third"); Bundle innerBundle1 = new Bundle(); innerBundle1.putInt("inner", 1); Bundle innerBundle2 = new Bundle(); innerBundle2.putString("inner", "2"); innerBundle2.putStringArray("deep list", new String[] { "7", "8" }); innerBundle1.putBundle("nested bundle", innerBundle2); Bundle b = new Bundle(); b.putBoolean("boolValue", true); 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" }); b.putStringArrayList("stringArrayListValue", arrayList); b.putBundle("nested", innerBundle1); JSONObject json = BundleJSONConverter.convertToJSON(b); assertNotNull(json);/*from w w w .j a v a2 s.co m*/ assertEquals(true, json.getBoolean("boolValue")); assertEquals(7, json.getInt("intValue")); assertEquals(5000000000l, json.getLong("longValue")); assertEquals(3.14, json.getDouble("doubleValue")); assertEquals("hello world", json.getString("stringValue")); JSONArray jsonArray = json.getJSONArray("stringArrayValue"); assertEquals(2, jsonArray.length()); assertEquals("first", jsonArray.getString(0)); assertEquals("second", jsonArray.getString(1)); jsonArray = json.getJSONArray("stringArrayListValue"); assertEquals(3, jsonArray.length()); assertEquals("1st", jsonArray.getString(0)); assertEquals("2nd", jsonArray.getString(1)); assertEquals("third", jsonArray.getString(2)); JSONObject innerJson = json.getJSONObject("nested"); assertEquals(1, innerJson.getInt("inner")); innerJson = innerJson.getJSONObject("nested bundle"); assertEquals("2", innerJson.getString("inner")); jsonArray = innerJson.getJSONArray("deep list"); assertEquals(2, jsonArray.length()); assertEquals("7", jsonArray.getString(0)); assertEquals("8", jsonArray.getString(1)); Bundle finalBundle = BundleJSONConverter.convertToBundle(json); assertNotNull(finalBundle); assertEquals(true, finalBundle.getBoolean("boolValue")); assertEquals(7, finalBundle.getInt("intValue")); assertEquals(5000000000l, finalBundle.getLong("longValue")); assertEquals(3.14, finalBundle.getDouble("doubleValue")); assertEquals("hello world", finalBundle.getString("stringValue")); List<String> stringList = finalBundle.getStringArrayList("stringArrayValue"); assertEquals(2, stringList.size()); assertEquals("first", stringList.get(0)); assertEquals("second", stringList.get(1)); stringList = finalBundle.getStringArrayList("stringArrayListValue"); assertEquals(3, stringList.size()); assertEquals("1st", stringList.get(0)); assertEquals("2nd", stringList.get(1)); assertEquals("third", stringList.get(2)); Bundle finalInnerBundle = finalBundle.getBundle("nested"); assertEquals(1, finalInnerBundle.getInt("inner")); finalBundle = finalInnerBundle.getBundle("nested bundle"); assertEquals("2", finalBundle.getString("inner")); stringList = finalBundle.getStringArrayList("deep list"); assertEquals(2, stringList.size()); assertEquals("7", stringList.get(0)); assertEquals("8", stringList.get(1)); }
From source file:com.facebook.internal.BundleJSONConverterTest.java
@Test public void testSimpleValues() throws JSONException { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1st"); arrayList.add("2nd"); arrayList.add("third"); Bundle innerBundle1 = new Bundle(); innerBundle1.putInt("inner", 1); Bundle innerBundle2 = new Bundle(); innerBundle2.putString("inner", "2"); innerBundle2.putStringArray("deep list", new String[] { "7", "8" }); innerBundle1.putBundle("nested bundle", innerBundle2); Bundle b = new Bundle(); b.putBoolean("boolValue", true); 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" }); b.putStringArrayList("stringArrayListValue", arrayList); b.putBundle("nested", innerBundle1); JSONObject json = BundleJSONConverter.convertToJSON(b); assertNotNull(json);/*from w w w . j av a 2 s . c o m*/ assertEquals(true, json.getBoolean("boolValue")); assertEquals(7, json.getInt("intValue")); assertEquals(5000000000l, json.getLong("longValue")); assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA); assertEquals("hello world", json.getString("stringValue")); JSONArray jsonArray = json.getJSONArray("stringArrayValue"); assertEquals(2, jsonArray.length()); assertEquals("first", jsonArray.getString(0)); assertEquals("second", jsonArray.getString(1)); jsonArray = json.getJSONArray("stringArrayListValue"); assertEquals(3, jsonArray.length()); assertEquals("1st", jsonArray.getString(0)); assertEquals("2nd", jsonArray.getString(1)); assertEquals("third", jsonArray.getString(2)); JSONObject innerJson = json.getJSONObject("nested"); assertEquals(1, innerJson.getInt("inner")); innerJson = innerJson.getJSONObject("nested bundle"); assertEquals("2", innerJson.getString("inner")); jsonArray = innerJson.getJSONArray("deep list"); assertEquals(2, jsonArray.length()); assertEquals("7", jsonArray.getString(0)); assertEquals("8", jsonArray.getString(1)); Bundle finalBundle = BundleJSONConverter.convertToBundle(json); assertNotNull(finalBundle); assertEquals(true, finalBundle.getBoolean("boolValue")); assertEquals(7, finalBundle.getInt("intValue")); assertEquals(5000000000l, finalBundle.getLong("longValue")); assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA); assertEquals("hello world", finalBundle.getString("stringValue")); List<String> stringList = finalBundle.getStringArrayList("stringArrayValue"); assertEquals(2, stringList.size()); assertEquals("first", stringList.get(0)); assertEquals("second", stringList.get(1)); stringList = finalBundle.getStringArrayList("stringArrayListValue"); assertEquals(3, stringList.size()); assertEquals("1st", stringList.get(0)); assertEquals("2nd", stringList.get(1)); assertEquals("third", stringList.get(2)); Bundle finalInnerBundle = finalBundle.getBundle("nested"); assertEquals(1, finalInnerBundle.getInt("inner")); finalBundle = finalInnerBundle.getBundle("nested bundle"); assertEquals("2", finalBundle.getString("inner")); stringList = finalBundle.getStringArrayList("deep list"); assertEquals(2, stringList.size()); assertEquals("7", stringList.get(0)); assertEquals("8", stringList.get(1)); }
From source file:fr.eoit.activity.fragment.iteminfo.PricesDialog.java
@Override protected void onCreateSimpleDialog(View inflatedLayout, Bundle savedInstanceState) { if (savedInstanceState != null) { itemId = savedInstanceState.getInt("itemId"); chosenPriceId = savedInstanceState.getInt("chosenPriceId"); fixedPrice = savedInstanceState.getDouble("fixedPrice"); }//from w w w .ja v a 2 s .c o m nfPercent = new DecimalFormat("##0.#%"); this.inflatedLayout = inflatedLayout; }
From source file:br.org.funcate.dynamicforms.FormActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // make sure the orientation can't be changed once this activity started int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else {//from w ww .j a va2 s .c o m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } Bundle extras = getIntent().getExtras(); if (extras != null) { sectionName = extras.getString(LibraryConstants.PREFS_KEY_FORM_NAME); sectionObjectString = extras.getString(LibraryConstants.PREFS_KEY_FORM_JSON); latitude = extras.getDouble(LibraryConstants.LATITUDE); longitude = extras.getDouble(LibraryConstants.LONGITUDE); elevation = extras.getDouble(LibraryConstants.ELEVATION); noteId = extras.getLong(LibraryConstants.SELECTED_POINT_ID); } try { if (sectionObjectString == null) { sectionObject = TagsManager.getInstance(this).getSectionByName(sectionName); // copy the section object, which will be kept around along the activity sectionObjectString = sectionObject.toString(); } sectionObject = new JSONObject(sectionObjectString); formNames4Section = TagsManager.getFormNames4Section(sectionObject); } catch (Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } setContentView(R.layout.form); }
From source file:com.nextgis.mobile.MainActivity.java
void doBindService() { mTrackAddPointHandler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); Bundle resultData = msg.getData(); double dfLat = resultData.getDouble("lat"); double dfLon = resultData.getDouble("lon"); // mMap.addPointToRouteOverlay(dfLon, dfLat); }/* ww w . ja va2s. c o m*/ }; bindService(new Intent(this, TrackerService.class), m_oConnection, 0); }