Example usage for android.os Bundle putDouble

List of usage examples for android.os Bundle putDouble

Introduction

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

Prototype

public void putDouble(@Nullable String key, double value) 

Source Link

Document

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

Usage

From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java

private void retrieveLocation() {
    // Build HTTP request
    StringBuilder builder = new StringBuilder();
    HttpClient client = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(
            "http://maps.google." + "com/maps/api/geocode/json?address=" + addressURL + "&sensor=false");

    // Send HTTP request
    try {/*from   w  w w  .  j a v a  2  s  .  co  m*/
        HttpResponse response = client.execute(httpGet);
        StatusLine statusLine = response.getStatusLine();
        int statusCode = statusLine.getStatusCode();

        if (statusCode == 200) {
            // Read the returned content into a string
            HttpEntity entity = response.getEntity();
            InputStream content = entity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(content));
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
        } else {
            // Something is wrong, inform user of the error
            Log.e(TAG, "Failed to download file");
            Toast.makeText(getApplicationContext(), "Location retrieval failed. Please try again",
                    Toast.LENGTH_LONG).show();
            Message msg = new Message();
            msg.obj = "SHOW ADDRESS ENTER DIALOG";
            handler.sendMessage(msg);
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Create the JSONObject for parsing the string returned
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject = new JSONObject(builder.toString());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    // Parse the string returned into JSONObject
    try {
        addressArray = (JSONArray) jsonObject.get("results");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    if (addressArray == null) {
        // Nothing returned, inform the user of the error
        Message msg = new Message();
        msg.obj = "SHOW ADDRESS ENTER DIALOG - FAILED";
        handler.sendMessage(msg);
    } else if (addressArray.length() == 0) {
        // No match found, inform the user of the error
        Message msg = new Message();
        msg.obj = "SHOW ADDRESS ENTER DIALOG - NO RESULTS";
        handler.sendMessage(msg);
    } else if (addressArray.length() == 1) {
        // Exact one result returned
        // Set the intent back to FindActivity
        Bundle bundle = new Bundle();
        Intent newIntent = new Intent();
        bundle.putString(Find.TIME, date);
        Double lng = new Double(0);
        Double lat = new Double(0);
        // Parse the JSONObject to get the longitude and latitude
        try {
            lng = addressArray.getJSONObject(0).getJSONObject("geometry").getJSONObject("location")
                    .getDouble("lng");
            lat = addressArray.getJSONObject(0).getJSONObject("geometry").getJSONObject("location")
                    .getDouble("lat");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        bundle.putDouble(Find.LONGITUDE, lng);
        bundle.putDouble(Find.LATITUDE, lat);
        bundle.putInt(Find.IS_ADHOC, REMINDER_SET);
        newIntent.putExtras(bundle);
        setResult(RESULT_OK, newIntent);
        finish();
    } else {
        // More than one results returned
        // Show Address Confirm Dialog for user confirmation
        Message msg = new Message();
        msg.obj = "SHOW ADDRESS CONFIRM DIALOG";
        handler.sendMessage(msg);
    }
}

From source file:com.inmobi.ultrapush.AnalyzeActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putDouble("dtRMS", dtRMS);
    savedInstanceState.putDouble("dtRMSFromFT", dtRMSFromFT);
    savedInstanceState.putDouble("maxAmpDB", maxAmpDB);
    savedInstanceState.putDouble("maxAmpFreq", maxAmpFreq);

    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.wirelessmoves.cl.MainActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    super.onSaveInstanceState(savedInstanceState);

    /* save variables */
    savedInstanceState.putLong("NumberOfSignalStrengthUpdates", NumberOfSignalStrengthUpdates);

    savedInstanceState.putLong("LastCellId", LastCellId);
    savedInstanceState.putLong("NumberOfCellChanges", NumberOfCellChanges);

    savedInstanceState.putLong("LastLacId", LastLacId);
    savedInstanceState.putLong("NumberOfLacChanges", NumberOfLacChanges);

    savedInstanceState.putLongArray("PreviousCells", PreviousCells);
    savedInstanceState.putInt("PreviousCellsIndex", PreviousCellsIndex);
    savedInstanceState.putLong("NumberOfUniqueCellChanges", NumberOfUniqueCellChanges);

    savedInstanceState.putBoolean("outputDebugInfo", outputDebugInfo);

    savedInstanceState.putDouble("CurrentLocationLong", CurrentLocationLong);
    savedInstanceState.putDouble("CurrentLocationLat", CurrentLocationLat);

    /* save the trace data still in the write buffer into a file */
    saveDataToFile(FileWriteBufferStr,/*from   w  ww .j a  v a2  s.c o  m*/
            "---in save instance, " + DateFormat.getTimeInstance().format(new Date()) + "\r\n");
    FileWriteBufferStr = "";

}

From source file:com.trailbehind.android.iburn.map.MapActivity.java

/**
 * Move map.//from w  w w .jav  a  2 s.c  om
 * 
 * @param point
 *            the point
 */
private void moveMap(WgsPoint point) {
    final double lat1 = point.getLat();
    final double lon1 = point.getLon();

    final WgsPoint middlePoint = mMapComponent.getMiddlePoint();
    final double lat0 = middlePoint.getLat();
    final double lon0 = middlePoint.getLon();

    final double latDiff = (lat1 - lat0) / 20;
    final double lonDiff = (lon1 - lon0) / 20;

    for (int i = 1; i < 21; i++) {
        final Bundle bundle = new Bundle();
        if (i != 20) {
            bundle.putDouble(KEY_LAT, (lat0 + (latDiff * i)));
            bundle.putDouble(KEY_LON, (lon0 + (lonDiff * i)));
        } else {
            bundle.putDouble(KEY_LAT, lat1);
            bundle.putDouble(KEY_LON, lon1);
        }

        final Message msg = mActivityHandler.obtainMessage(ActivityHandler.MESSAGE_MOVE_MAP);
        msg.setData(bundle);
        mActivityHandler.sendMessageDelayed(msg, i * 30);
    }
}

From source file:org.cm.podd.report.activity.ReportActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putString("currentFragment", currentFragment);
    outState.putLong("reportId", reportId);
    outState.putLong("reportType", reportType);
    outState.putBoolean("follow", follow);
    outState.putSerializable("formIterator", formIterator);
    outState.putDouble("currentLatitude", currentLatitude);
    outState.putDouble("currentLongitude", currentLongitude);
    outState.putBoolean("testReport", testReport);
    outState.putInt("reportSubmit", reportSubmit);
    outState.putString("followActionName", followActionName);
    if (recordSpec != null) {
        outState.putSerializable("recordSpec", recordSpec);
    }/* w  w w . j  ava  2 s  .co m*/
    outState.putString("parentReportGuid", parentReportGuid);
    super.onSaveInstanceState(outState);
}

From source file:net.alexjf.tmm.fragments.ImmedTransactionStatsFragment.java

private void updateCurrentTransactionSet() {
    if (adapter == null || catPercentageAdapter == null) {
        return;//from  ww  w . j a v a 2s.  co  m
    }

    if (adapter.getCount() == 0 && catPercentageAdapter.getCount() == 0) {
        return;
    }

    if (categoryStatsTask != null) {
        return;
    }

    Utils.preventOrientationChanges(getActivity());

    String strLoading = getActivity().getResources().getString(R.string.analyzing_stats);

    categoryStatsTask = new AsyncTaskWithProgressDialog<ImmediateTransactionAdapter>(getActivity(),
            TASK_CATEGORYSTATS, strLoading) {
        // TODO: Make this more efficient by already getting all the
        // data from the database
        @Override
        protected Bundle doInBackground(ImmediateTransactionAdapter... args) {
            List<ImmediateTransaction> currentTransactionSet = new LinkedList<ImmediateTransaction>();
            Utils.fromAdapterToList(adapter, currentTransactionSet);
            currentFilter.applyInPlace(currentTransactionSet);

            Map<Category, Double> perCategoryValues = new HashMap<Category, Double>();

            double totalValue = 0;
            CurrencyUnit currency = null;

            for (ImmediateTransaction transaction : currentTransactionSet) {
                try {
                    transaction.load();
                    Category cat = transaction.getCategory();
                    cat.load();

                    Money transactionValue = transaction.getValue();

                    if (currency == null) {
                        currency = transactionValue.getCurrencyUnit();
                    }

                    double transactionValueDouble = transactionValue.abs().getAmount().doubleValue();

                    Double existingValue = perCategoryValues.get(cat);

                    totalValue += transactionValueDouble;

                    if (existingValue != null) {
                        transactionValueDouble += existingValue;
                    }

                    perCategoryValues.put(cat, transactionValueDouble);
                } catch (DatabaseException e) {
                    setThrowable(e);
                    return null;
                }
            }

            Bundle bundle = new Bundle();
            int size = perCategoryValues.size();
            Category[] categories = new Category[size];
            double[] values = new double[size];

            List<Entry<Category, Double>> catValues = new ArrayList<Entry<Category, Double>>(
                    perCategoryValues.entrySet());
            Collections.sort(catValues, new Comparator<Entry<Category, Double>>() {
                @Override
                public int compare(Map.Entry<Category, Double> arg0, Map.Entry<Category, Double> arg1) {
                    return arg0.getValue().compareTo(arg1.getValue());
                }

                ;
            });

            int i = 0;
            for (Entry<Category, Double> catValue : catValues) {
                categories[i] = catValue.getKey();
                values[i] = catValue.getValue();
                i++;
            }

            if (currency != null) {
                bundle.putString(KEY_CURRENCY, currency.getCurrencyCode());
            }
            bundle.putParcelableArray(KEY_CATEGORIES, categories);
            bundle.putDoubleArray(KEY_VALUES, values);
            bundle.putDouble(KEY_TOTALVALUE, totalValue);

            return bundle;
        }

        ;
    };

    categoryStatsTask.setResultListener(this);
    categoryStatsTask.execute(adapter);
}

From source file:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java

/**
 * ????????.//from w w w  . j  a v  a2  s. c  o m
 * 
 * @param sensorEvent .
 */
public void onSensorChanged(final SensorEvent sensorEvent) {
    if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

        mAccellX = sensorEvent.values[0];
        mAccellY = sensorEvent.values[1];
        mAccellZ = sensorEvent.values[2];

        Bundle orientation = new Bundle();
        Bundle a1 = new Bundle();
        a1.putDouble(DeviceOrientationProfile.PARAM_X, 0.0);
        a1.putDouble(DeviceOrientationProfile.PARAM_Y, 0.0);
        a1.putDouble(DeviceOrientationProfile.PARAM_Z, 0.0);
        Bundle a2 = new Bundle();
        a2.putDouble(DeviceOrientationProfile.PARAM_X, mAccellX);
        a2.putDouble(DeviceOrientationProfile.PARAM_Y, mAccellY);
        a2.putDouble(DeviceOrientationProfile.PARAM_Z, mAccellZ);
        Bundle r = new Bundle();
        r.putDouble(DeviceOrientationProfile.PARAM_ALPHA, mGyroX);
        r.putDouble(DeviceOrientationProfile.PARAM_BETA, mGyroY);
        r.putDouble(DeviceOrientationProfile.PARAM_GAMMA, mGyroZ);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION, a1);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION_INCLUDING_GRAVITY, a2);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ROTATION_RATE, r);
        orientation.putLong(DeviceOrientationProfile.PARAM_INTERVAL, 0);
        DeviceOrientationProfile.setInterval(orientation, INTERVAL_TIME);

        List<Event> events = EventManager.INSTANCE.getEventList(mDeviceId,
                DeviceOrientationProfile.PROFILE_NAME, null,
                DeviceOrientationProfile.ATTRIBUTE_ON_DEVICE_ORIENTATION);

        for (int i = 0; i < events.size(); i++) {
            Event event = events.get(i);
            Intent intent = EventManager.createEventMessage(event);

            intent.putExtra(DeviceOrientationProfile.PARAM_ORIENTATION, orientation);
            getContext().sendBroadcast(intent);
        }

    } else if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
        mGyroX = sensorEvent.values[0];
        mGyroY = sensorEvent.values[1];
        mGyroZ = sensorEvent.values[2];
    }
}

From source file:org.onebusaway.android.report.ui.InfrastructureIssueActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putFloat(MapParams.ZOOM, mMapFragment.getMapView().getZoomLevelAsFloat());
    ObaStop obaStop = mIssueLocationHelper.getObaStop();
    if (obaStop != null) {
        String stopId = obaStop.getId();
        getIntent().putExtra(MapParams.STOP_ID, stopId);
        outState.putString(MapParams.STOP_ID, stopId);
        outState.putString(MapParams.STOP_NAME, obaStop.getName());
        outState.putString(MapParams.STOP_CODE, obaStop.getStopCode());
        outState.putBoolean(SHOW_STOP_MARKER, true);
    }/*from   w  w w . j  a  va  2 s . c om*/

    outState.putDouble(MapParams.CENTER_LAT, mIssueLocationHelper.getIssueLocation().getLatitude());
    outState.putDouble(MapParams.CENTER_LON, mIssueLocationHelper.getIssueLocation().getLongitude());

    SpinnerItem spinnerItem = (SpinnerItem) mServicesSpinner.getSelectedItem();
    if (spinnerItem != null && (!spinnerItem.isHint() && !spinnerItem.isSection()
            || (spinnerItem.isHint() && mServicesSpinnerFrameLayout.getVisibility() == View.VISIBLE))) {
        Service service = ((ServiceSpinnerItem) spinnerItem).getService();
        outState.putString(RESTORED_SERVICE, service.getService_name());
        outState.putBoolean(SHOW_CATEGORIES, true);
    }

    if (isInfoVisible()) {
        String infoText = ((TextView) mInfoHeader.findViewById(R.id.ri_info_text)).getText().toString();
        outState.putString(SHOW_INFO, infoText);
    }

    outState.putBoolean(ARRIVAL_LIST, mShowArrivalListFragment);
    outState.putBoolean(HEURISTIC_MATCH, mIsAllTransitHeuristicMatch);
    outState.putString(AGENCY_NAME, mAgencyName);
    outState.putString(SELECTED_SERVICE_TYPE, mTransitServiceIssueTypeWithoutStop);
    outState.putString(ACTION_BAR_TITLE, getTitle().toString());
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java

private DosePickerFragment getDosePickerFragment(Presentation p, ScheduleItem item, Schedule s) {
    DosePickerFragment dpf = null;//from  w  w w .j  av a 2 s .  c o m
    Bundle arguments = new Bundle();

    if (p != null && (p.equals(Presentation.DROPS) || p.equals(Presentation.PILLS)
            || p.equals(Presentation.CAPSULES) || p.equals(Presentation.EFFERVESCENT))) {
        dpf = new PillDosePickerFragment();
    } else {
        dpf = new DefaultDosePickerFragment();
        arguments.putSerializable("presentation", p);
    }
    if (item != null) {
        arguments.putDouble("dose", item.dose());
    } else if (s != null) {
        arguments.putDouble("dose", s.dose());
    }

    dpf.setArguments(arguments);
    return dpf;

}

From source file:planets.position.Planets.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_linear);

    titleButton = (Button) findViewById(R.id.titleButton);
    positionButton = (Button) findViewById(R.id.positionButton);
    whatupButton = (Button) findViewById(R.id.whatupButton);
    solarButton = (Button) findViewById(R.id.solarEclButton);
    lunarButton = (Button) findViewById(R.id.lunarEclButton);
    locationButton = (Button) findViewById(R.id.locationButton);
    realButton = (Button) findViewById(R.id.realButton);

    cr = getApplicationContext().getContentResolver();
    getSupportLoaderManager().initLoader(PLANET_LOADER, null, this);

    if (!(checkFiles("semo_18.se1") && checkFiles("sepl_18.se1"))) {
        // copy files thread
        copyFilesTask = new CopyFilesTask();
        copyFilesTask.execute();/*w w  w .  j ava2s .c  o m*/
    } else
        loadLocation();

    titleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // about description
            Bundle b = new Bundle();
            b.putInt("res", R.string.main_about);
            Intent i = new Intent(Planets.this, About.class);
            i.putExtras(b);
            startActivity(i);
        }
    });

    positionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Launch the Planet Position activity
            if (checkLocation()) {
                planetDialog = PlanetListDialog.newInstance(R.array.planets_array, 1, R.string.planet_prompt,
                        0);
                planetDialog.show(getSupportFragmentManager(), "planetDialog");
            } else {
                loadLocation();
            }
        }
    });

    locationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            enterLocManual();
        }

    });

    whatupButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Launch the What's Up Now activity
            if (checkLocation()) {
                Bundle b = new Bundle();
                b.putDouble("Lat", latitude);
                b.putDouble("Long", longitude);
                b.putDouble("Elevation", elevation);
                b.putDouble("Offset", offset);
                Intent i = new Intent(Planets.this, ViewWhatsUp.class);
                i.putExtras(b);
                startActivity(i);
            } else
                loadLocation();
        }

    });

    realButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Launch Real Time Position activity
            if (checkLocation()) {
                planetDialog = PlanetListDialog.newInstance(R.array.planets_array, 2, R.string.planet_prompt,
                        0);
                planetDialog.show(getSupportFragmentManager(), "planetDialog");
            } else {
                loadLocation();
            }
        }

    });

    solarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Launch the Solar Eclipse activity
            if (checkLocation()) {
                Bundle b = new Bundle();
                b.putDouble("Lat", latitude);
                b.putDouble("Long", longitude);
                b.putDouble("Elevation", elevation);
                b.putDouble("Offset", offset);
                Intent i = new Intent(Planets.this, SolarEclipse.class);
                i.putExtras(b);
                startActivity(i);
            } else {
                loadLocation();
            }
        }

    });

    lunarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Launch the Lunar Eclipse activity
            if (checkLocation()) {
                Bundle b = new Bundle();
                b.putDouble("Lat", latitude);
                b.putDouble("Long", longitude);
                b.putDouble("Elevation", elevation);
                b.putDouble("Offset", offset);
                Intent i = new Intent(Planets.this, LunarEclipse.class);
                i.putExtras(b);
                startActivity(i);
            } else {
                loadLocation();
            }
        }

    });

}